1515
1616permissions :
1717 contents : write # needed to write releases
18+ id-token : write # needed for keyless signing
1819
1920jobs :
2021
21- github_release :
22- runs-on : ubuntu-latest
23- outputs :
24- release_upload_url : ${{ steps.create_release.outputs.upload_url }}
25- steps :
26- - name : Prepare
27- id : prep
28- run : |
29- VERSION="${{ github.event.inputs.tag }}-${GITHUB_SHA::8}"
30- if [[ $GITHUB_REF == refs/tags/* ]]; then
31- VERSION=${GITHUB_REF/refs\/tags\//}
32- fi
33- echo ::set-output name=VERSION::${VERSION}
34- - name : Create Release
35- id : create_release
36- uses : actions/create-release@v1
37- env :
38- GITHUB_TOKEN : ${{ github.token }}
39- with :
40- release_name : ${{ steps.prep.outputs.VERSION }}
41- tag_name : ${{ steps.prep.outputs.VERSION }}
42- draft : false
43- prerelease : true
44-
4522 linux-amd64-release :
4623 runs-on : ubuntu-latest
47- needs : github_release
4824 steps :
4925 - name : Checkout
5026 uses : actions/checkout@v2
6238
6339 tar -zcvf linux-x86_64-libgit2-all-libs.tar.gz libgit2-linux-libgit2-all
6440 rm -rf ${GITHUB_WORKSPACE}/build ${GITHUB_WORKSPACE}/libgit2
65- - name : Upload Release Asset
66- id : upload-release-asset-libgit2-all
67- uses : actions/upload-release-asset@v1
68- env :
69- GITHUB_TOKEN : ${{ github.token }}
70- with :
71- upload_url : ${{ needs.github_release.outputs.release_upload_url }}
72- asset_path : ./linux-x86_64-libgit2-all-libs.tar.gz
73- asset_name : linux-x86_64-libgit2-all-libs.tar.gz
74- asset_content_type : application/gzip
7541
7642 - name : Build static libraries - libgit2 only
7743 run : |
@@ -85,16 +51,11 @@ jobs:
8551
8652 tar -zcvf linux-x86_64-libgit2-only-lib.tar.gz libgit2-linux-libgit2-only
8753 rm -rf ${GITHUB_WORKSPACE}/build ${GITHUB_WORKSPACE}/libgit2
88- - name : Upload Release Asset
89- id : upload-release-asset-libgit2-only
90- uses : actions/upload-release-asset@v1
91- env :
92- GITHUB_TOKEN : ${{ github.token }}
54+ - uses : actions/upload-artifact@v3
9355 with :
94- upload_url : ${{ needs.github_release.outputs.release_upload_url }}
95- asset_path : ./linux-x86_64-libgit2-only-lib.tar.gz
96- asset_name : linux-x86_64-libgit2-only-lib.tar.gz
97- asset_content_type : application/gzip
56+ name : release-artifact
57+ path : ' *.tar.gz'
58+ if-no-files-found : error
9859
9960 darwin-release :
10061 # This job builds and releases "universal libraries" that are
10869 # of testing, GitHub's macos-10.15 did not seem to.
10970 # Cross-compiling to arm64 on that runner consistently failed.
11071 runs-on : macos-11
111- needs : github_release
11272 steps :
11373 - name : Checkout
11474 uses : actions/checkout@v2
@@ -156,16 +116,6 @@ jobs:
156116 rm -rf ${GITHUB_WORKSPACE}/build ${GITHUB_WORKSPACE}/libgit2
157117 env :
158118 MACOSX_DEPLOYMENT_TARGET : 10.15
159- - name : Upload Release Asset
160- id : upload-release-asset-libgit2-all
161- uses : actions/upload-release-asset@v1
162- env :
163- GITHUB_TOKEN : ${{ github.token }}
164- with :
165- upload_url : ${{ needs.github_release.outputs.release_upload_url }}
166- asset_path : ./darwin-libgit2-all-libs.tar.gz
167- asset_name : darwin-libgit2-all-libs.tar.gz
168- asset_content_type : application/gzip
169119
170120 - name : Build universal static libraries for Darwin - libgit2 only
171121 run : |
@@ -179,9 +129,8 @@ jobs:
179129 CMAKE_APPLE_SILICON_PROCESSOR=arm64 \
180130 ./hack/static.sh build_libgit2_only
181131
182- mkdir -p ./libgit2-darwin-libgit2-only
132+ mkdir -p ./libgit2-darwin-libgit2-only/lib
183133 mv ${GITHUB_WORKSPACE}/build/libgit2-darwin-amd64/include ./libgit2-darwin-libgit2-only/
184- mv ${GITHUB_WORKSPACE}/build/libgit2-darwin-amd64/lib ./libgit2-darwin-libgit2-only/
185134
186135 libtool -static -o ./libgit2-darwin-libgit2-only/lib/libgit2.a \
187136 ${GITHUB_WORKSPACE}/build/libgit2-darwin-amd64/lib/libgit2.a \
@@ -191,13 +140,34 @@ jobs:
191140 rm -rf ${GITHUB_WORKSPACE}/build ${GITHUB_WORKSPACE}/libgit2
192141 env :
193142 MACOSX_DEPLOYMENT_TARGET : 10.15
194- - name : Upload Release Asset
195- id : upload-release-asset-libgit2-only
196- uses : actions/upload-release-asset@v1
197- env :
198- GITHUB_TOKEN : ${{ github.token }}
143+ - uses : actions/upload-artifact@v3
144+ with :
145+ name : release-artifact
146+ path : ' *.tar.gz'
147+ if-no-files-found : error
148+
149+ goreleaser :
150+ runs-on : ubuntu-latest
151+ needs : [linux-amd64-release, darwin-release]
152+ if : ${{ always() && contains(join(needs.*.result, ','), 'success') }}
153+ steps :
154+ - uses : actions/checkout@v2
155+ with :
156+ fetch-depth : 0
157+ - uses : actions/setup-go@v2
158+ with :
159+ go-version : 1.17.x
160+ - name : Setup Cosign
161+ uses : sigstore/cosign-installer@main
162+ - name : Setup Syft
163+ uses : anchore/sbom-action/download-syft@v0
164+ - name : Download Files
165+ uses : actions/download-artifact@v3
199166 with :
200- upload_url : ${{ needs.github_release.outputs.release_upload_url }}
201- asset_path : ./darwin-libs-libgit2-only.tar.gz
202- asset_name : darwin-libs-libgit2-only.tar.gz
203- asset_content_type : application/gzip
167+ name : release-artifact
168+ - uses : goreleaser/goreleaser-action@v2
169+ with :
170+ version : latest
171+ args : release --rm-dist
172+ env :
173+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
0 commit comments