forked from ericsink/cb
-
Notifications
You must be signed in to change notification settings - Fork 0
236 lines (202 loc) · 7.62 KB
/
Copy pathupdate-sqlite3mc.yml
File metadata and controls
236 lines (202 loc) · 7.62 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
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
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
name: Update SQLite3MC (Manual)
on:
workflow_dispatch:
inputs:
version:
description: "SQLite3MC version (e.g. 2.3.4)"
required: true
type: string
mode:
description: "Update mode"
required: true
type: choice
default: dry-run
options:
- sanity
- dry-run
- update
permissions:
contents: read
concurrency:
group: update-sqlite-${{ github.ref }}
cancel-in-progress: false
jobs:
update:
name: Update version information and SQLite3MC sources
runs-on: ubuntu-latest
permissions:
contents: write # commits & pushes updated SQLite3MC sources
attestations: read
id-token: write
env:
MODE: ${{ github.event.inputs.mode }}
steps:
# -------------------------------------------------
# Checkout repository
# -------------------------------------------------
- name: Checkout
uses: actions/checkout@v6
with:
fetch-depth: 0
# -------------------------------------------------
# Setup Python
# -------------------------------------------------
- name: Setup Python
uses: actions/setup-python@v6
with:
python-version: "3.12"
# -------------------------------------------------
# Validate version format
# -------------------------------------------------
- name: Validate version format
env:
VERSION: ${{ inputs.version }}
run: |
set -euo pipefail
python3 scripts/validate_version.py "${{ inputs.version }}"
# -------------------------------------------------
# Resolve release asset
# Locate release asset for SQLite3MC amalgamation
# -------------------------------------------------
- name: Resolve release asset (locked)
id: asset
env:
GH_TOKEN: ${{ github.token }}
VERSION: ${{ inputs.version }}
shell: bash
run: |
set -euo pipefail
TAG="v${VERSION}"
echo "Resolving release for tag: $TAG"
mapfile -t ASSETS < <(
gh release view "$TAG" \
--repo utelle/SQLite3MultipleCiphers \
--json assets \
--jq '
.assets[].name
| select(test("^sqlite3mc-'"${VERSION}"'-sqlite-[0-9.]+-amalgamation\\.zip$"))
'
)
if [ "${#ASSETS[@]}" -ne 1 ]; then
echo "ERROR: Expected exactly 1 matching asset, found ${#ASSETS[@]}" >&2
printf '%s\n' "${ASSETS[@]:-}"
exit 1
fi
ASSET_NAME="${ASSETS[0]}"
echo "asset_name=$ASSET_NAME" >> "$GITHUB_OUTPUT"
# -------------------------------------------------
# Download release asset for SQLite3MC amalgamation
# -------------------------------------------------
- name: Download release asset
env:
GH_TOKEN: ${{ github.token }}
VERSION: ${{ inputs.version }}
run: |
set -euo pipefail
mkdir -p download
gh release download "v${VERSION}" \
--repo utelle/SQLite3MultipleCiphers \
--pattern "${{ steps.asset.outputs.asset_name }}" \
--dir download
# -------------------------------------------------
# Verify GitHub Attestation
# --signer-workflow pins the trusted builder identity: only artifacts
# attested by the reusable build-reusable.yml workflow of the
# SQLite3MultipleCiphers repo are accepted (not just any workflow of
# that repo).
# -------------------------------------------------
- name: Verify GitHub Attestation
env:
GH_TOKEN: ${{ github.token }}
run: |
set -euo pipefail
FILE="download/${{ steps.asset.outputs.asset_name }}"
echo "Verifying GitHub attestation for $FILE"
gh attestation verify "$FILE" \
--repo utelle/SQLite3MultipleCiphers
#gh attestation verify "$FILE" \
# --repo utelle/SQLite3MultipleCiphers \
# --signer-workflow utelle/SQLite3MultipleCiphers/.github/workflows/build-reusable.yml
echo "Attestation verification successful"
# -------------------------------------------------
# Extract amalgamation archive
# -------------------------------------------------
- name: Extract amalgamation archive
run: |
set -euo pipefail
mkdir extracted
unzip \
"download/${{ steps.asset.outputs.asset_name }}" \
-d extracted
# -------------------------------------------------
# Replace SQLite3MC source files
# -------------------------------------------------
- name: Replace SQLite3MC source files
run: |
set -euo pipefail
# Check that directory sqlite3mc exists
test -d sqlite3mc
# Check that all needed files were extracted
test -f extracted/sqlite3mc_amalgamation.c
test -f extracted/sqlite3mc_amalgamation.h
test -f extracted/shell3mc_amalgamation.c
test -f extracted/sqlite3ext.h
# Check that previous versions exist
test -f sqlite3mc/sqlite3.c
test -f sqlite3mc/sqlite3.h
test -f sqlite3mc/shell.c
test -f sqlite3mc/sqlite3ext.h
# Replace source files by new versions
cp -T extracted/sqlite3mc_amalgamation.c sqlite3mc/sqlite3.c
cp -T extracted/sqlite3mc_amalgamation.h sqlite3mc/sqlite3.h
cp -T extracted/shell3mc_amalgamation.c sqlite3mc/shell.c
cp -T extracted/sqlite3ext.h sqlite3mc/sqlite3ext.h
# -------------------------------------------------
# Update versioninfo.json
# -------------------------------------------------
- name: Update versioninfo.json
env:
VERSION: ${{ inputs.version }}
run: |
set -euo pipefail
python3 scripts/update_versioninfo.py \
"${{ inputs.version }}" \
bld/versioninfo.json
# -------------------------------------------------
# GIT + GPG SETUP incl. dry-run validation (composite action;
# skipped entirely in sanity mode). The dry-run validation now uses an
# empty signed commit + `git verify-commit` — the same mechanism the
# update mode actually relies on (git commit -S), and the same
# validation as in release.yml.
# -------------------------------------------------
- name: Set up GPG signing
if: ${{ inputs.mode != 'sanity' }}
uses: ./.github/actions/setup-signing
with:
git-user-name: ${{ vars.GIT_USER_NAME }}
git-user-email: ${{ vars.GIT_USER_EMAIL }}
gpg-key-id: ${{ vars.GPG_KEY_ID }}
gpg-private-key: ${{ secrets.GPG_PRIVATE_KEY }}
validate: ${{ inputs.mode == 'dry-run' }}
# -------------------------------------------------
# Commit changed source files and configuration (only update)
# -------------------------------------------------
- name: Commit changes
if: ${{ inputs.mode == 'update' }}
env:
VERSION: ${{ inputs.version }}
shell: bash
run: |
set -euo pipefail
git add \
sqlite3mc/sqlite3.c \
sqlite3mc/sqlite3.h \
sqlite3mc/sqlite3ext.h \
sqlite3mc/shell.c \
bld/versioninfo.json
if git diff --cached --quiet; then
echo "No changes detected"
exit 0
fi
git commit -S -m "Update SQLite3MC to ${VERSION}"
git push