Files
revive/.github/workflows/release.yml
T
LJ 11e2ea1be4 Fix Wasm build cache collision (#544)
## Description

Before the CI refactor, the Wasm builds initiated by `release.yml` and
`test-wasm.yml` ran in parallel, building duplicate builds. After the CI
refactor, those workflows shared the build cache key to instead reuse
the build. In both cases, the resolc Wasm URI baked into `resolc_web.js`
depends on whether it is a release or not.

If the Wasm build step initiated by `release.yml` started *before*
`test-wasm.yml`, `test-wasm.yml` would use an incorrect cache due to the
invalid resolc Wasm URI (seen by [this failed
run](https://github.com/paritytech/revive/actions/runs/27178950108/job/80235255116?pr=529)).

This PR updates the workflow input `is_release` to only pertain to ref
names starting with `v` (which is what the `create-release` step guards
on), and updates the cache key and concurrency group to include
`is_release`, solving the cache collision. (Thus, the workflows needing
a Wasm build for non-v-releases will still reuse the now-correct cache.)
2026-06-10 10:06:43 +02:00

166 lines
4.9 KiB
YAML

name: Build & Release
on:
push:
tags:
- "v*"
pull_request:
branches: ["main"]
types: [opened, synchronize, labeled, unlabeled]
paths-ignore:
- "**.md"
- "book/**"
- "docs/**"
- "tooling-projects/**"
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
env:
CARGO_TERM_COLOR: always
jobs:
check-version-changed:
runs-on: ubuntu-24.04
permissions:
contents: write
env:
CURRENT_TAG: ${{ github.ref_name }}
outputs:
RELEASE_NOTES: ${{ steps.versions.outputs.RELEASE_NOTES }}
steps:
- uses: actions/checkout@v6
- name: Check versions
id: versions
run: |
if [[ $CURRENT_TAG == 'main' ]]; then
echo "::notice::Tag $CURRENT_TAG is not a release tag, skipping the check in the main branch"
exit 0
fi
if [[ $CURRENT_TAG != "v"* ]]; then
echo "::notice::Tag $CURRENT_TAG is not a release tag, skipping the check in a PR"
exit 0
fi
export PKG_VER=v$(cat crates/resolc/Cargo.toml | grep -A 5 package] | grep version | cut -d '=' -f 2 | tr -d '"' | tr -d " ")
echo "Current tag $CURRENT_TAG"
echo "Package version $PKG_VER"
if [[ $CURRENT_TAG != $PKG_VER ]]; then
echo "::error::Tag $CURRENT_TAG doesn't match package version $PKG_VER in Cargo.toml, please fix"
exit 1
fi
export RELEASE_NOTES="$(sed '/^## '${CURRENT_TAG}'/,/^## v/!d' CHANGELOG.md | sed -e '1d' -e '$d')"
echo "Release notes:"
echo "$RELEASE_NOTES"
echo 'RELEASE_NOTES<<EOF' >> $GITHUB_OUTPUT
echo "$RELEASE_NOTES" >> $GITHUB_OUTPUT
echo 'EOF' >> $GITHUB_OUTPUT
build:
needs: [check-version-changed]
uses: ./.github/workflows/reusable-build.yml
with:
is_release: ${{ startsWith(github.ref_name, 'v') }}
retention_days: 1
create-release:
if: startsWith(github.ref_name, 'v')
needs: [check-version-changed, build]
runs-on: ubuntu-24.04
environment: tags
steps:
- name: Download Artifacts
uses: actions/download-artifact@v7
with:
merge-multiple: true
- name: Make Executable
run: |
chmod +x resolc-x86_64-unknown-linux-musl
chmod +x resolc-universal-apple-darwin
- name: Create sha-256 checksum
run: |
sha256sum resolc-x86_64-unknown-linux-musl > checksums.txt
sha256sum resolc-universal-apple-darwin >> checksums.txt
sha256sum resolc-x86_64-pc-windows-msvc.exe >> checksums.txt
sha256sum resolc.js >> checksums.txt
sha256sum resolc.wasm >> checksums.txt
sha256sum resolc_web.js >> checksums.txt
- uses: actions/create-github-app-token@v3
id: app-token
with:
app-id: ${{ secrets.REVIVE_RELEASE_APP_ID }}
private-key: ${{ secrets.REVIVE_RELEASE_APP_KEY }}
- name: create-release
uses: softprops/action-gh-release@v2
with:
body: |
## Changelog
${{ needs.check-version-changed.outputs.RELEASE_NOTES }}
## Note for macOS Users
The macOS binary is unsigned and it needs to be made runnable using `xattr -c resolc-universal-apple-darwin`.
tag_name: ${{ github.ref_name }}
name: ${{ github.ref_name }}
prerelease: true
token: ${{ steps.app-token.outputs.token }}
target_commitish: ${{ github.sha }}
files: |
resolc-x86_64-unknown-linux-musl
resolc-universal-apple-darwin
resolc-x86_64-pc-windows-msvc.exe
resolc.js
resolc.wasm
resolc_web.js
checksums.txt
npm-release:
needs: [create-release]
runs-on: ubuntu-24.04
environment: tags
steps:
- uses: actions/checkout@v6
- name: Download Artifacts
uses: actions/download-artifact@v7
with:
merge-multiple: true
- name: Set Up Node.js
uses: actions/setup-node@v6
with:
node-version: "24"
- run: npm ci -w js/resolc
- name: Build
run: |
cp --remove-destination resolc.{wasm,js} js/resolc/src/resolc/
npm -w js/resolc run build
- name: npm pack
run: npm -w js/resolc pack
- uses: actions/upload-artifact@v6
with:
name: npm_package
path: "parity-resolc-*.tgz"
- uses: octokit/request-action@bbedc70b1981e610d89f1f8de88311a1fc02fb83
with:
route: POST /repos/paritytech/npm_publish_automation/actions/workflows/publish.yml/dispatches
ref: main
inputs: '${{ format(''{{ "artifact_name": "npm_package", "repo": "{0}", "run_id": "{1}" }}'', github.repository, github.run_id) }}'
env:
GITHUB_TOKEN: ${{ secrets.NPM_PUBLISH_AUTOMATION_TOKEN }}