Repository navigation
137 lines (113 loc) · 3.97 KB
/
Copy pathrelease.yml
File metadata and controls
137 lines (113 loc) · 3.97 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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
name: Release - Tagged
on:
push:
tags:
- "*.*.*"
permissions:
contents: write
packages: write
id-token: write
concurrency:
group: release-${{ github.ref }}
cancel-in-progress: false
env:
GOLANG_VERSION: 1.27.2
NODE_VERSION: "22"
jobs:
release:
runs-on: ubuntu-latest
timeout-minutes: 90
steps:
- name: Checkout
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
fetch-depth: 0
- name: Ensure release tag is on main
shell: bash
run: |
set -euo pipefail
git fetch --no-tags origin main:refs/remotes/origin/main
tag_commit="$(git rev-list -n 1 "refs/tags/${GITHUB_REF_NAME}")"
if ! git merge-base --is-ancestor "${tag_commit}" origin/main; then
echo "::error::Release tags must point to commits already merged to main"
exit 1
fi
- name: Set up Go
uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0
with:
go-version: ${{ env.GOLANG_VERSION }}
cache: true
- name: Set up Node
uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
with:
node-version: ${{ env.NODE_VERSION }}
cache: npm
cache-dependency-path: frontend/package-lock.json
- name: Build frontend bundle
shell: bash
run: make frontend
- name: Verify frontend bundle exists
shell: bash
run: |
set -euo pipefail
test -f frontend/dist/index.html
test -d frontend/dist/assets
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@bb05f3f5519dd87d3ba754cc423b652a5edd6d2c # v4.2.0
- name: Login to Docker Hub
uses: docker/login-action@dbcb813823bdd20940b903addbd779551569679f # v4.6.0
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}
- name: Install cosign
uses: sigstore/cosign-installer@6f9f17788090df1f26f669e9d70d6ae9567deba6 # v4.1.2
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@f06c13b6b1a9625abc9e6e439d9c05a8f2190e94 # v7.2.3
with:
distribution: goreleaser
version: latest
args: release --clean
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
DOCKER_HUB_ORG: docker.io/${{ secrets.DOCKER_HUB_ORG }}
- name: Verify signed images
shell: bash
env:
DOCKER_HUB_ORG: docker.io/${{ secrets.DOCKER_HUB_ORG }}
RELEASE_TAG: ${{ github.ref_name }}
run: |
set -euo pipefail
retry() {
local attempts=$1
shift
local n=1
until "$@"; do
if [ "$n" -ge "$attempts" ]; then
echo "Command failed after $attempts attempts: $*"
return 1
fi
n=$((n + 1))
sleep $((5 * n))
done
}
resolve_digest() {
local image_ref=$1
local digest
digest="$(docker buildx imagetools inspect "${image_ref}" | awk '/Digest:/ {print $2; exit}')"
if [ -z "${digest}" ]; then
echo "Unable to resolve digest for ${image_ref}" >&2
return 1
fi
printf '%s\n' "${digest}"
}
image_tag="${RELEASE_TAG#v}"
for component in tls api cli frontend; do
image="${DOCKER_HUB_ORG}/osctrl-${component}"
for tag in "${image_tag}" latest; do
digest="$(retry 6 resolve_digest "${image}:${tag}")"
retry 3 cosign verify \
--certificate-identity-regexp "https://github.com/${{ github.repository }}/.github/workflows/.*" \
--certificate-oidc-issuer "https://token.actions.githubusercontent.com" \
"${image}@${digest}" >/dev/null
done
done