Skip to content

Commit a1f502a

Browse files
committed
fix(ci): select predictive validation without PR packages
1 parent ab4b4d3 commit a1f502a

9 files changed

Lines changed: 2014 additions & 709 deletions

.github/workflows/ci.yml

Lines changed: 156 additions & 37 deletions
Large diffs are not rendered by default.

.github/workflows/linux-binaries.yml

Lines changed: 87 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,26 @@ on:
1515
description: "Stable prefix that isolates artifacts in the caller run."
1616
required: true
1717
type: string
18+
artifact_retention_days:
19+
description: "Retention for uploaded build artifacts."
20+
required: false
21+
default: 7
22+
type: number
23+
upload_artifacts:
24+
description: "Whether to upload archives for a publishing caller."
25+
required: false
26+
default: true
27+
type: boolean
28+
cache_write:
29+
description: "Allow a trusted non-PR caller to refresh build caches."
30+
required: false
31+
default: false
32+
type: boolean
33+
validate_relay_image:
34+
description: "Build the Relay runtime image for each native architecture without pushing it."
35+
required: false
36+
default: true
37+
type: boolean
1838
secrets:
1939
release_signing_key:
2040
description: "Tauri/minisign private key, base64. Absent on forks: archives ship unsigned."
@@ -47,9 +67,11 @@ jobs:
4767
- os: ubuntu-22.04
4868
name: linux-x64
4969
target: x86_64-unknown-linux-gnu
70+
docker_arch: amd64
5071
- os: ubuntu-22.04-arm
5172
name: linux-arm64
5273
target: aarch64-unknown-linux-gnu
74+
docker_arch: arm64
5375

5476
steps:
5577
- name: Checkout
@@ -61,6 +83,13 @@ jobs:
6183
uses: oven-sh/setup-bun@v2
6284
with:
6385
bun-version: "1.3.14"
86+
no-cache: true
87+
88+
- name: Setup Node.js
89+
uses: actions/setup-node@v5
90+
with:
91+
node-version-file: package.json
92+
package-manager-cache: false
6493

6594
- name: Build plugin Host resources
6695
run: |
@@ -91,8 +120,13 @@ jobs:
91120
- name: Cache Rust build
92121
uses: swatinem/rust-cache@v2
93122
with:
94-
shared-key: "linux-binaries-v1-${{ matrix.platform.name }}"
123+
shared-key: "linux-binaries-v2-${{ github.base_ref || github.ref_name }}-${{ matrix.platform.name }}"
95124
cache-bin: false
125+
save-if: ${{ inputs.cache_write && github.event_name != 'pull_request' }}
126+
cache-on-failure: ${{ inputs.cache_write && github.event_name != 'pull_request' }}
127+
128+
- name: Verify committed Cargo metadata
129+
run: cargo metadata --locked --no-deps
96130

97131
- name: Patch build version
98132
shell: bash
@@ -106,12 +140,10 @@ jobs:
106140
# the same way, which also keeps the two asset sets on one version string.
107141
ASSET_VERSION="${RELEASE_VERSION%%+*}"
108142
echo "ASSET_VERSION=${ASSET_VERSION}" >>"$GITHUB_ENV"
109-
sed -i \
110-
"s/^version = \".*\" # x-release-please-version/version = \"${ASSET_VERSION}\" # x-release-please-version/" \
111-
Cargo.toml
112-
sed -i \
113-
"s/^version = \".*\" # x-release-please-version/version = \"${ASSET_VERSION}\" # x-release-please-version/" \
114-
src/apps/relay-server/Cargo.toml
143+
node scripts/set-build-version.mjs --version "$ASSET_VERSION"
144+
145+
- name: Verify projected Cargo metadata
146+
run: cargo metadata --locked --no-deps
115147

116148
- name: Build CLI and Relay Server
117149
shell: bash
@@ -121,7 +153,7 @@ jobs:
121153
# checksum-only.
122154
BITFUN_RELEASE_PUBKEY: ${{ secrets.release_pubkey }}
123155
run: |
124-
cargo build --release \
156+
cargo build --locked --release \
125157
--target ${{ matrix.platform.target }} \
126158
-p bitfun-cli \
127159
-p bitfun-relay-server \
@@ -179,12 +211,58 @@ jobs:
179211
"$CLI_ARCHIVE" "${CLI_ARCHIVE}.sha256" \
180212
"$RELAY_ARCHIVE" "${RELAY_ARCHIVE}.sha256"
181213
214+
- name: Verify Linux binary outputs
215+
shell: bash
216+
env:
217+
CLI_ARCHIVE: ${{ steps.cli-stage.outputs.archive }}
218+
CLI_CHECKSUM: ${{ steps.cli-stage.outputs.checksum }}
219+
RELAY_ARCHIVE: ${{ steps.relay-stage.outputs.archive }}
220+
RELAY_CHECKSUM: ${{ steps.relay-stage.outputs.checksum }}
221+
run: |
222+
set -euo pipefail
223+
test -s "$CLI_ARCHIVE"
224+
test -s "$CLI_CHECKSUM"
225+
test -s "$RELAY_ARCHIVE"
226+
test -s "$RELAY_CHECKSUM"
227+
sha256sum --check "$CLI_CHECKSUM"
228+
sha256sum --check "$RELAY_CHECKSUM"
229+
230+
- name: Stage Relay image validation context
231+
if: ${{ inputs.validate_relay_image }}
232+
shell: bash
233+
env:
234+
RELAY_ARCHIVE: ${{ steps.relay-stage.outputs.archive }}
235+
run: |
236+
set -euo pipefail
237+
mkdir -p relay-image-context
238+
cp "$RELAY_ARCHIVE" relay-image-context/
239+
cp src/apps/relay-server/Dockerfile.release relay-image-context/
240+
241+
- name: Set up Docker Buildx
242+
if: ${{ inputs.validate_relay_image }}
243+
uses: docker/setup-buildx-action@v4
244+
245+
- name: Validate Relay runtime image
246+
if: ${{ inputs.validate_relay_image }}
247+
uses: docker/build-push-action@v7
248+
with:
249+
context: relay-image-context
250+
file: relay-image-context/Dockerfile.release
251+
platforms: linux/${{ matrix.platform.docker_arch }}
252+
push: false
253+
provenance: false
254+
sbom: false
255+
build-args: |
256+
VERSION=${{ inputs.version }}
257+
REVISION=${{ inputs.checkout_ref }}
258+
182259
- name: Upload Linux binary artifacts
260+
if: ${{ inputs.upload_artifacts }}
183261
uses: actions/upload-artifact@v6
184262
with:
185263
name: bitfun-linux-${{ inputs.artifact_prefix }}-${{ matrix.platform.name }}
186264
if-no-files-found: error
187-
retention-days: 7
265+
retention-days: ${{ inputs.artifact_retention_days }}
188266
path: |
189267
${{ steps.cli-stage.outputs.archive }}
190268
${{ steps.cli-stage.outputs.checksum }}

0 commit comments

Comments
 (0)