Skip to content

Commit 531c30b

Browse files
committed
feat: add auto-update workflow for vigil releases
1 parent 811bece commit 531c30b

2 files changed

Lines changed: 111 additions & 1 deletion

File tree

.github/workflows/update-vigil.yml

Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
name: Update Vigil formula
2+
3+
on:
4+
repository_dispatch:
5+
types: [vigil-release]
6+
workflow_dispatch:
7+
inputs:
8+
tag:
9+
description: "Release tag (e.g. v0.2.0)"
10+
required: true
11+
type: string
12+
13+
permissions:
14+
contents: write
15+
16+
jobs:
17+
update-formula:
18+
runs-on: r5n-m2-ultra
19+
steps:
20+
- uses: actions/checkout@v6
21+
22+
- name: Resolve tag
23+
id: resolve
24+
env:
25+
DISPATCH_TAG: ${{ github.event.client_payload.tag }}
26+
INPUT_TAG: ${{ inputs.tag }}
27+
run: |
28+
TAG="${DISPATCH_TAG:-$INPUT_TAG}"
29+
if [ -z "$TAG" ]; then
30+
echo "No tag provided"
31+
exit 1
32+
fi
33+
VERSION="${TAG#v}"
34+
echo "tag=$TAG" >> "$GITHUB_OUTPUT"
35+
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
36+
37+
- name: Download release artifacts
38+
env:
39+
TAG: ${{ steps.resolve.outputs.tag }}
40+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
41+
run: |
42+
mkdir -p /tmp/vigil-release
43+
gh release download "$TAG" \
44+
--repo r5n-labs/vigil \
45+
--pattern "vigil-*.zip" \
46+
--pattern "vigil-*.tar.gz" \
47+
-D /tmp/vigil-release
48+
49+
- name: Compute SHA256 hashes and update formula
50+
env:
51+
VERSION: ${{ steps.resolve.outputs.version }}
52+
TAG: ${{ steps.resolve.outputs.tag }}
53+
run: |
54+
set -euo pipefail
55+
56+
sha_darwin_arm64=$(shasum -a 256 /tmp/vigil-release/vigil-darwin-arm64.zip | cut -d' ' -f1)
57+
sha_darwin_x64=$(shasum -a 256 /tmp/vigil-release/vigil-darwin-x64.zip | cut -d' ' -f1)
58+
sha_linux_arm64=$(shasum -a 256 /tmp/vigil-release/vigil-linux-arm64.tar.gz | cut -d' ' -f1)
59+
sha_linux_x64=$(shasum -a 256 /tmp/vigil-release/vigil-linux-x64.tar.gz | cut -d' ' -f1)
60+
61+
cat > Formula/vigil.rb << RUBY
62+
class Vigil < Formula
63+
desc "Self-custody crypto wallet for the terminal"
64+
homepage "https://github.com/r5n-labs/vigil"
65+
version "${VERSION}"
66+
license "FSL-1.1-Apache-2.0"
67+
68+
on_macos do
69+
if Hardware::CPU.arm?
70+
url "https://github.com/r5n-labs/vigil/releases/download/${TAG}/vigil-darwin-arm64.zip"
71+
sha256 "${sha_darwin_arm64}"
72+
else
73+
url "https://github.com/r5n-labs/vigil/releases/download/${TAG}/vigil-darwin-x64.zip"
74+
sha256 "${sha_darwin_x64}"
75+
end
76+
end
77+
78+
on_linux do
79+
if Hardware::CPU.arm?
80+
url "https://github.com/r5n-labs/vigil/releases/download/${TAG}/vigil-linux-arm64.tar.gz"
81+
sha256 "${sha_linux_arm64}"
82+
else
83+
url "https://github.com/r5n-labs/vigil/releases/download/${TAG}/vigil-linux-x64.tar.gz"
84+
sha256 "${sha_linux_x64}"
85+
end
86+
end
87+
88+
def install
89+
bin.install "vigil"
90+
end
91+
92+
test do
93+
assert_match version.to_s, shell_output("#{bin}/vigil --version", 1)
94+
end
95+
end
96+
RUBY
97+
98+
sed -i '' 's/^ //' Formula/vigil.rb
99+
100+
- name: Commit and push
101+
env:
102+
VERSION: ${{ steps.resolve.outputs.version }}
103+
TAG: ${{ steps.resolve.outputs.tag }}
104+
run: |
105+
git config user.name "github-actions[bot]"
106+
git config user.email "github-actions[bot]@users.noreply.github.com"
107+
git add Formula/vigil.rb
108+
git diff --cached --quiet && echo "No changes" && exit 0
109+
git commit -m "chore: bump vigil to ${TAG}"
110+
git push

Formula/vigil.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
class Vigil < Formula
2-
desc "TBA"
2+
desc "Self-custody crypto wallet for the terminal"
33
homepage "https://github.com/r5n-labs/vigil"
44
version "0.1.0"
55
license "FSL-1.1-Apache-2.0"

0 commit comments

Comments
 (0)