1- name : Release Build
1+ name : Build Release
22
33on :
44 workflow_dispatch :
5+ release :
6+ types : [published]
57 push :
68
79jobs :
8- version :
9- runs-on : ubuntu-latest
10- outputs :
11- version : ${{ steps.get_version.outputs.version }}
12- steps :
13- - name : Checkout codebase
14- uses : actions/checkout@v4
15-
16- - name : Extract version from main.go
17- id : get_version
18- run : |
19- set -e
20- VERSION=$(grep -Eo 'version[[:space:]]*=[[:space:]]*"[^"]+"' main.go | head -n1 | sed -E 's/.*"([^"]+)"/\1/')
21- if [ -z "$VERSION" ]; then
22- echo "::error::Failed to detect version constant in source code"
23- exit 1
24- fi
25- echo "Detected version: $VERSION"
26- echo "version=$VERSION" >> "$GITHUB_OUTPUT"
27-
28- - name : Create git tag if needed
29- if : github.ref == 'refs/heads/main'
30- run : |
31- git config --local user.name "github-actions"
32- git config --local user.email "github-actions@users.noreply.github.com"
33- git fetch --tags --quiet
34- if git rev-parse "refs/tags/v${VERSION}" >/dev/null 2>&1; then
35- echo "Tag v${VERSION} already exists"
36- else
37- git tag -a "v${VERSION}" -m "v${VERSION}"
38- git push origin "v${VERSION}"
39- fi
40- env :
41- VERSION : ${{ steps.get_version.outputs.version }}
42-
4310 build :
44- needs : version
4511 permissions :
46- contents : read
12+ contents : write
4713 strategy :
4814 fail-fast : false
4915 matrix :
@@ -52,18 +18,15 @@ jobs:
5218 goarch : amd64
5319 - goos : darwin
5420 goarch : arm64
55-
5621 - goos : android
5722 goarch : arm64
58-
5923 - goos : linux
6024 goarch : amd64
6125 - goos : linux
6226 goarch : arm64
6327 - goos : linux
6428 goarch : arm
6529 goarm : 7
66-
6730 - goos : windows
6831 goarch : amd64
6932 - goos : windows
8144
8245 - name : Show workflow information
8346 run : |
84- export _NAME=$GOOS-$GOARCH$GOARM$GOMIPS
85- echo "GOOS: $GOOS, GOARCH: $GOARCH, GOARM: $GOARM, GOMIPS: $GOMIPS, RELEASE_NAME: $_NAME"
47+ export _NAME=$GOOS-$GOARCH${ GOARM}
48+ echo "GOOS: $GOOS, GOARCH: $GOARCH, GOARM: $GOARM, RELEASE_NAME: $_NAME"
8649 echo "ASSET_NAME=$_NAME" >> $GITHUB_ENV
8750 echo "REF=${GITHUB_SHA::6}" >> $GITHUB_ENV
8851
@@ -91,41 +54,23 @@ jobs:
9154 with :
9255 go-version : ' 1.24'
9356 check-latest : true
94- cache : false
9557
9658 - name : Build heybabe
9759 run : |
98- go build -v -o bin/ heybabe_${{ env.ASSET_NAME }} -trimpath -ldflags "-s -w -buildid= -X main.version=${{ needs.version.outputs.version }}" .
60+ go build -v -o heybabe_${{ env.ASSET_NAME }}/ -trimpath -ldflags "-s -w -buildid= -X main.version=${{ github.ref }}" .
9961
100- - name : Upload files to Artifacts
62+ - name : Upload heybabe binary to Artifacts
10163 uses : actions/upload-artifact@v4
10264 with :
10365 name : heybabe_${{ env.ASSET_NAME }}_${{ env.REF }}
104- path : ./bin/heybabe_${{ env.ASSET_NAME }}
105-
106- release :
107- name : Publish Release
108- if : github.ref == 'refs/heads/main'
109- needs : [version, build]
110- runs-on : ubuntu-latest
111- permissions :
112- contents : write
113- steps :
114- - name : Download all build artifacts
115- uses : actions/download-artifact@v4
116- with :
117- path : ./dist
118- merge-multiple : true
66+ path : ./heybabe_${{ env.ASSET_NAME }}/*
11967
120- - name : Create / Update GitHub Release and upload binaries
121- uses : softprops/action-gh-release@v2
68+ - name : Upload binary to GitHub Release
69+ if : github.event_name == 'release'
70+ uses : svenstaro/upload-release-action@v2
12271 with :
123- tag_name : v${{ needs.version.outputs.version }}
124- name : v${{ needs.version.outputs.version }}
125- draft : false
126- prerelease : false
127- files : |
128- dist/**
129- env :
130- GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
72+ repo_token : ${{ secrets.GITHUB_TOKEN }}
73+ file : ./heybabe_${{ env.ASSET_NAME }}/*
74+ tag : ${{ github.ref }}
75+ file_glob : true
13176
0 commit comments