ci(release): modify sbom artifact name #17
Workflow file for this run
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
name: releaser | |
on: | |
push: | |
tags: | |
- 'v*.*.*' | |
permissions: | |
contents: read | |
jobs: | |
releaser: | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: ncipollo/release-action@v1 | |
with: | |
generateReleaseNotes: true | |
- uses: anchore/sbom-action@v0 | |
build-and-publish-oci: | |
runs-on: ubuntu-latest | |
permissions: | |
contents: read | |
packages: write | |
steps: | |
- name: Checkout Repository | |
uses: actions/checkout@v2 | |
- name: Set up Go | |
uses: actions/setup-go@v2 | |
with: | |
go-version: '1.21' | |
- name: Convert Repository Name to Lowercase | |
id: lowercase | |
run: echo "::set-output name=name::$(echo ${{ github.repository }} | tr '[:upper:]' '[:lower:]')" | |
- name: Extract Version | |
id: tagger | |
uses: battila7/get-version-action@v2 | |
- name: Print Version | |
run: | | |
echo ${{steps.tagger.outputs.version}} | |
echo ${{steps.tagger.outputs.version-without-v}} | |
- name: Install Cosign | |
uses: sigstore/[email protected] | |
with: | |
cosign-release: 'v2.2.2' | |
- name: Build the OCI Image | |
run: docker build -t ghcr.io/${{ steps.lowercase.outputs.name }}:${{ steps.tagger.outputs.version-without-v }} . | |
working-directory: . | |
- name: Login to GitHub Packages | |
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin | |
- name: Push the OCI Image | |
run: docker push ghcr.io/${{ steps.lowercase.outputs.name }}:${{ steps.tagger.outputs.version-without-v }} | |
- name: Produce Image SBOM | |
uses: anchore/sbom-action@v0 | |
with: | |
image: ghcr.io/${{ steps.lowercase.outputs.name }}:${{ steps.tagger.outputs.version-without-v }} | |
artifact-name: ${{ steps.lowercase.outputs.name }}.spdx.json | |
- name: Sign image with Cosign | |
run: | | |
cosign sign --yes --key env://COSIGN_PRIVATE_KEY "ghcr.io/${{ steps.lowercase.outputs.name }}:${{ steps.tagger.outputs.version-without-v }}" | |
env: | |
COSIGN_PRIVATE_KEY: ${{ secrets.COSIGN_PRIVATE_KEY }} | |
COSIGN_PASSWORD: ${{ secrets.COSIGN_PASSWORD }} | |
- name: Attest the Image with SBOM | |
run: | | |
ls -lah /tmp | |
SBOM_FILE=$(find /tmp/sbom-action-* -name "*${{ steps.lowercase.outputs.name }}-${{ steps.tagger.outputs.version-without-v }}.spdx.json*.spdx.json" -type f) | |
echo "${SBOM_FILE}" | |
if [ -z "$SBOM_FILE" ]; then | |
echo "Error: .spdx file not found" | |
exit 1 | |
fi | |
cosign attest --yes --key env://COSIGN_PRIVATE_KEY --type spdx --predicate "${SBOM_FILE}" "ghcr.io/${{ steps.lowercase.outputs.name }}:${{ steps.tagger.outputs.version-without-v }}" | |
env: | |
COSIGN_PRIVATE_KEY: ${{ secrets.COSIGN_PRIVATE_KEY }} | |
COSIGN_PASSWORD: ${{ secrets.COSIGN_PASSWORD }} |