diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 1d471d8..3834a09 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -19,6 +19,7 @@ jobs: go-version: stable - run: echo "GOVERSION=$(go version)" >> "$GITHUB_ENV" - uses: goreleaser/goreleaser-action@5742e2a039330cbb23ebf35f046f814d4c6ff811 # v5.1.0 + id: goreleaser with: version: latest args: build --clean --debug --single-target --snapshot @@ -46,3 +47,21 @@ jobs: file: Dockerfile build-args: BINARY=lagoon-opensearch-sync context: dist/lagoon-opensearch-sync_linux_amd64_v1 + check-tag: + permissions: + contents: read + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4 + with: + fetch-depth: 0 + - id: ccv + uses: smlx/ccv@c5f6769c943c082c4e8d8ccf2ec4b6f5f517e1f2 # v0.7.3 + with: + write-tag: false + - run: | + echo "new-tag=$NEW_TAG" + echo "new-tag-version=$NEW_TAG_VERSION" + env: + NEW_TAG: ${{steps.ccv.outputs.new-tag}} + NEW_TAG_VERSION: ${{steps.ccv.outputs.new-tag-version}} diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index a4c1878..4db6dc2 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -11,59 +11,42 @@ jobs: contents: write runs-on: ubuntu-latest outputs: - new-tag: ${{ steps.bump-tag.outputs.new }} - new-tag-version: ${{ steps.bump-tag.outputs.new_tag_version }} + new-tag: ${{ steps.ccv.outputs.new-tag }} steps: - - uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6 + - uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4 with: fetch-depth: 0 - - name: Configure git - run: | - git config --global user.name "$GITHUB_ACTOR" - git config --global user.email "$GITHUB_ACTOR@users.noreply.github.com" - - uses: actions/setup-go@cdcb36043654635271a94b9a6d1392de5bb323a7 # v5.0.1 - with: - go-version: stable - - name: Install ccv - run: > - curl -sSL https://github.com/smlx/ccv/releases/download/v0.3.2/ccv_0.3.2_linux_amd64.tar.gz - | sudo tar -xz -C /usr/local/bin ccv - name: Bump tag if necessary - id: bump-tag - run: | - if [ -z "$(git tag -l "$(ccv)")" ]; then - git tag "$(ccv)" - git push --tags - echo "new=true" >> "$GITHUB_OUTPUT" - echo "new_tag_version=$(git tag --points-at HEAD)" >> "$GITHUB_OUTPUT" - fi + id: ccv + uses: smlx/ccv@c5f6769c943c082c4e8d8ccf2ec4b6f5f517e1f2 # v0.7.3 release-build: permissions: # create release contents: write - # push docker images to regsitry + # 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@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6 + - uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4 with: fetch-depth: 0 - - uses: actions/setup-go@cdcb36043654635271a94b9a6d1392de5bb323a7 # v5.0.1 + - uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # v5.0.0 with: go-version: stable - name: Login to GHCR - uses: docker/login-action@0d4c9c5ea7693da7b068278f7b52bda2a190a446 # v3.2.0 + uses: docker/login-action@e92390c5fb421da1463c202d546fed0ec5c39f20 # v3.1.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: sigstore/cosign-installer@59acb6260d9c0ba8f4a2f9d9b48431a222b68e20 # v3.5.0 - uses: advanced-security/sbom-generator-action@375dee8e6144d9fd0ec1f5667b4f6fb4faacefed # v0.0.1 id: sbom env: @@ -72,10 +55,28 @@ jobs: run: mv "$GITHUB_SBOM_PATH" ./sbom.spdx.json env: GITHUB_SBOM_PATH: ${{ steps.sbom.outputs.fileName }} - - uses: goreleaser/goreleaser-action@5742e2a039330cbb23ebf35f046f814d4c6ff811 # v5.1.0 + - uses: goreleaser/goreleaser-action@7ec5c2b0c6cdda6e8bbb49444bc797dd33d74dd8 # v5.0.0 + id: goreleaser with: version: latest args: release --clean env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} GITHUB_SBOM_PATH: ./sbom.spdx.json + # parse artifacts to the format required for image attestation + - run: | + echo "digest=$(echo "$ARTIFACTS" | jq -r '.[]|select(.type=="Docker Manifest")|select(.name|test(":v"))|.extra.Digest')" >> "$GITHUB_OUTPUT" + echo "name=$(echo "$ARTIFACTS" | jq -r '.[]|select(.type=="Docker Manifest")|select(.name|test(":v"))|.name|split(":")[0]')" >> "$GITHUB_OUTPUT" + id: image_metadata + env: + ARTIFACTS: ${{steps.goreleaser.outputs.artifacts}} + # attest archives + - uses: actions/attest-build-provenance@173725a1209d09b31f9d30a3890cf2757ebbff0d # v1.1.2 + with: + subject-path: "dist/*.tar.gz" + # attest images + - uses: actions/attest-build-provenance@173725a1209d09b31f9d30a3890cf2757ebbff0d # v1.1.2 + with: + subject-digest: ${{steps.image_metadata.outputs.digest}} + subject-name: ${{steps.image_metadata.outputs.name}} + push-to-registry: true diff --git a/.goreleaser.yaml b/.goreleaser.yaml index f797cce..54192e2 100644 --- a/.goreleaser.yaml +++ b/.goreleaser.yaml @@ -22,18 +22,6 @@ builds: changelog: use: github-native -signs: -- cmd: cosign - signature: "${artifact}.sig" - certificate: "${artifact}.pem" - args: - - "sign-blob" - - "--output-signature=${signature}" - - "--output-certificate=${certificate}" - - "${artifact}" - - "--yes" - artifacts: checksum - dockers: - ids: - lagoon-opensearch-sync @@ -63,14 +51,6 @@ docker_manifests: - "ghcr.io/{{ .Env.GITHUB_REPOSITORY }}:v{{ .Version }}-amd64" - "ghcr.io/{{ .Env.GITHUB_REPOSITORY }}:v{{ .Version }}-arm64v8" -docker_signs: -- args: - - "sign" - - "${artifact}@${digest}" - - "--yes" - artifacts: all - output: true - release: extra_files: - glob: "{{ .Env.GITHUB_SBOM_PATH }}"