-
Notifications
You must be signed in to change notification settings - Fork 0
209 lines (184 loc) · 6.32 KB
/
release.yml
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
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
# Creates a GitHub Release.
# Workflow is manually run.
# Preselect branch or tag before running this workflow.
name: release
on:
workflow_dispatch:
inputs:
prerelease:
description: "Mark this release as a prerelease"
required: false
default: "auto"
type: choice
# auto follows semver. Prerelease versions are hyphenated with a label. ex. 0.0.0-alpha, 1.0.0-rc1
options:
- auto
- "true"
- "false"
make-latest:
description: "Latest release"
required: false
default: true
type: boolean
nightly:
description: "Mark as nightly build"
required: true
default: true
type: boolean
permissions:
contents: write
id-token: write
packages: write
jobs:
release:
runs-on: ubuntu-latest
env:
DOCKER_CLI_EXPERIMENTAL: "enabled"
strategy:
matrix:
release_os:
- linux
- darwin
- freebsd
- illumos
- netbsd
- openbsd
- windows
steps:
- name: Disable release on nightly repository
if: ${{ !inputs.nightly }}
run: |
if [ "$GITHUB_REPOSITORY" == "openbao/openbao-nightly" ]; then
echo "Refusing to run non-nightly release on nightly repo" 1>&2
exit 1
fi
- name: Checkout
uses: actions/[email protected]
with:
fetch-depth: 0 # Required by GoRelease
- name: Disable nightly on primary repository
if: inputs.nightly
env:
PRERELEASE: ${{ inputs.prerelease }}
run: |
if [ "$GITHUB_REPOSITORY" != "openbao/openbao-nightly" ]; then
echo "Refusing to run nightly release on non-nightly repo" 1>&2
exit 1
fi
# Otherwise, create fake tags that we do not push; this limits the
# size of the changelog.
git tag v9999.9999.9998 HEAD~
git tag v9999.9999.9999-n"$(date +%Y%m%d)"
- name: Golang Setup
uses: ./.github/actions/set-up-go
- name: go-check
run: go version
- name: Node setup
uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af # v4.1.0
with:
node-version-file: "./ui/package.json"
- name: Yarn setup
id: install-yarn
run: |
npm install -g yarn
# Supports syft/sbom generation
- uses: anchore/sbom-action/download-syft@v0
# Supports Buildx
- name: Qemu Setup
uses: docker/setup-qemu-action@v3
- name: Buildx Setup
uses: docker/setup-buildx-action@v3
- name: Cosign Install
uses: sigstore/cosign-installer@v3
- name: GPG Import
id: gpg-import
uses: crazy-max/ghaction-import-gpg@v6
with:
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
passphrase: ${{ secrets.GPG_PASSWORD }}
- name: Cache Setup
uses: actions/cache@v4
with:
path: |
./dist/**/bao
./dist/**/*.exe
./dist/**/*.deb
./dist/**/*.rpm
./dist/*.tar.gz
./dist/*.tar.gz.zst
./dist/*.zip
key: ${{ github.ref }}
- name: "Docker Login: ghcr.io"
if: startsWith(github.ref, 'refs/tags/') || inputs.nightly
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: "Docker Login: docker.io"
if: startsWith(github.ref, 'refs/tags/') || inputs.nightly
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_TOKEN }}
- name: "Docker Login: quay.io"
if: startsWith(github.ref, 'refs/tags/') || inputs.nightly
uses: docker/login-action@v3
with:
registry: quay.io
username: ${{ secrets.QUAY_USERNAME }}
password: ${{ secrets.QUAY_TOKEN }}
# Needed for nPFM
- name: Create GPG Signing Key File
if: startsWith(github.ref, 'refs/tags/') || inputs.nightly
run: |
GPG_KEY_FILE=/tmp/signing-key.gpg
echo "${{ secrets.GPG_PRIVATE_KEY_BASE64 }}" | base64 -di > "${GPG_KEY_FILE}"
echo "GPG_KEY_FILE=${GPG_KEY_FILE}" >> "${GITHUB_ENV}"
env:
GPG_TTY: /dev/ttys000 # Set the GPG_TTY to avoid issues with pinentry
# Before executing binary builds, build the UI.
- name: Install UI dependencies
id: ui-dependencies
working-directory: ./ui
run: |
yarn install --frozen-lockfile
npm rebuild node-sass
- name: Build UI
id: ui-build
run: |
make static-dist
# Execute Go binary builds
- name: "Template GoRelaser configuration"
if: startsWith(github.ref, 'refs/tags/') || inputs.nightly
run: |
sed "s/REPLACE_WITH_RELEASE_GOOS/${{ matrix.release_os }}/g" .goreleaser-template.yaml > .goreleaser.yaml
sed -i "s/^#OTHERARCH#//g" .goreleaser.yaml
[ "${{ matrix.release_os }}" == "linux" ] && sed -i "s/^#LINUXONLY#//g" .goreleaser.yaml || true
- name: "GoReleaser: Release"
if: startsWith(github.ref, 'refs/tags/') || inputs.nightly
uses: goreleaser/goreleaser-action@v6
with:
distribution: goreleaser
version: latest
args: release --clean --timeout=60m --verbose --parallelism 2
env:
COSIGN_PASSWORD: ${{ secrets.COSIGN_PASSWORD }}
COSIGN_PRIVATE_KEY: ${{ secrets.COSIGN_PRIVATE_KEY }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GPG_FINGERPRINT: ${{ steps.gpg-import.outputs.fingerprint }}
GPG_PASSWORD: ${{ secrets.GPG_PASSWORD }}
GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }}
GITHUB_RELEASE_PRERELEASE: ${{ inputs.prerelease }}
GITHUB_RELEASE_MAKE_LATEST: ${{ inputs.make-latest }}
NFPM_DEFAULT_PASSPHRASE: ${{ secrets.GPG_PASSWORD }}
NIGHTLY_RELEASE: ${{ inputs.nightly }}
- name: Remove GPG Signing Key File
if: always()
run: |
if [ -n "${GPG_KEY_FILE}" ]; then
rm -rf "${GPG_KEY_FILE}"
fi
- name: "Check free space on runner"
run: |
df -h .