Merge pull request #321 from stefanprodan/immutable-cfg-gen #40
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: release | |
on: | |
push: | |
tags: [ 'v*' ] | |
permissions: | |
contents: read | |
jobs: | |
goreleaser: | |
outputs: | |
hashes: ${{ steps.hash.outputs.hashes }} | |
version: ${{ steps.hash.outputs.version }} | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write | |
id-token: write | |
packages: write | |
steps: | |
- name: Checkout | |
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 | |
- name: Unshallow | |
run: git fetch --prune --unshallow | |
- name: Setup Go | |
uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # v5.0.0 | |
with: | |
go-version: 1.21.x | |
cache-dependency-path: | | |
**/go.sum | |
**/go.mod | |
- name: Setup Syft | |
uses: anchore/sbom-action/download-syft@c7f031d9249a826a082ea14c79d3b686a51d485a # v0.15.3 | |
- name: Run GoReleaser | |
id: run-goreleaser | |
uses: goreleaser/goreleaser-action@7ec5c2b0c6cdda6e8bbb49444bc797dd33d74dd8 # v5.0.0 | |
with: | |
version: latest | |
args: release --skip-validate | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
HOMEBREW_TAP_GITHUB_TOKEN: ${{ secrets.HOMEBREW_GITHUB_TOKEN }} | |
- name: Generate SLSA subject | |
id: hash | |
env: | |
ARTIFACTS: "${{ steps.run-goreleaser.outputs.artifacts }}" | |
run: | | |
set -euo pipefail | |
hashes=$(echo $ARTIFACTS | jq --raw-output '.[] | {name, "digest": (.extra.Digest // .extra.Checksum)} | select(.digest) | {digest} + {name} | join(" ") | sub("^sha256:";"")' | base64 -w0) | |
if test "$hashes" = ""; then # goreleaser < v1.13.0 | |
checksum_file=$(echo "$ARTIFACTS" | jq -r '.[] | select (.type=="Checksum") | .path') | |
hashes=$(cat $checksum_file | base64 -w0) | |
fi | |
echo "hashes=$hashes" >> $GITHUB_OUTPUT | |
echo "version=${GITHUB_REF_NAME#v}" >> $GITHUB_OUTPUT | |
publish-artifacts: | |
needs: [goreleaser] | |
runs-on: ubuntu-latest | |
permissions: | |
contents: read | |
id-token: write | |
packages: write | |
steps: | |
- name: Checkout | |
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 | |
- name: Setup Cosign | |
uses: sigstore/cosign-installer@9614fae9e5c5eddabb09f90a270fcb487c9f7149 # v3.3.0 | |
- name: Setup Timoni | |
uses: ./actions/setup | |
- name: Login to GHCR | |
uses: docker/login-action@343f7c4344506bcbf9b4de18042ae17996df046d # v3.0.0 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Version info | |
id: info | |
run: | | |
VERSION=$(timoni -v | awk '{ print $NF }') | |
echo "version=${VERSION}" >> $GITHUB_OUTPUT | |
- name: Push minimal module | |
run: | | |
timoni mod push ./examples/minimal oci://ghcr.io/stefanprodan/timoni/minimal \ | |
-v ${{ steps.info.outputs.version }} --latest \ | |
-a 'org.opencontainers.image.licenses=Apache-2.0' \ | |
-a 'org.opencontainers.image.source=https://github.com/stefanprodan/timoni' \ | |
-a 'org.opencontainers.image.description=A minimal timoni.sh module.' \ | |
-a 'org.opencontainers.image.documentation=https://timoni.sh' \ | |
--sign cosign | |
- name: Push blueprint starter | |
run: | | |
timoni mod push ./blueprints/starter oci://ghcr.io/stefanprodan/timoni/blueprints/starter \ | |
-v ${{ steps.info.outputs.version }} --latest \ | |
-a 'org.opencontainers.image.licenses=Apache-2.0' \ | |
-a 'org.opencontainers.image.source=https://github.com/stefanprodan/timoni' \ | |
-a 'org.opencontainers.image.description=Get started blueprint for timoni.sh modules.' \ | |
-a 'org.opencontainers.image.documentation=https://timoni.sh' \ | |
--sign cosign | |
- name: Push schemas | |
run: | | |
timoni artifact push oci://ghcr.io/stefanprodan/timoni/schemas \ | |
-f ./schemas -t ${{ steps.info.outputs.version }} -t latest \ | |
-a 'org.opencontainers.image.licenses=Apache-2.0' \ | |
-a 'org.opencontainers.image.source=https://github.com/stefanprodan/timoni' \ | |
-a 'org.opencontainers.image.description=Timoni CUE schemas.' \ | |
-a 'org.opencontainers.image.documentation=https://timoni.sh' \ | |
--content-type="cue.mod/pkg" \ | |
--sign cosign | |
provenance: | |
needs: [goreleaser] | |
permissions: | |
actions: read # To read the workflow path. | |
id-token: write # To sign the provenance. | |
contents: write # To add assets to a release. | |
uses: slsa-framework/slsa-github-generator/.github/workflows/generator_generic_slsa3.yml@v1.9.0 | |
with: | |
provenance-name: "timoni_${{ needs.goreleaser.outputs.version }}_provenance.intoto.jsonl" | |
base64-subjects: "${{ needs.goreleaser.outputs.hashes }}" | |
upload-assets: true # upload to a new release |