Repository navigation
121 lines (118 loc) · 4.48 KB
/
Copy pathcli-plugin-release.yaml
File metadata and controls
121 lines (118 loc) · 4.48 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
name: cli-plugin-release
on:
workflow_call:
inputs:
go-version:
description: 'Go version to setup'
required: true
type: string
release-candidate-prefix:
description: 'release candidate image tag prefix'
required: false
default: 'rc'
type: string
secrets:
github-token:
description: 'GitHub token for creating releases and pushing to GHCR'
required: true
jobs:
cli-release:
if: startsWith(github.ref, 'refs/tags/v')
runs-on: ubuntu-latest
permissions:
contents: write # for creating the GitHub release.
id-token: write # for creating OIDC tokens for signing.
attestations: write # for GitHub Attestations.
artifact-metadata: write # for GitHub SLSA provenance.
steps:
- name: Checkout
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
fetch-depth: 0
- name: Setup Syft
uses: anchore/sbom-action/download-syft@3ad7283483fc7af8ff2b4ea19663c2d5ca935e26 # v0.24.2
- name: Setup Go
uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0
with:
go-version: ${{ inputs.go-version }}
cache: false
- name: Version info
id: ver
run: |
VERSION=${GITHUB_REF/refs\/tags\//}
echo "SEMVER=${VERSION#v}" >> $GITHUB_OUTPUT
- name: Create release
id: run-goreleaser
uses: goreleaser/goreleaser-action@f06c13b6b1a9625abc9e6e439d9c05a8f2190e94 # v7.2.3
with:
version: latest
args: release
env:
GITHUB_TOKEN: ${{ secrets.github-token }}
- name: Attest release assets
uses: actions/attest@1e69f48acb82d1966a394da916b4c1698aa569d6 # v4.2.2
with:
subject-checksums: '${{ github.workspace }}/dist/${{ github.event.repository.name }}_${{ steps.ver.outputs.SEMVER }}_checksums.txt'
cli-release-docker:
needs: [cli-release]
if: ${{ !cancelled() && (!startsWith(github.ref, 'refs/tags/v') || needs.cli-release.result == 'success') }}
runs-on: ubuntu-latest
permissions:
id-token: write # for creating OIDC tokens for signing.
packages: write # for pushing and signing container images.
steps:
- name: Checkout
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Version info
id: ver
env:
GIT_REF: ${{ github.ref }}
GIT_SHA: ${{ github.sha }}
RELEASE_CANDIDATE_PREFIX: ${{ inputs.release-candidate-prefix }}
run: |
VERSION="${RELEASE_CANDIDATE_PREFIX}-${GIT_SHA::8}"
if [[ $GIT_REF == refs/tags/* ]]; then
VERSION=${GIT_REF/refs\/tags\//}
fi
echo "VERSION=${VERSION}" >> $GITHUB_OUTPUT
- name: Setup QEMU
uses: docker/setup-qemu-action@99012661954931238ded8c8b007157a8430204e1 # v4.4.0
- name: Setup Docker Buildx
id: buildx
uses: docker/setup-buildx-action@f87e5991a6d7451dcb8d9637bfbc97413f497069 # v4.4.1
- name: Login to GitHub Container Registry
uses: docker/login-action@dbcb813823bdd20940b903addbd779551569679f # v4.6.0
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.github-token }}
- name: Generate image meta
id: meta
uses: docker/metadata-action@dc802804100637a589fabce1cb79ff13a1411302 # v6.2.0
with:
images: |
ghcr.io/${{ github.repository }}
tags: |
type=raw,value=${{ steps.ver.outputs.VERSION }}
type=raw,value=latest,enable=${{ startsWith(github.ref, 'refs/tags/v') }}
- name: Push image
id: build-push
uses: docker/build-push-action@c3c9e263c25d99ce0380d002d59b67737d91b0dc # v7.4.0
with:
sbom: true
provenance: true
push: true
builder: ${{ steps.buildx.outputs.name }}
context: .
file: ./Dockerfile
platforms: linux/amd64,linux/arm64
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
build-args: "VERSION=${{ steps.ver.outputs.VERSION }}"
- uses: sigstore/cosign-installer@6f9f17788090df1f26f669e9d70d6ae9567deba6 # v4.1.2
- name: Sign image
env:
COSIGN_EXPERIMENTAL: 1
run: |
cosign sign --yes \
ghcr.io/${{ github.repository }}@${{ steps.build-push.outputs.digest }}