Skip to content

Merge pull request #479 from uselagoon/fix-token #211

Merge pull request #479 from uselagoon/fix-token

Merge pull request #479 from uselagoon/fix-token #211

Workflow file for this run

name: release
on:
push:
branches:
- main
permissions: {}
jobs:
release-tag:
permissions:
# create tag
contents: write
runs-on: ubuntu-latest
outputs:
new-tag: ${{ steps.ccv.outputs.new-tag }}
steps:
- uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0
with:
fetch-depth: 0
- name: Bump tag if necessary
id: ccv
uses: smlx/ccv@d3de774e9b607b079940a7a86952f44643743336 # v0.9.0
release-build:
permissions:
# create release
contents: write
# push docker images to registry
packages: write
# use OIDC token for signing
id-token: write
# required by attest-build-provenance
attestations: write
needs: release-tag
if: needs.release-tag.outputs.new-tag == 'true'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0
with:
fetch-depth: 0
- uses: actions/setup-go@0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32 # v5.0.2
with:
go-version: stable
- name: Login to GHCR
uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567 # v3.3.0
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Set up environment
run: echo "GOVERSION=$(go version)" >> "$GITHUB_ENV"
- uses: advanced-security/sbom-generator-action@375dee8e6144d9fd0ec1f5667b4f6fb4faacefed # v0.0.1
id: sbom
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Move sbom to avoid dirty git
run: mv "$GITHUB_SBOM_PATH" ./sbom.spdx.json
env:
GITHUB_SBOM_PATH: ${{ steps.sbom.outputs.fileName }}
- uses: goreleaser/goreleaser-action@286f3b13b1b49da4ac219696163fb8c1c93e1200 # v6.0.0
id: goreleaser
with:
version: latest
args: release --clean
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_SBOM_PATH: ./sbom.spdx.json
# attest archives
- uses: actions/attest-build-provenance@1c608d11d69870c2092266b3f9a6f3abbf17002c # v1.4.3
with:
subject-path: "dist/*.tar.gz"
# parse artifacts to the format required for image attestation
- run: |
echo "digest=$(echo "$ARTIFACTS" | jq -r '.[]|select(.type=="Docker Manifest")|select(.name|test("ssh-portal:v"))|.extra.Digest')" >> "$GITHUB_OUTPUT"
echo "name=$(echo "$ARTIFACTS" | jq -r '.[]|select(.type=="Docker Manifest")|select(.name|test("ssh-portal:v"))|.name|split(":")[0]')" >> "$GITHUB_OUTPUT"
id: image_metadata_ssh_portal
env:
ARTIFACTS: ${{steps.goreleaser.outputs.artifacts}}
- run: |
echo "digest=$(echo "$ARTIFACTS" | jq -r '.[]|select(.type=="Docker Manifest")|select(.name|test("ssh-portal-api:v"))|.extra.Digest')" >> "$GITHUB_OUTPUT"
echo "name=$(echo "$ARTIFACTS" | jq -r '.[]|select(.type=="Docker Manifest")|select(.name|test("ssh-portal-api:v"))|.name|split(":")[0]')" >> "$GITHUB_OUTPUT"
id: image_metadata_ssh_portal_api
env:
ARTIFACTS: ${{steps.goreleaser.outputs.artifacts}}
- run: |
echo "digest=$(echo "$ARTIFACTS" | jq -r '.[]|select(.type=="Docker Manifest")|select(.name|test("ssh-token:v"))|.extra.Digest')" >> "$GITHUB_OUTPUT"
echo "name=$(echo "$ARTIFACTS" | jq -r '.[]|select(.type=="Docker Manifest")|select(.name|test("ssh-token:v"))|.name|split(":")[0]')" >> "$GITHUB_OUTPUT"
id: image_metadata_ssh_token
env:
ARTIFACTS: ${{steps.goreleaser.outputs.artifacts}}
# attest images
- uses: actions/attest-build-provenance@1c608d11d69870c2092266b3f9a6f3abbf17002c # v1.4.3
with:
subject-digest: ${{steps.image_metadata_ssh_portal.outputs.digest}}
subject-name: ${{steps.image_metadata_ssh_portal.outputs.name}}
push-to-registry: true
- uses: actions/attest-build-provenance@1c608d11d69870c2092266b3f9a6f3abbf17002c # v1.4.3
with:
subject-digest: ${{steps.image_metadata_ssh_portal_api.outputs.digest}}
subject-name: ${{steps.image_metadata_ssh_portal_api.outputs.name}}
push-to-registry: true
- uses: actions/attest-build-provenance@1c608d11d69870c2092266b3f9a6f3abbf17002c # v1.4.3
with:
subject-digest: ${{steps.image_metadata_ssh_token.outputs.digest}}
subject-name: ${{steps.image_metadata_ssh_token.outputs.name}}
push-to-registry: true