-
-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1448 from aquaproj/ci/slsa-provenance
ci: release SLSA Provenance
- Loading branch information
Showing
4 changed files
with
84 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
--- | ||
name: Release | ||
on: | ||
push: | ||
tags: [v*] | ||
permissions: | ||
contents: write # required to create a release | ||
id-token: write # required for cosign | ||
env: | ||
AQUA_POLICY_CONFIG: ${{ github.workspace }}/aqua-policy.yaml | ||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
outputs: | ||
hashes: ${{ steps.hash.outputs.hashes }} | ||
steps: | ||
- uses: actions/checkout@755da8c3cf115ac066823e79a1e1788f8940201b # v3.2.0 | ||
- uses: actions/setup-go@6edd4406fa81c3da01a34fa6f6343087c207a568 # v3.5.0 | ||
with: | ||
go-version: '1.19.3' | ||
cache: true | ||
|
||
- name: Generate token | ||
id: generate_token | ||
if: startsWith(github.ref, 'refs/tags/') | ||
uses: tibdex/github-app-token@021a2405c7f990db57f5eae5397423dcc554159c # tag=v1.7.0 | ||
with: | ||
app_id: ${{ secrets.APP_ID }} | ||
private_key: ${{ secrets.APP_PRIVATE_KEY }} | ||
|
||
- name: remove changes | ||
# Sometimes it is failed to release by goreleaser due to changes of go.sum | ||
run: git checkout -- . | ||
- name: fetch tags to release | ||
run: git fetch --tags -f | ||
- name: Unshallow | ||
run: git fetch --prune --unshallow | ||
- name: Run GoReleaser | ||
uses: goreleaser/goreleaser-action@8f67e590f2d095516493f017008adc464e63adb1 # v4.1.0 | ||
if: startsWith(github.ref, 'refs/tags/') | ||
with: | ||
version: latest | ||
args: release --rm-dist | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
HOMEBREW_TAP_GITHUB_TOKEN: ${{ steps.generate_token.outputs.token }} | ||
|
||
- name: Generate hashes | ||
id: hash | ||
run: | | ||
# sha256sum generates sha256 hash for all artifacts. | ||
# base64 -w0 encodes to base64 and outputs on a single line. | ||
# sha256sum artifact1 artifact2 ... | base64 -w0 | ||
echo "hashes=$(find dist -name "*.tar.gz" -print0 | xargs -0 sha256sum | base64 -w0)" >> "$GITHUB_OUTPUT" | ||
provenance: | ||
needs: [build] | ||
permissions: | ||
actions: read # Needed for detection of GitHub Actions environment. | ||
id-token: write # Needed for provenance signing and ID | ||
contents: write # Needed for release uploads | ||
uses: slsa-framework/slsa-github-generator/.github/workflows/generator_generic_slsa3.yml@v1.4.0 | ||
with: | ||
base64-subjects: "${{ needs.build.outputs.hashes }}" | ||
# Upload provenance to a new release | ||
upload-assets: false | ||
|
||
release: | ||
needs: [provenance] | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Download the provenance | ||
uses: actions/download-artifact@v3 | ||
with: | ||
name: ${{ needs.provenance.outputs.provenance-name }} | ||
|
||
- name: Upload provenance | ||
run: gh release upload -R aquaproj/aqua "${REF#refs/tags/}" multiple.intoto.jsonl | ||
env: | ||
REF: ${{ github.ref }} | ||
GITHUB_TOKEN: ${{ github.token }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters