Skip to content

v0.1.0

v0.1.0 #38

Workflow file for this run

name: Release
on:
release:
types:
- created
jobs:
publish-image:
permissions:
contents: write # Used to upload assets
packages: write # Used to push images to `ghcr.io`
id-token: write # Needed to create an OIDC token for keyless signing
runs-on: ubuntu-latest
outputs:
image-digest: ${{ steps.image.outputs.digest }}
steps:
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Install Cosign
uses: sigstore/[email protected]
with:
cosign-release: 'v2.1.1' # optional
- name: Login to GHCR
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ secrets.GH_USERNAME }}
password: ${{ secrets.GH_TOKEN }}
- name: Checkout
uses: actions/checkout@v3
- name: Docker meta
id: meta
uses: docker/metadata-action@v4
with:
images: ghcr.io/akuity/kargo
flavor: latest=false
tags: type=semver,pattern={{raw}}
- name: Build and push
id: image
uses: docker/build-push-action@v3
with:
platforms: linux/amd64,linux/arm64
build-args: |
VERSION=${{ github.ref_name }}
GIT_COMMIT=${{ github.sha }}
GIT_TREE_STATE=clean
tags: ${{ steps.meta.outputs.tags }}
push: true
cache-from: type=gha
cache-to: type=gha,mode=max
provenance: false
sbom: false
- name: Sign image
env:
TAGS: ${{ steps.meta.outputs.tags }}
run: |
cosign sign \
-a "repo=${{ github.repository }}" \
-a "workflow=${{ github.workflow }}" \
-a "sha=${{ github.sha }}" \
--yes \
ghcr.io/akuity/kargo@${{ steps.image.outputs.digest}}
- name: Publish SBOM
uses: anchore/sbom-action@v0
with:
image: ${{ steps.meta.outputs.tags }}
kargo-image-provenance:
needs:
- publish-image
permissions:
actions: read # for detecting the Github Actions environment.
id-token: write # for creating OIDC tokens for signing.
packages: write # for uploading attestations. (https://github.com/slsa-framework/slsa-github-generator/blob/main/internal/builders/container/README.md#known-issues)
# Must be refernced 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/[email protected]
with:
image: ghcr.io/akuity/kargo
digest: ${{ needs.publish-image.outputs.image-digest }}
secrets:
registry-username: ${{ secrets.GH_USERNAME }}
registry-password: ${{ secrets.GH_TOKEN }}
publish-charts:
needs: publish-image
runs-on: ubuntu-latest
steps:
- name: Set up Helm
uses: azure/setup-helm@v3
with:
version: '3.12.3'
- name: Login to GHCR
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ secrets.GH_USERNAME }}
password: ${{ secrets.GH_TOKEN }}
- name: Checkout code
uses: actions/checkout@v3
- name: Publish chart
env:
HELM_EXPERIMENTAL_OCI: '1'
KARGO_CHARTS_REPO: ghcr.io/akuity/kargo-charts
VERSION: ${{ github.ref_name }}
run: |
CHART_VERSION=$(echo $VERSION | cut -c 2-)
cd charts/kargo
helm dep up
helm package . --version ${CHART_VERSION} --app-version ${VERSION}
helm push kargo-${CHART_VERSION}.tgz oci://${KARGO_CHARTS_REPO}
publish-cli:
runs-on: ubuntu-latest
container:
image: golang:1.21.0-bookworm
strategy:
matrix:
os: [linux, darwin, windows]
arch: [amd64, arm64]
outputs:
hash-linux-amd64: ${{ steps.hash.outputs.hash-linux-amd64 }}
hash-linux-arm64: ${{ steps.hash.outputs.hash-linux-arm64 }}
hash-darwin-amd64: ${{ steps.hash.outputs.hash-darwin-amd64 }}
hash-darwin-arm64: ${{ steps.hash.outputs.hash-darwin-arm64 }}
hash-windows-amd64: ${{ steps.hash.outputs.hash-windows-amd64 }}
hash-windows-arm64: ${{ steps.hash.outputs.hash-windows-arm64 }}
steps:
- name: Checkout code
uses: actions/checkout@v3
- uses: actions/cache@v3
with:
path: /go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Build CLI
env:
GOFLAGS: -buildvcs=false
GOOS: ${{ matrix.os }}
GOARCH: ${{ matrix.arch }}
VERSION: ${{ github.ref_name }}
GIT_COMMIT: ${{ github.sha }}
GIT_TREE_STATE: clean
run: make build-cli
- name: Publish CLI
uses: svenstaro/upload-release-action@v2
with:
file: bin/*
file_glob: true
repo_token: ${{ secrets.GITHUB_TOKEN }}
- name: Generate subject
id: hash
run: |
echo "hash-${{ matrix.os }}-${{ matrix.arch }}=$(sha256sum bin/kargo* | awk -F 'bin/' '{print $1 $2}'| base64 -w0)" >> "$GITHUB_OUTPUT"
combine_hashes:
needs: [publish-cli]
runs-on: ubuntu-latest
outputs:
hashes: ${{ steps.hashes.outputs.hashes }}
env:
HASHES: ${{ toJSON(needs.publish-cli.outputs) }}
steps:
- id: hashes
run: |
echo "$HASHES" | jq -r '.[] | @base64d' | sed "/^$/d" > hashes.txt
echo "hashes=$(cat hashes.txt | base64 -w0)" >> "$GITHUB_OUTPUT"
provenance:
needs: [combine_hashes]
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/[email protected]
with:
base64-subjects: "${{ needs.combine_hashes.outputs.hashes }}"
upload-assets: true # Optional: Upload to a new release
provenance-name: kargo-cli.intoto.jsonl