11name : ci
22
33on :
4- release :
5- types : [created]
64 push :
75 branches :
86 - main
9- pull_request : {}
7+ tags :
8+ - " v[0-9]+.[0-9]+.[0-9]+*"
9+ pull_request :
1010
1111jobs :
1212 lint :
1818 - uses : actions/checkout@v4
1919 - uses : actions/setup-go@v5
2020 with :
21- go-version : ' >=1.21 .0'
21+ go-version : ' >=1.22 .0'
2222 - run : |
2323 if [ "$(gofmt -l . | wc -l)" -gt 0 ]; then
2424 exit 1
@@ -32,39 +32,28 @@ jobs:
3232 - uses : actions/checkout@v4
3333 - uses : actions/setup-go@v5
3434 with :
35- go-version : ' >=1.21 .0'
35+ go-version : ' >=1.22 .0'
3636 - run : go test ./...
3737
38- build_latest :
39- if : github.event_name == 'push' && github. ref == 'refs/heads/main'
38+ create_release :
39+ if : startsWith( github.ref, 'refs/tags/v')
4040 permissions :
4141 contents : write
4242 runs-on : ubuntu-latest
4343 needs : [lint, test]
44- strategy :
45- matrix :
46- goos : [linux, darwin]
47- goarch : ["386", amd64, arm64]
48- exclude :
49- - goarch : " 386"
50- goos : darwin
5144 steps :
5245 - uses : actions/checkout@v4
53- - uses : wangyoucao577/go-release-action@v1
54- with :
55- github_token : ${{ secrets.GITHUB_TOKEN }}
56- goos : ${{ matrix.goos }}
57- goarch : ${{ matrix.goarch }}
58- binary_name : launcher-extras
59- overwrite : true
60- release_tag : latest
61-
46+ - name : build and release
47+ env :
48+ GH_TOKEN : ${{ github.token }}
49+ run : |
50+ gh release create ${{ github.ref_name }}
6251 build_release :
63- if : github.event_name == 'release'
52+ if : startsWith( github.ref, 'refs/tags/v')
6453 permissions :
6554 contents : write
6655 runs-on : ubuntu-latest
67- needs : [lint, test]
56+ needs : [lint, test, create_release ]
6857 strategy :
6958 matrix :
7059 goos : [linux, darwin]
7463 goos : darwin
7564 steps :
7665 - uses : actions/checkout@v4
77- - uses : wangyoucao577/go-release-action@v1
66+ - uses : actions/setup-go@v5
7867 with :
79- github_token : ${{ secrets.GITHUB_TOKEN }}
80- goos : ${{ matrix.goos }}
81- goarch : ${{ matrix.goarch }}
82- binary_name : launcher-extras
68+ go-version : " >=1.22.0"
69+ - name : build and release
70+ working-directory : ./v2
71+ env :
72+ GH_TOKEN : ${{ github.token }}
73+ GOOS : ${{ matrix.goos }}
74+ GOARCH : ${{ matrix.goarch }}
75+ BIN_FILE : launcher-extras
76+ ZIP_FILE : launcher-extras-${{ matrix.goos }}-${{ matrix.goarch }}.tar.gz
77+ run : |
78+ go build -o bin/${BIN_FILE}
79+ cd bin
80+ tar cvfz ${ZIP_FILE} ${BIN_FILE}
81+ MD5_SUM=$(md5sum ${ZIP_FILE} | cut -d ' ' -f 1)
82+ echo ${MD5_SUM} > ${ZIP_FILE}.md5
83+ gh release upload ${{ github.ref_name }} ${ZIP_FILE} ${ZIP_FILE}.md5
0 commit comments