-
Notifications
You must be signed in to change notification settings - Fork 0
273 lines (243 loc) · 9.32 KB
/
Copy pathci.yml
File metadata and controls
273 lines (243 loc) · 9.32 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
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
name: ci
on:
push:
branches:
- "**"
tags:
- "v*"
pull_request:
workflow_dispatch:
permissions:
contents: read
defaults:
run:
shell: bash
env:
REQPACK_RUNTIME_TAG: v1.2.14
jobs:
build-test:
name: ${{ matrix.name }}
runs-on: ${{ matrix.runner }}
strategy:
fail-fast: false
matrix:
include:
- name: linux-x86_64
runner: ubuntu-24.04
platform: linux
arch: x86_64
vcpkg_triplet: x64-linux
python_cmd: python3
binary_path: build/tempify
reqpack_asset: rqp-v1.2.14-x86_64-linux.tar.gz
plugin_test: true
- name: linux-aarch64
runner: ubuntu-24.04-arm
platform: linux
arch: aarch64
vcpkg_triplet: arm64-linux
python_cmd: python3
binary_path: build/tempify
reqpack_asset: rqp-v1.2.14-aarch64-linux.tar.gz
plugin_test: true
- name: macos-x86_64
runner: macos-15-intel
platform: macos
arch: x86_64
vcpkg_triplet: x64-osx
python_cmd: python3
binary_path: build/tempify
reqpack_asset: ""
plugin_test: false
- name: macos-aarch64
runner: macos-15
platform: macos
arch: aarch64
vcpkg_triplet: arm64-osx
python_cmd: python3
binary_path: build/tempify
reqpack_asset: rqp-v1.2.14-aarch64-darwin.tar.gz
plugin_test: true
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Install Linux prerequisites
if: runner.os == 'Linux'
run: |
sudo apt-get update
sudo apt-get install -y --no-install-recommends ninja-build pkg-config zstd
- name: Install macOS prerequisites
if: runner.os == 'macOS'
run: |
brew update
brew install ninja zstd
- name: Bootstrap vcpkg (Unix)
if: runner.os != 'Windows'
run: |
set -euo pipefail
VCPKG_ROOT="$RUNNER_TEMP/vcpkg"
git clone --depth 1 https://github.com/microsoft/vcpkg.git "$VCPKG_ROOT"
"$VCPKG_ROOT/bootstrap-vcpkg.sh" -disableMetrics
echo "VCPKG_ROOT=$VCPKG_ROOT" >> "$GITHUB_ENV"
"$VCPKG_ROOT/vcpkg" install "lua:${{ matrix.vcpkg_triplet }}" "cli11:${{ matrix.vcpkg_triplet }}"
- name: Configure (Unix)
if: runner.os != 'Windows'
run: |
set -euo pipefail
cmake -S . -B build -G Ninja \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_TOOLCHAIN_FILE="$VCPKG_ROOT/scripts/buildsystems/vcpkg.cmake" \
-DVCPKG_TARGET_TRIPLET="${{ matrix.vcpkg_triplet }}"
- name: Build (Unix)
if: runner.os != 'Windows'
run: |
set -euo pipefail
cmake --build build --parallel
- name: Test (Unix)
if: runner.os != 'Windows'
run: |
set -euo pipefail
ctest --test-dir build --output-on-failure
- name: Download ReqPack runtime (Unix)
if: runner.os != 'Windows' && matrix.plugin_test
run: |
set -euo pipefail
mkdir -p reqpack-runtime
curl -fsSL \
"https://github.com/Coditary/ReqPack/releases/download/${REQPACK_RUNTIME_TAG}/${{ matrix.reqpack_asset }}" \
-o "reqpack-runtime/${{ matrix.reqpack_asset }}"
- name: Extract ReqPack runtime (Linux)
if: runner.os == 'Linux' && matrix.plugin_test
run: |
set -euo pipefail
mkdir -p reqpack-runtime/root
tar -xzf "reqpack-runtime/${{ matrix.reqpack_asset }}" -C reqpack-runtime/root
- name: Extract ReqPack runtime (macOS)
if: runner.os == 'macOS' && matrix.plugin_test
run: |
set -euo pipefail
mkdir -p reqpack-runtime/root
tar -xzf "reqpack-runtime/${{ matrix.reqpack_asset }}" -C reqpack-runtime/root
- name: Test bundled ReqPack plugin (Unix)
if: runner.os != 'Windows' && matrix.plugin_test
run: |
set -euo pipefail
./reqpack-runtime/root/rqp test-plugin --help >/dev/null
./reqpack-runtime/root/rqp test-plugin --plugin . --preset core
- name: Package release artifact (Unix)
if: startsWith(github.ref, 'refs/tags/v') && runner.os != 'Windows'
run: |
set -euo pipefail
${{ matrix.python_cmd }} scripts/ci/package_binary.py \
--version "$GITHUB_REF_NAME" \
--platform "${{ matrix.platform }}" \
--arch "${{ matrix.arch }}" \
--binary "${{ matrix.binary_path }}" \
--output-dir dist
- name: Package ReqPack artifact (Unix)
if: startsWith(github.ref, 'refs/tags/v') && runner.os != 'Windows'
run: |
set -euo pipefail
${{ matrix.python_cmd }} scripts/ci/package_reqpack.py \
--version "$GITHUB_REF_NAME" \
--platform "${{ matrix.platform }}" \
--arch "${{ matrix.arch }}" \
--binary "${{ matrix.binary_path }}" \
--output-dir dist
- name: Smoke install packaged ReqPack artifact (Linux)
if: startsWith(github.ref, 'refs/tags/v') && runner.os == 'Linux' && matrix.arch == 'x86_64'
run: |
set -euo pipefail
temp_home="$RUNNER_TEMP/tempify-rqp-home"
rm -rf "$temp_home"
mkdir -p "$temp_home"
HOME="$temp_home" XDG_DATA_HOME="$temp_home/.local/share" ./reqpack-runtime/root/rqp install ./dist/tempify-cli-${GITHUB_REF_NAME#v}-${{ matrix.platform }}-${{ matrix.arch }}.rqp --non-interactive
HOME="$temp_home" XDG_DATA_HOME="$temp_home/.local/share" "$temp_home/.local/bin/tempify" --help >/dev/null
test -f "$temp_home/.local/share/reqpack/plugins/tempify/run.lua"
- name: Upload release artifact
if: startsWith(github.ref, 'refs/tags/v')
uses: actions/upload-artifact@v4
with:
name: release-${{ matrix.platform }}-${{ matrix.arch }}
path: |
dist/*.tar.gz
dist/*.rqp
if-no-files-found: error
release:
if: startsWith(github.ref, 'refs/tags/v')
needs: build-test
runs-on: ubuntu-24.04
permissions:
contents: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Download packaged artifacts
uses: actions/download-artifact@v4
with:
pattern: release-*
merge-multiple: true
path: dist
- name: Build ReqPack repository index
run: |
set -euo pipefail
python3 scripts/ci/build_reqpack_index.py --dist-dir dist --output dist/index.json
- name: Publish GitHub release
env:
GH_TOKEN: ${{ github.token }}
GH_REPO: ${{ github.repository }}
run: |
set -euo pipefail
VERSION="${GITHUB_REF_NAME#v}"
if ! gh release view "$GITHUB_REF_NAME" --repo "$GH_REPO" >/dev/null 2>&1; then
gh release create "$GITHUB_REF_NAME" --repo "$GH_REPO" --title "Tempify $VERSION" --notes "Automated release for Tempify $VERSION."
fi
gh release edit "$GITHUB_REF_NAME" --repo "$GH_REPO" --draft=false --latest --title "Tempify $VERSION" --notes "Automated release for Tempify $VERSION."
gh release upload "$GITHUB_REF_NAME" dist/*.tar.gz dist/*.rqp dist/index.json --repo "$GH_REPO" --clobber
docker:
if: startsWith(github.ref, 'refs/tags/v')
needs: build-test
runs-on: ubuntu-24.04
permissions:
contents: read
packages: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Compute image metadata
id: meta
run: |
set -euo pipefail
IMAGE_NAME=$(printf '%s' 'ghcr.io/coditary/tempify' | tr '[:upper:]' '[:lower:]')
VERSION="${GITHUB_REF_NAME#v}"
CREATED=$(date -u +%Y-%m-%dT%H:%M:%SZ)
echo "image_name=$IMAGE_NAME" >> "$GITHUB_OUTPUT"
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
echo "created=$CREATED" >> "$GITHUB_OUTPUT"
- name: Log in to GHCR
env:
GH_TOKEN: ${{ github.token }}
run: |
set -euo pipefail
printf '%s' "$GH_TOKEN" | docker login ghcr.io -u "${GITHUB_ACTOR}" --password-stdin
- name: Enable QEMU
run: |
set -euo pipefail
docker run --privileged --rm tonistiigi/binfmt --install amd64,arm64
- name: Create buildx builder
run: |
set -euo pipefail
docker buildx create --name tempify-builder --use
docker buildx inspect --bootstrap
- name: Build and push Docker image
run: |
set -euo pipefail
docker buildx build \
--platform linux/amd64,linux/arm64 \
--build-arg TEMPIFY_VERSION="${{ steps.meta.outputs.version }}" \
--build-arg BUILD_DATE="${{ steps.meta.outputs.created }}" \
--label "org.opencontainers.image.source=https://github.com/${GITHUB_REPOSITORY}" \
-t "${{ steps.meta.outputs.image_name }}:${{ steps.meta.outputs.version }}" \
-t "${{ steps.meta.outputs.image_name }}:${GITHUB_REF_NAME}" \
-t "${{ steps.meta.outputs.image_name }}:latest" \
--push .