Skip to content

Commit 4e1fc4f

Browse files
committed
ci: allow re-using engine builds for releases (#3399)
1 parent 7619e4d commit 4e1fc4f

File tree

22 files changed

+256
-98
lines changed

22 files changed

+256
-98
lines changed

.github/workflows/release.yaml

Lines changed: 35 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ on:
1212
required: true
1313
type: boolean
1414
default: true
15+
reuse_engine_version:
16+
description: 'Reuse engine artifacts from this version (skips building)'
17+
required: false
18+
type: string
1519

1620
defaults:
1721
run:
@@ -47,8 +51,10 @@ jobs:
4751

4852
- name: Setup
4953
env:
50-
# Required to authenticate with Git
54+
# https://docs.github.com/en/actions/security-guides/automatic-token-authentication
5155
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
56+
R2_RELEASES_ACCESS_KEY_ID: ${{ secrets.R2_RELEASES_ACCESS_KEY_ID }}
57+
R2_RELEASES_SECRET_ACCESS_KEY: ${{ secrets.R2_RELEASES_SECRET_ACCESS_KEY }}
5258
working-directory: './rivet'
5359
run: |
5460
# Configure Git
@@ -66,15 +72,23 @@ jobs:
6672
# Install tsx globally
6773
npm install -g tsx
6874
69-
if [ "${{ inputs.latest }}" = "true" ]; then
70-
./scripts/release/main.ts --version "${{ github.event.inputs.version }}" --phase setup-ci
71-
else
72-
./scripts/release/main.ts --version "${{ github.event.inputs.version }}" --no-latest --phase setup-ci
75+
# Build command based on inputs
76+
CMD="./scripts/release/main.ts --version \"${{ github.event.inputs.version }}\" --phase setup-ci"
77+
78+
if [ "${{ inputs.latest }}" != "true" ]; then
79+
CMD="$CMD --no-latest"
80+
fi
81+
82+
if [ -n "${{ inputs.reuse_engine_version }}" ]; then
83+
CMD="$CMD --reuse-engine-version \"${{ inputs.reuse_engine_version }}\""
7384
fi
7485
86+
eval "$CMD"
87+
7588
binaries:
7689
name: "Build & Push Binaries"
7790
needs: [setup]
91+
if: ${{ !inputs.reuse_engine_version }}
7892
strategy:
7993
matrix:
8094
include:
@@ -158,6 +172,7 @@ jobs:
158172
docker:
159173
name: "Build & Push Docker Images"
160174
needs: [setup]
175+
if: ${{ !inputs.reuse_engine_version }}
161176
strategy:
162177
matrix:
163178
include:
@@ -223,7 +238,8 @@ jobs:
223238

224239
complete:
225240
name: "Complete"
226-
needs: [docker, binaries]
241+
needs: [setup, docker, binaries]
242+
if: ${{ always() && !cancelled() && needs.setup.result == 'success' && (needs.docker.result == 'success' || needs.docker.result == 'skipped') && (needs.binaries.result == 'success' || needs.binaries.result == 'skipped') }}
227243
runs-on: ubuntu-24.04
228244
steps:
229245
- uses: actions/checkout@v4
@@ -244,9 +260,10 @@ jobs:
244260

245261
- name: Complete
246262
env:
263+
# https://cli.github.com/manual/gh_help_environment
264+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
247265
R2_RELEASES_ACCESS_KEY_ID: ${{ secrets.R2_RELEASES_ACCESS_KEY_ID }}
248266
R2_RELEASES_SECRET_ACCESS_KEY: ${{ secrets.R2_RELEASES_SECRET_ACCESS_KEY }}
249-
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
250267
run: |
251268
# Authenticate with NPM
252269
cat << EOF > ~/.npmrc
@@ -259,8 +276,15 @@ jobs:
259276
# Install tsx globally
260277
npm install -g tsx
261278
262-
if [ "${{ inputs.latest }}" = "true" ]; then
263-
./scripts/release/main.ts --version "${{ github.event.inputs.version }}" --phase complete-ci --no-validate-git
264-
else
265-
./scripts/release/main.ts --version "${{ github.event.inputs.version }}" --no-latest --phase complete-ci --no-validate-git
279+
# Build command based on inputs
280+
CMD="./scripts/release/main.ts --version \"${{ github.event.inputs.version }}\" --phase complete-ci --no-validate-git"
281+
282+
if [ "${{ inputs.latest }}" != "true" ]; then
283+
CMD="$CMD --no-latest"
266284
fi
285+
286+
if [ -n "${{ inputs.reuse_engine_version }}" ]; then
287+
CMD="$CMD --reuse-engine-version \"${{ inputs.reuse_engine_version }}\""
288+
fi
289+
290+
eval "$CMD"

0 commit comments

Comments
 (0)