1- name : Build & Release
1+ name : Release
22
33on :
44 push :
@@ -15,103 +15,28 @@ permissions:
1515 contents : write
1616
1717jobs :
18- build :
19- name : Build ${{ matrix.os }}/${{ matrix.arch }}
18+ release :
19+ name : GoReleaser
2020 runs-on : ubuntu-latest
21- strategy :
22- matrix :
23- include :
24- # Linux
25- - { goos: linux, goarch: amd64, os: linux, arch: amd64, ext: "" }
26- - { goos: linux, goarch: arm64, os: linux, arch: arm64, ext: "" }
27- - { goos: linux, goarch: "386", os: linux, arch: "386", ext: "" }
28- - { goos: linux, goarch: arm, os: linux, arch: armv7, ext: "", goarm: "7" }
29- # macOS
30- - { goos: darwin, goarch: amd64, os: darwin, arch: amd64, ext: "" }
31- - { goos: darwin, goarch: arm64, os: darwin, arch: arm64, ext: "" }
32- # Windows
33- - { goos: windows, goarch: amd64, os: windows, arch: amd64, ext: ".exe" }
34- - { goos: windows, goarch: arm64, os: windows, arch: arm64, ext: ".exe" }
35- - { goos: windows, goarch: "386", os: windows, arch: "386", ext: ".exe" }
36-
3721 steps :
3822 - uses : actions/checkout@v4
23+ with :
24+ fetch-depth : 0
3925
4026 - name : Set up Go
4127 uses : actions/setup-go@v5
4228 with :
43- go-version : " 1.21"
44-
45- - name : Resolve version tag
46- id : version
47- run : |
48- if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
49- echo "tag=${{ inputs.tag }}" >> "$GITHUB_OUTPUT"
50- else
51- echo "tag=${GITHUB_REF#refs/tags/}" >> "$GITHUB_OUTPUT"
52- fi
29+ go-version : " 1.25"
5330
54- - name : Build binary
55- env :
56- GOOS : ${{ matrix.goos }}
57- GOARCH : ${{ matrix.goarch }}
58- GOARM : ${{ matrix.goarm }}
59- CGO_ENABLED : " 0"
31+ - name : Create tag for workflow_dispatch
32+ if : github.event_name == 'workflow_dispatch'
6033 run : |
61- VERSION="${{ steps.version.outputs.tag }}"
62- COMMIT="${{ github.sha }}"
63- BUILD_TIME="$(date -u +%Y-%m-%dT%H:%M:%SZ)"
64- LDFLAGS="-s -w -X shield-cli/cmd.Version=${VERSION} -X shield-cli/cmd.GitCommit=${COMMIT} -X shield-cli/cmd.BuildTime=${BUILD_TIME}"
65-
66- BINARY_NAME="shield-${{ matrix.os }}-${{ matrix.arch }}${{ matrix.ext }}"
67- go build -trimpath -ldflags "${LDFLAGS}" -o "${BINARY_NAME}" .
68-
69- # Create archive
70- if [ "${{ matrix.goos }}" = "windows" ]; then
71- zip "${BINARY_NAME%.exe}.zip" "${BINARY_NAME}"
72- else
73- tar czf "${BINARY_NAME}.tar.gz" "${BINARY_NAME}"
74- fi
34+ git tag ${{ inputs.tag }}
7535
76- - name : Upload artifact
77- uses : actions/upload-artifact@v4
36+ - name : Run GoReleaser
37+ uses : goreleaser/goreleaser-action@v6
7838 with :
79- name : shield-${{ matrix.os }}-${{ matrix.arch }}
80- path : |
81- shield-*.tar.gz
82- shield-*.zip
83-
84- release :
85- name : Create Release
86- needs : build
87- runs-on : ubuntu-latest
88- steps :
89- - name : Download all artifacts
90- uses : actions/download-artifact@v4
91- with :
92- path : dist
93- merge-multiple : true
94-
95- - name : Resolve version tag
96- id : version
97- run : |
98- if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
99- echo "tag=${{ inputs.tag }}" >> "$GITHUB_OUTPUT"
100- else
101- echo "tag=${GITHUB_REF#refs/tags/}" >> "$GITHUB_OUTPUT"
102- fi
103-
104- - name : Generate checksums
105- working-directory : dist
106- run : sha256sum shield-* > checksums.txt
107-
108- - name : Create GitHub Release
109- uses : softprops/action-gh-release@v2
110- with :
111- tag_name : ${{ steps.version.outputs.tag }}
112- name : Shield CLI ${{ steps.version.outputs.tag }}
113- generate_release_notes : true
114- files : |
115- dist/shield-*.tar.gz
116- dist/shield-*.zip
117- dist/checksums.txt
39+ version : latest
40+ args : release --clean
41+ env :
42+ GITHUB_TOKEN : ${{ secrets.HOMEBREW_TAP_TOKEN }}
0 commit comments