Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: add slsa provenance to release assets #5178

Merged
merged 1 commit into from
Aug 12, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
100 changes: 96 additions & 4 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,21 +33,55 @@ jobs:
GOOS: ${{ matrix.os }}
GOARCH: ${{ matrix.arch }}
run: make release-${{ matrix.target }}
- name: Making helm charts
env:
VERSION: ${{ github.ref_name }}
run: make package-chart
- name: upload cli
uses: actions/upload-artifact@v4
with:
name: cli-${{ matrix.target }}-${{ matrix.os }}-${{ matrix.arch }}.tgz
path: _output/release/${{ matrix.target }}-${{ matrix.os }}-${{ matrix.arch }}.tgz
- name: Uploading assets...
if: ${{ !env.ACT }}
uses: softprops/action-gh-release@v2
with:
files: |
_output/release/${{ matrix.target }}-${{ matrix.os }}-${{ matrix.arch }}.tgz
_output/release/${{ matrix.target }}-${{ matrix.os }}-${{ matrix.arch }}.tgz.sha256
generate-subject-for-cli-provenance:
needs: [release-assests]
runs-on: ubuntu-22.04
outputs:
hashes: ${{ steps.hash.outputs.hashes }}
steps:
- name: download cli
uses: actions/download-artifact@v4
with:
path: _output/release
pattern: cli-*
merge-multiple: true
- name: generate cli hash
id: hash
run: |
cd _output/release
# sha256sum generates sha256 hash for cli.
# base64 -w0 encodes to base64 and outputs on a single line.
echo "hashes=$(sha256sum *.tgz|base64 -w0)" >> "$GITHUB_OUTPUT"
zhzhuang-zju marked this conversation as resolved.
Show resolved Hide resolved
cli-provenance:
needs: [generate-subject-for-cli-provenance]
permissions:
actions: read # for detecting the Github Actions environment
id-token: write # Needed for provenance signing and ID
contents: write # Needed for release uploads
# Must be referenced by a tag. https://github.com/slsa-framework/slsa-github-generator/blob/main/internal/builders/container/README.md#referencing-the-slsa-generator
uses: slsa-framework/slsa-github-generator/.github/workflows/generator_generic_slsa3.yml@v2.0.0
with:
base64-subjects: "${{ needs.generate-subject-for-cli-provenance.outputs.hashes }}"
provenance-name: "karmada-cli.intoto.jsonl"
upload-assets: true
release-crds-assests:
permissions:
contents: write # for softprops/action-gh-release to create GitHub release
name: release crds
outputs:
hashes: ${{ steps.hash.outputs.hashes }}
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
Expand All @@ -61,15 +95,35 @@ jobs:
cwd: ./charts/karmada/
files: crds
outPath: crds.tar.gz
- name: generate crds hash
id: hash
run: |
# sha256sum generates sha256 hash for crds.
# base64 -w0 encodes to base64 and outputs on a single line.
echo "hashes=$(sha256sum crds.tar.gz | base64 -w0)" >> "$GITHUB_OUTPUT"
- name: Uploading crd assets...
uses: softprops/action-gh-release@v2
with:
files: |
crds.tar.gz
crds-provenance:
needs: [release-crds-assests]
permissions:
actions: read # for detecting the Github Actions environment
id-token: write # Needed for provenance signing and ID
contents: write # Needed for release uploads
# Must be referenced by a tag. https://github.com/slsa-framework/slsa-github-generator/blob/main/internal/builders/container/README.md#referencing-the-slsa-generator
uses: slsa-framework/slsa-github-generator/.github/workflows/generator_generic_slsa3.yml@v2.0.0
with:
base64-subjects: "${{ needs.release-crds-assests.outputs.hashes }}"
provenance-name: "karmada-crds.intoto.jsonl"
upload-assets: true
release-charts:
permissions:
contents: write # for softprops/action-gh-release to create GitHub release
name: Release charts
outputs:
hashes: ${{ steps.hash.outputs.hashes }}
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
Expand All @@ -86,10 +140,29 @@ jobs:
_output/charts/karmada-chart-${{ github.ref_name }}.tgz.sha256
_output/charts/karmada-operator-chart-${{ github.ref_name }}.tgz
_output/charts/karmada-operator-chart-${{ github.ref_name }}.tgz.sha256
- name: generate charts hash
id: hash
run: |
cd _output/charts
echo "hashes=$(sha256sum *.tgz|base64 -w0)" >> "$GITHUB_OUTPUT"
charts-provenance:
needs: [release-charts]
permissions:
actions: read # for detecting the Github Actions environment
id-token: write # Needed for provenance signing and ID
contents: write # Needed for release uploads
# Must be referenced by a tag. https://github.com/slsa-framework/slsa-github-generator/blob/main/internal/builders/container/README.md#referencing-the-slsa-generator
uses: slsa-framework/slsa-github-generator/.github/workflows/generator_generic_slsa3.yml@v2.0.0
with:
base64-subjects: "${{ needs.release-charts.outputs.hashes }}"
provenance-name: "karmada-charts.intoto.jsonl"
upload-assets: true
sbom-assests:
permissions:
contents: write # for softprops/action-gh-release to create GitHub release
name: Release sbom
outputs:
hashes: ${{ steps.sbom-hash.outputs.hashes}}
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
Expand All @@ -103,11 +176,30 @@ jobs:
- name: Tar the sbom files
run: |
tar -zcf sbom.tar.gz *.spdx
- name: Generate SBOM hash
shell: bash
id: sbom-hash
run: |
# sha256sum generates sha256 hash for sbom.
# base64 -w0 encodes to base64 and outputs on a single line.
echo "hashes=$(sha256sum sbom.tar.gz | base64 -w0)" >> "$GITHUB_OUTPUT"
- name: Uploading sbom assets...
uses: softprops/action-gh-release@v2
with:
files: |
sbom.tar.gz
sbom-provenance:
needs: [sbom-assests]
permissions:
actions: read # for detecting the Github Actions environment
id-token: write # Needed for provenance signing and ID
contents: write # Needed for release uploads
# Must be referenced by a tag. https://github.com/slsa-framework/slsa-github-generator/blob/main/internal/builders/container/README.md#referencing-the-slsa-generator
uses: slsa-framework/slsa-github-generator/.github/workflows/generator_generic_slsa3.yml@v2.0.0
with:
base64-subjects: "${{ needs.sbom-assests.outputs.hashes }}"
provenance-name: "karmada-sbom.intoto.jsonl"
upload-assets: true
update-krew-index:
needs: release-assests
name: Update krew-index
Expand Down
Loading