1 name: Scoop Release
2
3 # Dispatched by release-github.yml once the release and its checksums exist.
4 on:
5 workflow_dispatch:
6 inputs:
7 tag:
8 description: "Release tag (e.g. v1.5.2)"
9 required: true
10
11 concurrency:
12 # A re-pushed or re-dispatched tag fires this a second time. Queue the
13 # duplicate behind the original instead of cancelling it: cancelling a run
14 # mid-publish can leave a channel half-uploaded, whereas a queued duplicate
15 # just hits the "already published" check and exits clean.
16 group: ${{ github.workflow }}-${{ github.event.inputs.tag || github.ref_name }}
17 cancel-in-progress: false
18
19 permissions:
20 contents: read
21
22 env:
23 REPO: getsigit/sigit
24
25 jobs:
26 update-scoop-bucket:
27 name: Update Scoop bucket
28 runs-on: ubuntu-latest
29
30 steps:
31 - name: Resolve tag and version
32 id: release
33 shell: bash
34 run: |
35 TAG="${{ github.event.inputs.tag }}"
36 VERSION="${TAG#v}"
37
38 echo "tag=${TAG}" >> "$GITHUB_OUTPUT"
39 echo "version=${VERSION}" >> "$GITHUB_OUTPUT"
40
41 - name: Read SHA256 checksums from release
42 id: sha
43 env:
44 GH_TOKEN: ${{ github.token }}
45 shell: bash
46 run: |
47 mkdir -p artifacts
48
49 gh release download "${{ steps.release.outputs.tag }}" \
50 --repo "${{ env.REPO }}" \
51 --pattern "sigit-win-*.exe.sha256" \
52 --dir artifacts/
53
54 AMD64_SHA=$(cat artifacts/sigit-win-amd64.exe.sha256)
55 ARM64_SHA=$(cat artifacts/sigit-win-arm64.exe.sha256)
56
57 echo "amd64=${AMD64_SHA}" >> "$GITHUB_OUTPUT"
58 echo "arm64=${ARM64_SHA}" >> "$GITHUB_OUTPUT"
59
60 echo "AMD64 SHA256: ${AMD64_SHA}"
61 echo "ARM64 SHA256: ${ARM64_SHA}"
62
63 - name: Checkout Scoop bucket
64 uses: actions/checkout@v6
65 with:
66 repository: getsigit/scoop-bucket
67 token: ${{ secrets.SCOOP_BUCKET_TOKEN }}
68 path: scoop-bucket
69
70 - name: Generate manifest
71 shell: bash
72 run: |
73 VERSION="${{ steps.release.outputs.version }}"
74 TAG="${{ steps.release.outputs.tag }}"
75 AMD64_SHA="${{ steps.sha.outputs.amd64 }}"
76 ARM64_SHA="${{ steps.sha.outputs.arm64 }}"
77
78 mkdir -p scoop-bucket/bucket
79
80 # The `#/sigit.exe` URL fragment is Scoop's rename-on-download
81 # syntax: the release asset is sigit-win-amd64.exe, but the shim has
82 # to end up as sigit.exe for `sigit` to work on PATH.
83 cat > scoop-bucket/bucket/sigit.json <<MANIFEST
84 {
85 "version": "${VERSION}",
86 "description": "siGit Code, an AI coding agent that runs on your machine.",
87 "homepage": "https://sigit.si",
88 "license": "Apache-2.0",
89 "architecture": {
90 "64bit": {
91 "url": "https://github.com/${REPO}/releases/download/${TAG}/sigit-win-amd64.exe#/sigit.exe",
92 "hash": "${AMD64_SHA}"
93 },
94 "arm64": {
95 "url": "https://github.com/${REPO}/releases/download/${TAG}/sigit-win-arm64.exe#/sigit.exe",
96 "hash": "${ARM64_SHA}"
97 }
98 },
99 "bin": "sigit.exe",
100 "checkver": {
101 "github": "https://github.com/${REPO}"
102 },
103 "autoupdate": {
104 "architecture": {
105 "64bit": {
106 "url": "https://github.com/${REPO}/releases/download/v\$version/sigit-win-amd64.exe#/sigit.exe"
107 },
108 "arm64": {
109 "url": "https://github.com/${REPO}/releases/download/v\$version/sigit-win-arm64.exe#/sigit.exe"
110 }
111 },
112 "hash": {
113 "url": "\$url.sha256"
114 }
115 }
116 }
117 MANIFEST
118
119 echo "Generated manifest:"
120 cat scoop-bucket/bucket/sigit.json
121
122 - name: Validate manifest JSON
123 shell: bash
124 run: |
125 if ! jq empty scoop-bucket/bucket/sigit.json; then
126 echo "::error::Generated Scoop manifest is not valid JSON" >&2
127 exit 1
128 fi
129
130 for field in version bin architecture; do
131 if [ "$(jq -r "has(\"${field}\")" scoop-bucket/bucket/sigit.json)" != "true" ]; then
132 echo "::error::Scoop manifest is missing the '${field}' field" >&2
133 exit 1
134 fi
135 done
136
137 - name: Commit and push
138 shell: bash
139 run: |
140 VERSION="${{ steps.release.outputs.version }}"
141
142 cd scoop-bucket
143 git config user.name "github-actions[bot]"
144 git config user.email "github-actions[bot]@users.noreply.github.com"
145 git add bucket/sigit.json
146 git diff --cached --quiet && echo "No changes to commit" && exit 0
147 git commit -m "Update sigit to ${VERSION}"
148 git push