Skip to content

Commit 5977527

Browse files
authored
Re-pin wkg.lock automatically when publishing the bridge wasm (#164)
Rust is not byte-reproducible across toolchains, so every publish yields a new digest even when the source is unchanged: the run that verified GHCR permissions rebuilt the wasm 1.4KB smaller and broke main and every open PR with a digest mismatch, needing a manual lock refresh (#163). The workflow now re-pins the lock and pushes it back in the same run, so publishing and pinning land together. It builds before committing, so a wasm that does not build is never pinned.
1 parent ca9119b commit 5977527

1 file changed

Lines changed: 39 additions & 39 deletions

File tree

.github/workflows/wasm-publish.yaml

Lines changed: 39 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -8,31 +8,26 @@ on:
88
inputs:
99
version:
1010
description: >-
11-
Semver tag to publish, e.g. 1.2.0. Use an immutable release tag when
12-
preparing a release; leave the default to refresh the development
13-
snapshot. Must be valid semver: wkg.lock rejects tags like "latest".
11+
Semver tag to publish, e.g. 1.2.0. Leave the default to refresh the
12+
development snapshot. Must be valid semver: wkg.lock rejects "latest".
1413
required: true
1514
default: 999.0.0-SNAPSHOT
1615

17-
# Pushes to main refresh the development snapshot; a manual run can publish any
18-
# semver tag. Must match cranelift-bridge.version in the root pom.xml for the
19-
# build to actually consume what was published.
16+
# Must match cranelift-bridge.version in the root pom.xml to be consumed.
2017
env:
2118
WASM_VERSION: ${{ inputs.version || '999.0.0-SNAPSHOT' }}
2219

2320
jobs:
2421
build-and-publish:
2522
runs-on: ubuntu-latest
2623
permissions:
27-
contents: read
24+
contents: write
2825
packages: write
2926
id-token: write
3027
steps:
3128
- name: Checkout sources
3229
uses: actions/checkout@v7
3330

34-
# Catches "latest", "1.2" and similar before anything is pushed: an
35-
# unparseable tag only fails later, when a consumer writes wkg.lock.
3631
- name: Validate version is semver
3732
run: |
3833
if ! echo "$WASM_VERSION" | grep -Eq '^[0-9]+\.[0-9]+\.[0-9]+(-[0-9A-Za-z.-]+)?(\+[0-9A-Za-z.-]+)?$'; then
@@ -55,14 +50,9 @@ jobs:
5550
- name: Login to GHCR
5651
run: echo "${{ secrets.GITHUB_TOKEN }}" | oras login ghcr.io -u ${{ github.actor }} --password-stdin
5752

58-
# Pushed from inside redline/ so the org.opencontainers.image.title
59-
# annotation is a bare filename. A path like "redline/cranelift_bridge.wasm"
60-
# makes the OCI client try to write into a directory that does not exist
61-
# on pull.
62-
#
63-
# The source annotation links the package to this repository, which is what
64-
# lets GITHUB_TOKEN write to it from Actions and makes it show up under the
65-
# repo's packages.
53+
# From redline/ so the image title is a bare filename; a path makes the
54+
# client write into a non-existent directory on pull. The source
55+
# annotation links the package to the repo, granting GITHUB_TOKEN write.
6656
- name: Push to GHCR
6757
working-directory: redline
6858
run: |
@@ -71,26 +61,36 @@ jobs:
7161
ghcr.io/bytecodealliance/endive-cranelift-bridge:${WASM_VERSION} \
7262
cranelift_bridge.wasm:application/wasm
7363
74-
- name: Next steps
64+
- name: Set up Java
65+
uses: actions/setup-java@v5
66+
with:
67+
distribution: 'temurin'
68+
java-version: '17'
69+
cache: maven
70+
71+
# Rust is not byte-reproducible, so every publish yields a new digest. A
72+
# stale lock breaks main and every open PR, so re-pin in the same run.
73+
- name: Re-pin wkg.lock on main
74+
if: github.ref == 'refs/heads/main'
75+
run: |
76+
set -euo pipefail
77+
78+
# Builds before committing, so a wasm that does not build is never pinned.
79+
./mvnw -B -Dquickly -Dinlay.update
80+
81+
if git diff --quiet -- redline/wkg.lock; then
82+
echo "Lock already matches the published digest."
83+
exit 0
84+
fi
85+
86+
git config user.name "Endive BOT"
87+
git config user.email "endive@bytecodealliance.org"
88+
git add redline/wkg.lock
89+
git commit -m "Re-pin cranelift_bridge.wasm"
90+
git pull --rebase
91+
git push
92+
93+
- name: Summary
7594
run: |
76-
{
77-
echo "Published \`$WASM_VERSION\`."
78-
echo
79-
echo "Publishing does not update the lock file. Until it is refreshed the"
80-
echo "build keeps resolving the previously pinned digest, and re-pushing an"
81-
echo "already-locked tag makes every build fail with a digest mismatch."
82-
echo
83-
echo "To consume it:"
84-
echo
85-
echo '```bash'
86-
echo "# 1. point the build at this tag"
87-
echo "./mvnw versions:set-property -Dproperty=cranelift-bridge.version \\"
88-
echo " -DnewVersion=$WASM_VERSION -DgenerateBackupPoms=false"
89-
echo
90-
echo "# 2. re-pin the digest"
91-
echo "./mvnw generate-sources -pl :redline-bridge-experimental -Dinlay.update"
92-
echo
93-
echo "# 3. commit both"
94-
echo "git commit -am 'Use cranelift_bridge.wasm $WASM_VERSION'"
95-
echo '```'
96-
} >> "$GITHUB_STEP_SUMMARY"
95+
echo "Published \`$WASM_VERSION\`. Open pull requests need a rebase to" \
96+
"pick up the re-pinned lock." >> "$GITHUB_STEP_SUMMARY"

0 commit comments

Comments
 (0)