55 tags :
66 - " v*"
77
8+ permissions :
9+ contents : write # required to create releases
10+
811jobs :
912 build :
1013 runs-on : ubuntu-latest
1114 strategy :
1215 matrix :
13- goos : [linux, windows, darwin]
1416 goarch : [amd64, arm64]
17+
1518 steps :
1619 - name : Checkout code
1720 uses : actions/checkout@v4
@@ -21,23 +24,14 @@ jobs:
2124 with :
2225 go-version : " 1.23"
2326
24- - name : Build binaries
27+ - name : Build Linux binaries
2528 run : |
26- make CI=true build \
27- BINARY_NAME=coldwire-server \
28- GOOS=${{ matrix.goos }} \
29- GOARCH=${{ matrix.goarch }} \
30- BIN_DIR=bin
31- # make will create bin/<binary>-<os>-<arch>(.exe)
32-
33- - name : Show bin contents (build)
34- run : ls -la bin || true
29+ make build CI=true BINARY_NAME=coldwire-server GOOS=linux GOARCH=${{ matrix.goarch }}
3530
3631 - name : Upload artifacts
3732 uses : actions/upload-artifact@v4
3833 with :
39- # Unique artifact name per OS/ARCH
40- name : binaries-${{ matrix.goos }}-${{ matrix.goarch }}
34+ name : binaries-linux-${{ matrix.goarch }}
4135 path : bin/*
4236
4337 release :
@@ -52,58 +46,25 @@ jobs:
5246 with :
5347 path : bin/
5448
55- - name : Show downloaded tree
56- run : |
57- echo "=== bin before flattening ==="
58- ls -laR bin || true
59-
60- - name : Flatten artifacts into bin/
61- run : |
62- set -eu
63- shopt -s nullglob || true
64- # move files from per-artifact subfolders into bin/
65- for d in bin/*; do
66- if [ -d "$d" ]; then
67- # move files (if any) up one level
68- for f in "$d"/*; do
69- # if there are files, move them
70- if [ -e "$f" ]; then
71- mv "$f" bin/ || true
72- fi
73- done
74- # remove the (now likely empty) folder
75- rmdir "$d" 2>/dev/null || true
76- fi
77- done
78- echo "=== bin after flattening ==="
79- ls -la bin || true
80-
8149 - name : Compute SHA256 checksums
8250 run : |
83- set -eu
84- mkdir -p bin
8551 echo "## Checksums" > bin/CHECKSUMS.md
86- # only files, skip the CHECKSUMS.md itself
87- find bin -type f -not -name 'CHECKSUMS.md' -print0 | xargs -0 -n1 sha256sum >> bin/CHECKSUMS.md
52+ for f in bin/*; do
53+ [ -f "$f" ] || continue
54+ sha256sum "$f" >> bin/CHECKSUMS.md
55+ done
8856 cat bin/CHECKSUMS.md
8957
9058 - name : Extract latest changelog section
9159 id : changelog
9260 run : |
93- # Grab the latest "## [v..." section (lines after first match until the next '## [v' or EOF)
9461 latest_notes=$(awk '/^## \[v/{if (found) exit; found=1; next} found {print}' CHANGELOG.md)
95- if [ -z "$latest_notes" ]; then
96- latest_notes="(no changelog entry found)"
97- fi
9862 echo "LATEST_NOTES<<EOF" >> $GITHUB_ENV
9963 echo "$latest_notes" >> $GITHUB_ENV
10064 echo "EOF" >> $GITHUB_ENV
10165
102- - name : Create GitHub Release
103- id : create_release
66+ - name : Publish GitHub Release
10467 uses : actions/create-release@v1
105- env :
106- GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
10768 with :
10869 tag_name : ${{ github.ref_name }}
10970 release_name : Release ${{ github.ref_name }}
@@ -112,30 +73,10 @@ jobs:
11273 prerelease : false
11374
11475 - name : Upload release assets
115- env :
116- GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
117- UPLOAD_URL : ${{ steps.create_release.outputs.upload_url }}
11876 run : |
119- set -eu
120- # upload_url is a template like: https://uploads.github.com/repos/OWNER/REPO/releases/ID/assets{?name,label}
121- # we need to strip the template braces part
122- base_url="${UPLOAD_URL%\{*}"
123- echo "Upload base URL: $base_url"
124-
12577 for f in bin/*; do
126- if [ -f "$f" ]; then
127- name=$(basename "$f")
128- echo "Uploading $name ..."
129- curl --fail -sS -X POST \
130- -H "Authorization: Bearer $GITHUB_TOKEN" \
131- -H "Content-Type: application/octet-stream" \
132- --data-binary @"$f" \
133- "$base_url?name=$name"
134- fi
78+ [ -f "$f" ] || continue
79+ gh release upload "${GITHUB_REF_NAME}" "$f" --clobber
13580 done
136-
137- - name : Show final assets on release (sanity)
138- run : ls -la bin || true
139-
140- - name : Clean build artifacts
141- run : make clean
81+ env :
82+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
0 commit comments