@@ -3,10 +3,11 @@ name: Release
3
3
on :
4
4
push :
5
5
tags :
6
- - ' v*' # Push events to matching v*, i.e. v1.0, v20.15.10
6
+ - ' v*' # Trigger on versioned tags, e.g., v1.0, v20.15.10
7
7
8
8
env :
9
9
BINARY_NAME : " httpprobe"
10
+ GO_VERSION : " 1.23.3"
10
11
11
12
jobs :
12
13
test :
18
19
- name : Set up Go
19
20
uses : actions/setup-go@v4
20
21
with :
21
- go-version : ' 1.22.0 '
22
+ go-version : ${{ env.GO_VERSION }}
22
23
23
24
- name : Cache Go modules
24
25
uses : actions/cache@v3
60
61
- name : Set up Go
61
62
uses : actions/setup-go@v4
62
63
with :
63
- go-version : ' 1.23.3 '
64
+ go-version : ${{ env.GO_VERSION }}
64
65
65
66
- name : Cache Go modules
66
67
uses : actions/cache@v3
71
72
${{ runner.os }}-go-
72
73
73
74
- name : Set version
74
- id : version
75
- run : echo "VERSION=$(echo ${{ github.ref }} | cut -d '/' -f 3)" >> $GITHUB_ENV
75
+ run : echo "VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV
76
76
77
77
- name : Build
78
78
env :
@@ -84,25 +84,22 @@ jobs:
84
84
85
85
- name : Prepare artifact
86
86
run : |
87
- mkdir -p dist
87
+ ARTIFACT_NAME="${{ env.BINARY_NAME }}-${{ env.VERSION }}_${{ matrix.platform }}_${{ matrix.arch }}"
88
+ OUTPUT_PATH="dist/${ARTIFACT_NAME}"
89
+ mkdir -p $OUTPUT_PATH
90
+
88
91
if [[ "${{ matrix.platform }}" == "windows" ]]; then
89
- BINARY_PATH="bin/${{ env.BINARY_NAME }}.exe"
90
92
mv bin/${{ env.BINARY_NAME }} bin/${{ env.BINARY_NAME }}.exe
91
- ARTIFACT_NAME="${{ env.BINARY_NAME }}-${{ env.VERSION }}_${{ matrix.platform }}_${{ matrix.arch }}"
92
- mkdir -p dist/tmp
93
- cp $BINARY_PATH dist/tmp/${{ env.BINARY_NAME }}.exe
94
- cd dist && tar -czf $ARTIFACT_NAME.tar.gz -C tmp .
93
+ mv bin/${{ env.BINARY_NAME }}.exe $OUTPUT_PATH/${{ env.BINARY_NAME }}.exe
95
94
else
96
- BINARY_PATH="bin/${{ env.BINARY_NAME }}"
97
- ARTIFACT_NAME="${{ env.BINARY_NAME }}-${{ env.VERSION }}_${{ matrix.platform }}_${{ matrix.arch }}"
98
- mkdir -p dist/tmp
99
- cp $BINARY_PATH dist/tmp/${{ env.BINARY_NAME }}
100
- cd dist && tar -czf $ARTIFACT_NAME.tar.gz -C tmp .
95
+ mv bin/${{ env.BINARY_NAME }} $OUTPUT_PATH/${{ env.BINARY_NAME }}
101
96
fi
102
97
98
+ # Archive the binary (without extra directories)
99
+ tar -czf dist/$ARTIFACT_NAME.tar.gz -C $OUTPUT_PATH .
100
+
103
101
echo "ARTIFACT_PATH=dist/$ARTIFACT_NAME.tar.gz" >> $GITHUB_ENV
104
102
echo "ARTIFACT_NAME=$ARTIFACT_NAME" >> $GITHUB_ENV
105
- shell : bash
106
103
107
104
- name : Upload Build Artifact
108
105
uses : actions/upload-artifact@v4
@@ -127,21 +124,18 @@ jobs:
127
124
path : artifacts
128
125
129
126
- name : Generate Release Body
130
- id : release_body
131
127
run : |
132
- echo "body<<EOF" >> $GITHUB_OUTPUT
133
- echo "Changelog:" >> $GITHUB_OUTPUT
134
- git log $(git describe --tags --abbrev=0 2>/dev/null || echo HEAD~10)..HEAD --oneline >> $GITHUB_OUTPUT
135
- echo "EOF" >> $GITHUB_OUTPUT
128
+ echo "## Changelog" > release_body.md
129
+ git log --pretty=format:"- %s" $(git describe --tags --abbrev=0 2>/dev/null || echo $(git rev-list --max-parents=0 HEAD))..HEAD >> release_body.md
136
130
137
131
- name : Create Release and Upload Assets
138
132
uses : softprops/action-gh-release@v1
139
133
with :
140
134
token : ${{ secrets.GH_PERSONAL_TOKEN }}
141
135
name : Release ${{ github.ref_name }}
142
- body : ${{ steps. release_body.outputs.body }}
136
+ body_path : release_body.md
143
137
files : artifacts/**/*.tar.gz
144
-
138
+
145
139
update-scoop :
146
140
needs : release
147
141
runs-on : ubuntu-latest
@@ -156,88 +150,46 @@ jobs:
156
150
token : ${{ secrets.GH_PERSONAL_TOKEN }}
157
151
158
152
- name : Get release version
159
- id : get_version
160
153
run : |
161
- # Extract tag name from ref
162
154
TAG_NAME="${{ github.ref_name }}"
163
- echo "tag_name=$TAG_NAME" >> $GITHUB_OUTPUT
164
-
165
- # Remove 'v' prefix if present for version number
166
155
VERSION="${TAG_NAME#v}"
167
- echo "version=$VERSION " >> $GITHUB_OUTPUT
168
- echo "Tag: $TAG_NAME, Version: $VERSION"
156
+ echo "tag_name=$TAG_NAME " >> $GITHUB_ENV
157
+ echo "version=$VERSION" >> $GITHUB_ENV
169
158
170
- - name : Download release assets to compute hashes
159
+ - name : Download release assets
171
160
run : |
172
- VERSION=${{ steps.get_version.outputs.version }}
173
- TAG_NAME=${{ steps.get_version.outputs.tag_name }}
174
161
mkdir -p tmp
175
-
176
- # Download assets
177
- curl -L "https://github.com/mrfoh/httpprobe/releases/download/${TAG_NAME}/httpprobe-${TAG_NAME}_windows_amd64.tar.gz" -o tmp/httpprobe-${TAG_NAME}_windows_amd64.tar.gz
178
- curl -L "https://github.com/mrfoh/httpprobe/releases/download/${TAG_NAME}/httpprobe-${TAG_NAME}_windows_386.tar.gz" -o tmp/httpprobe-${TAG_NAME}_windows_386.tar.gz
179
- curl -L "https://github.com/mrfoh/httpprobe/releases/download/${TAG_NAME}/httpprobe-${TAG_NAME}_windows_arm64.tar.gz" -o tmp/httpprobe-${TAG_NAME}_windows_arm64.tar.gz
180
-
181
- # Compute SHA256 hashes
182
- AMD64_HASH=$(sha256sum tmp/httpprobe-${TAG_NAME}_windows_amd64.tar.gz | cut -d ' ' -f 1)
183
- I386_HASH=$(sha256sum tmp/httpprobe-${TAG_NAME}_windows_386.tar.gz | cut -d ' ' -f 1)
184
- ARM64_HASH=$(sha256sum tmp/httpprobe-${TAG_NAME}_windows_arm64.tar.gz | cut -d ' ' -f 1)
185
-
186
- # Store hashes for later use
187
- echo "amd64_hash=$AMD64_HASH" >> $GITHUB_OUTPUT
188
- echo "i386_hash=$I386_HASH" >> $GITHUB_OUTPUT
189
- echo "arm64_hash=$ARM64_HASH" >> $GITHUB_OUTPUT
190
- id : compute_hashes
162
+ for arch in amd64 386 arm64; do
163
+ curl -L "https://github.com/mrfoh/httpprobe/releases/download/${{ github.ref_name }}/httpprobe-${{ github.ref_name }}_windows_$arch.tar.gz" -o tmp/httpprobe-${{ github.ref_name }}_windows_$arch.tar.gz
164
+ done
191
165
192
- - name : Update scoop manifest
166
+ - name : Compute SHA256 hashes
193
167
run : |
194
- VERSION=${{ steps.get_version.outputs.version }}
195
-
196
- # Update version in manifest
197
- jq '.version = env.VERSION' bucket/httpprobe.json > bucket/httpprobe.json.tmp
198
- mv bucket/httpprobe.json.tmp bucket/httpprobe.json
199
-
200
- # Update URLs in manifest
201
- jq '.architecture."64bit".url = "https://github.com/mrfoh/httpprobe/releases/download/v" + env.VERSION + "/httpprobe-v" + env.VERSION + "_windows_amd64.tar.gz"' bucket/httpprobe.json > bucket/httpprobe.json.tmp
202
- mv bucket/httpprobe.json.tmp bucket/httpprobe.json
203
-
204
- jq '.architecture."32bit".url = "https://github.com/mrfoh/httpprobe/releases/download/v" + env.VERSION + "/httpprobe-v" + env.VERSION + "_windows_386.tar.gz"' bucket/httpprobe.json > bucket/httpprobe.json.tmp
205
- mv bucket/httpprobe.json.tmp bucket/httpprobe.json
206
-
207
- jq '.architecture."arm64".url = "https://github.com/mrfoh/httpprobe/releases/download/v" + env.VERSION + "/httpprobe-v" + env.VERSION + "_windows_arm64.tar.gz"' bucket/httpprobe.json > bucket/httpprobe.json.tmp
208
- mv bucket/httpprobe.json.tmp bucket/httpprobe.json
209
-
210
- # Update hashes in manifest
211
- jq --arg hash "${{ steps.compute_hashes.outputs.amd64_hash }}" '.architecture."64bit".hash = $hash' bucket/httpprobe.json > bucket/httpprobe.json.tmp
212
- mv bucket/httpprobe.json.tmp bucket/httpprobe.json
213
-
214
- jq --arg hash "${{ steps.compute_hashes.outputs.i386_hash }}" '.architecture."32bit".hash = $hash' bucket/httpprobe.json > bucket/httpprobe.json.tmp
215
- mv bucket/httpprobe.json.tmp bucket/httpprobe.json
216
-
217
- jq --arg hash "${{ steps.compute_hashes.outputs.arm64_hash }}" '.architecture."arm64".hash = $hash' bucket/httpprobe.json > bucket/httpprobe.json.tmp
218
- mv bucket/httpprobe.json.tmp bucket/httpprobe.json
219
-
220
- # Update autoupdate URLs
221
- jq '.autoupdate.architecture."64bit".url = "https://github.com/mrfoh/httpprobe/releases/download/v$version/httpprobe-v$version_windows_amd64.tar.gz"' bucket/httpprobe.json > bucket/httpprobe.json.tmp
222
- mv bucket/httpprobe.json.tmp bucket/httpprobe.json
223
-
224
- jq '.autoupdate.architecture."32bit".url = "https://github.com/mrfoh/httpprobe/releases/download/v$version/httpprobe-v$version_windows_386.tar.gz"' bucket/httpprobe.json > bucket/httpprobe.json.tmp
225
- mv bucket/httpprobe.json.tmp bucket/httpprobe.json
226
-
227
- jq '.autoupdate.architecture."arm64".url = "https://github.com/mrfoh/httpprobe/releases/download/v$version/httpprobe-v$version_windows_arm64.tar.gz"' bucket/httpprobe.json > bucket/httpprobe.json.tmp
228
- mv bucket/httpprobe.json.tmp bucket/httpprobe.json
168
+ for arch in amd64 386 arm64; do
169
+ HASH=$(sha256sum tmp/httpprobe-${{ github.ref_name }}_windows_$arch.tar.gz | awk '{print $1}')
170
+ echo "${arch}_hash=$HASH" >> $GITHUB_ENV
171
+ done
172
+
173
+ - name : Update Scoop manifest
174
+ run : |
175
+ jq --arg version "${{ env.version }}" \
176
+ --arg amd64 "${{ env.amd64_hash }}" \
177
+ --arg i386 "${{ env.386_hash }}" \
178
+ --arg arm64 "${{ env.arm64_hash }}" \
179
+ '
180
+ .version = $version |
181
+ .architecture."64bit".url = "https://github.com/mrfoh/httpprobe/releases/download/v" + $version + "/httpprobe-v" + $version + "_windows_amd64.tar.gz" |
182
+ .architecture."64bit".hash = $amd64 |
183
+ .architecture."32bit".url = "https://github.com/mrfoh/httpprobe/releases/download/v" + $version + "/httpprobe-v" + $version + "_windows_386.tar.gz" |
184
+ .architecture."32bit".hash = $i386 |
185
+ .architecture."arm64".url = "https://github.com/mrfoh/httpprobe/releases/download/v" + $version + "/httpprobe-v" + $version + "_windows_arm64.tar.gz" |
186
+ .architecture."arm64".hash = $arm64
187
+ ' bucket/httpprobe.json > bucket/httpprobe.json.tmp && mv bucket/httpprobe.json.tmp bucket/httpprobe.json
229
188
230
189
- name : Commit and push updated manifest
231
190
run : |
232
191
git config --global user.name "GitHub Actions Bot"
233
192
git config --global user.email "github-actions[bot]@users.noreply.github.com"
234
-
235
193
git add bucket/httpprobe.json
236
-
237
- # Check if there are changes to commit
238
- if git diff --staged --quiet; then
239
- echo "No changes to commit"
240
- else
241
- git commit -m "chore: update scoop manifest for ${{ github.ref_name }}"
242
- git push origin main
243
- fi
194
+ git commit -m "chore: update scoop manifest for ${{ github.ref_name }} [skip ci]" || exit 0
195
+ git push origin main
0 commit comments