Merge pull request #915 from chainguard-dev/dependabot/github_actions… #491
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: Create Release | |
on: | |
push: | |
branches: | |
- main | |
tags: | |
- 'v*' # Push events to matching v*, i.e. v1.0, v20.15.10 | |
env: | |
GO_VERSION: '1.21' | |
jobs: | |
cli: | |
# Only release CLI for tagged releases | |
if: startsWith(github.event.ref, 'refs/tags/v') | |
name: Release the CLI | |
runs-on: ubuntu-latest | |
# https://docs.github.com/en/actions/reference/authentication-in-a-workflow | |
permissions: | |
id-token: write | |
contents: write | |
steps: | |
- uses: actions/setup-go@93397bea11091df50f3d7e59dc26a7711a8bcfbe # v2.2.0 | |
with: | |
go-version: ${{ env.GO_VERSION }} | |
check-latest: true | |
- uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 | |
- uses: sigstore/cosign-installer@11086d25041f77fe8fe7b9ea4e48e3b9192b8f19 # v3.1.2 | |
- uses: goreleaser/goreleaser-action@7ec5c2b0c6cdda6e8bbb49444bc797dd33d74dd8 # v2.8.1 | |
with: | |
version: latest | |
install-only: true | |
- name: Release | |
run: make release | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
ko-build: | |
name: Release apko image | |
runs-on: ubuntu-latest | |
# https://docs.github.com/en/actions/reference/authentication-in-a-workflow | |
permissions: | |
id-token: write | |
packages: write | |
contents: read | |
env: | |
KO_DOCKER_REPO: ghcr.io/${{ github.repository }} | |
COSIGN_YES: "true" | |
steps: | |
- uses: actions/setup-go@93397bea11091df50f3d7e59dc26a7711a8bcfbe # v2.2.0 | |
with: | |
go-version: ${{ env.GO_VERSION }} | |
check-latest: true | |
- uses: imjasonh/setup-ko@ace48d793556083a76f1e3e6068850c1f4a369aa # v0.4 | |
- uses: sigstore/cosign-installer@11086d25041f77fe8fe7b9ea4e48e3b9192b8f19 # v3.1.2 | |
- uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 | |
- name: Login to registry | |
run: | | |
echo ${{ github.token }} | go run ./ login ghcr.io --username=${{ github.repository_owner }} --password-stdin | |
- name: Publish/Sign apko image | |
run: | | |
# If not a tagged release, override image tag to "canary" | |
export IMAGE_TAG=${GITHUB_REF#refs/tags/} | |
if [[ $GITHUB_REF != refs/tags/* ]]; then | |
export IMAGE_TAG=canary | |
fi | |
make sign-image | |
tekton-task: | |
# Only release the Tekton Task after a CLI release has been created, since | |
# goreleaser creates a GitHub Release which the Tekton Task will be | |
# attached to. | |
needs: cli | |
name: Release the Tekton Task | |
runs-on: ubuntu-latest | |
# https://docs.github.com/en/actions/reference/authentication-in-a-workflow | |
permissions: | |
id-token: write | |
contents: write | |
packages: write | |
steps: | |
- uses: actions/setup-go@93397bea11091df50f3d7e59dc26a7711a8bcfbe # v2.2.0 | |
with: | |
go-version: ${{ env.GO_VERSION }} | |
check-latest: true | |
- uses: ko-build/setup-ko@ace48d793556083a76f1e3e6068850c1f4a369aa # v0.6 | |
- uses: sigstore/cosign-installer@11086d25041f77fe8fe7b9ea4e48e3b9192b8f19 # v3.1.2 | |
- uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 | |
- name: Login to registry | |
run: | | |
echo ${{ github.token }} | go run ./ login ghcr.io --username=${{ github.repository_owner }} --password-stdin | |
- name: Generate Tekton Task | |
run: | | |
# If not a tagged release, override image tag to "canary" | |
export IMAGE_TAG=${GITHUB_REF#refs/tags/} | |
if [[ $GITHUB_REF != refs/tags/* ]]; then | |
export IMAGE_TAG=canary | |
fi | |
make ko-resolve | |
- name: Attach to release | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: gh release upload ${GITHUB_REF#refs/tags/} task.yaml |