@@ -2,7 +2,7 @@ name: release
22
33on :
44 push :
5- tags : ['v*' ]
5+ tags : ["v*.*.*" ]
66
77jobs :
88 get-tag :
@@ -14,27 +14,39 @@ jobs:
1414 - id : vars
1515 run : echo ::set-output name=tag::${GITHUB_REF#refs/*/}
1616 build :
17+ env :
18+ BIN_NAME : ${{ needs.get-tag.outputs.tag }}.${{ matrix.platform.goos }}-${{ matrix.platform.goarch }}
1719 needs : [get-tag]
1820 runs-on : ubuntu-latest
1921 strategy :
2022 matrix :
2123 platform :
22- - {goos: darwin, goarch: amd64}
23- - {goos: linux, goarch: amd64}
24- - {goos: windows, goarch: amd64}
24+ - { goos: darwin, goarch: amd64 }
25+ - { goos: linux, goarch: amd64 }
26+ - { goos: windows, goarch: amd64 }
2527 steps :
2628 - name : Checkout
2729 uses : actions/checkout@v2
2830 - name : Setup go
2931 uses : actions/setup-go@v1
3032 with :
3133 go-version : ^1.0
32- - run : CGO_ENABLED=0 GOOS=${{ matrix.platform.goos }} GOARCH=${{ matrix.platform.goarch }} go build -ldflags "-s -w" -o gcppromd-${{ needs.get-tag.outputs.tag }}.${{ matrix.platform.goos }}-${{ matrix.platform.goarch }} ./cmd/gcppromd
34+ - name : Set binary name
35+ id : binary_name
36+ run : |
37+ echo "BIN_NAME=gcppromd-${{ needs.get-tag.outputs.tag }}.${{ matrix.platform.goos }}-${{ matrix.platform.goarch }}" >> $GITHUB_ENV
38+ - run : >-
39+ CGO_ENABLED=0 GOOS=${{ matrix.platform.goos }}
40+ GOARCH=${{ matrix.platform.goarch }}
41+ go build -ldflags "-s -w" -o ${{ env.BIN_NAME }} ./cmd/gcppromd &&
42+ shasum -a 256 ${{ env.BIN_NAME }} > ${{ env.BIN_NAME }}.sha256
3343 - name : Upload binary
3444 uses : actions/upload-artifact@v2
3545 with :
36- name : binary.${{ matrix.platform.goos }}-${{ matrix.platform.goarch }}
37- path : gcppromd-${{ needs.get-tag.outputs.tag }}.${{ matrix.platform.goos }}-${{ matrix.platform.goarch }}
46+ name : binary.${{ env.BIN_NAME }}
47+ path : |
48+ ${{ env.BIN_NAME }}
49+ ${{ env.BIN_NAME }}.sha256
3850 if-no-files-found : error
3951 release :
4052 needs : [get-tag, build]
@@ -45,12 +57,18 @@ jobs:
4557 - uses : actions/download-artifact@v2
4658 with :
4759 path : .
60+ # git fetch --tags --force is required because GitHub checkout action doesn't seems to preserve the tag annotation.
61+ - name : Retrive release message
62+ run : |
63+ echo 'RELEASE_MSG<<EOF' >> $GITHUB_ENV
64+ git fetch --tags --force && git tag -l --format='%(contents)' ${{ needs.get-tag.outputs.tag }} >> $GITHUB_ENV
65+ echo 'EOF' >> $GITHUB_ENV
4866 - name : Release
4967 uses : softprops/action-gh-release@v1
5068 with :
5169 draft : true
52- body_path : CHANGELOGS/ ${{ needs.get-tag.outputs.tag }}.md
70+ body : ${{ env.RELEASE_MSG }}
5371 files : |
5472 binary.*/*
5573 env :
56- GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
74+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
0 commit comments