Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/actions/github-release/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ async function runOnce() {

core.info(`files: ${files}`);
core.info(`name: ${name}`);
core.info(`token: ${token}`);

const octokit = new github.GitHub(token);

Expand Down Expand Up @@ -69,7 +68,8 @@ async function runOnce() {
owner,
repo,
tag_name: name,
prerelease: name === 'dev',
// `dev`, and versions like `v1.2.3-rc.0`.
prerelease: name === 'dev' || name.includes('-'),
});

// Upload all the relevant assets for this release as just general blobs.
Expand Down
72 changes: 72 additions & 0 deletions .github/workflows/create-release-pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
name: Create release PR

# Opens a PR that bumps the version and updates CHANGELOG.md. Merging it tags
# the release (tag-release.yml), which builds and publishes it (release.yml).
on:
workflow_dispatch:
inputs:
version:
description: Version to release, without a leading `v` (ex. `0.6.0`, `0.6.0-rc.0`)
required: true
type: string

permissions: {}

jobs:
create-release-pr:
# Releases are only cut from the default branch.
if: github.ref_name == github.event.repository.default_branch
runs-on: ubuntu-latest
permissions:
# To push the release branch and open the PR.
contents: write
pull-requests: write
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
# git-cliff needs the history and tags since the last release.
fetch-depth: 0
persist-credentials: false

- uses: taiki-e/install-action@ab49d3c64680143e184118bed66a46419fc15519 # v2.90.5
with:
tool: git-cliff,cargo-edit
fallback: cargo-binstall

# `cargo set-version` rejects anything that isn't a semver version, so
# the input is validated before it's used anywhere else.
- name: Bump version
env:
VERSION: ${{ inputs.version }}
run: |
cargo set-version "$VERSION"
cd npm/weval
# The `version` script runs an `update.js` that doesn't exist.
npm version "$VERSION" --no-git-tag-version --ignore-scripts
sed -i "s/^const TAG = \".*\";$/const TAG = \"v$VERSION\";/" index.js

- name: Update changelog
env:
# Lets git-cliff look up the PR and author of each commit.
GITHUB_TOKEN: ${{ github.token }}
VERSION: ${{ inputs.version }}
run: git cliff --unreleased --tag "v$VERSION" --prepend CHANGELOG.md

- name: Create release PR
uses: peter-evans/create-pull-request@3ffccacd46053766916f087ce41d627c0b8cf2d1 # v8.1.3
with:
# Checks on PRs opened with GITHUB_TOKEN wait for a maintainer to
# approve them. A RELEASE_PAT secret, if there is one, avoids that.
token: ${{ secrets.RELEASE_PAT || github.token }}
branch: prep-release-v${{ inputs.version }}
commit-message: "release: weval v${{ inputs.version }}"
title: "release: weval v${{ inputs.version }}"
signoff: true
body: |
Release prep for weval `v${{ inputs.version }}`.

- [ ] Review the `CHANGELOG.md` section for this release.

If the checks are waiting for approval (because GitHub Actions opened this PR), approve them from the checks section below.

Once this PR is merged, `tag-release.yml` tags the merge commit as `v${{ inputs.version }}`, and `release.yml` builds the binaries, creates the GitHub release, and publishes to crates.io and npm.
105 changes: 87 additions & 18 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,15 @@ on:
branches: [main]
tags-ignore: [dev]
pull_request:
# tag-release.yml starts this on the tag it creates for a merged release PR.
workflow_dispatch:
defaults:
run:
shell: bash

permissions:
contents: read

# Cancel any in-flight jobs for the same PR/branch so there's only one active
# at a time
concurrency:
Expand Down Expand Up @@ -39,9 +44,10 @@ jobs:
os: ubuntu-latest
target: s390x-unknown-linux-gnu
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
submodules: true
persist-credentials: false
- uses: ./.github/actions/install-rust
- uses: ./.github/actions/binary-compatible-builds
with:
Expand All @@ -57,39 +63,44 @@ jobs:
# Assemble release artifats appropriate for this platform, then upload them
# unconditionally to this workflow's files so we have a copy of them.
- run: ./ci/build-tarballs.sh "${{ matrix.build }}" "${{ matrix.target }}"
- uses: actions/upload-artifact@v4
- uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
with:
name: bins-${{ matrix.build }}
path: dist
publish:
needs: [build]
runs-on: ubuntu-latest
permissions:
# To create the GitHub release.
contents: write
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
# Download all the artifacts that we'll be publishing. Should keep an eye on
# the `download-artifact` repository to see if we can ever get something
# like "download all artifacts" or "download this list of artifacts"
- uses: actions/download-artifact@v4
- uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
with:
name: bins-x86_64-macos
path: dist
- uses: actions/download-artifact@v4
- uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
with:
name: bins-aarch64-macos
path: dist
- uses: actions/download-artifact@v4
- uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
with:
name: bins-x86_64-windows
path: dist
- uses: actions/download-artifact@v4
- uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
with:
name: bins-x86_64-mingw
path: dist
- uses: actions/download-artifact@v4
- uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
with:
name: bins-x86_64-linux
path: dist
- uses: actions/download-artifact@v4
- uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
with:
name: bins-aarch64-linux
path: dist
Expand All @@ -100,20 +111,78 @@ jobs:
if [[ $GITHUB_REF == refs/tags/v* ]]; then
name=${GITHUB_REF:10}
fi
echo ::set-output name=val::$name
echo TAG=$name >> $GITHUB_ENV
echo "val=$name" >> "$GITHUB_OUTPUT"
id: tagname

# ... and if this was an actual push (tag or `main`) then we publish a
# new release. This'll automatically publish a tag release or update `dev`
# with this `sha`. Note that `continue-on-error` is set here so if this hits
# a bug we can go back and fetch and upload the release ourselves.
- run: cd .github/actions/github-release && npm install --production
# ... and if this was an actual push to `main` or a tag (pushed, or
# dispatched by tag-release.yml) then we publish a new release. This'll
# automatically publish a tag release or update `dev` with this `sha`.
# Note that `continue-on-error` is set for `dev` so if this hits a bug we
# can go back and fetch and upload the release ourselves. Tag releases
# must succeed, since the npm package downloads its binary from them.
- name: Publish Release
uses: ./.github/actions/github-release
if: github.event_name == 'push' && (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v'))
if: github.event_name != 'pull_request' && (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v'))
with:
files: "dist/*"
token: ${{ secrets.GITHUB_TOKEN }}
name: ${{ steps.tagname.outputs.val }}
continue-on-error: true
continue-on-error: ${{ github.ref == 'refs/heads/main' }}

# Publishing to crates.io and npm uses trusted publishing (OIDC), so no
# registry tokens are stored. Outside bytecodealliance/weval (e.g. on forks)
# it's a dry run.
publish-crate:
needs: [publish]
if: startsWith(github.ref, 'refs/tags/v')
runs-on: ubuntu-latest
permissions:
contents: read
# For trusted publishing.
id-token: write
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- uses: ./.github/actions/install-rust
- uses: rust-lang/crates-io-auth-action@3268eb413133e2960fa4ae0e963ca76380c54cd9 # v1.0.6
if: github.repository == 'bytecodealliance/weval'
id: auth
- name: Check the crate version matches the tag
run: grep -qxF "version = \"${GITHUB_REF_NAME#v}\"" Cargo.toml
- name: Publish to crates.io
env:
CARGO_REGISTRY_TOKEN: ${{ steps.auth.outputs.token }}
DRY_RUN: ${{ github.repository != 'bytecodealliance/weval' && '--dry-run' || '' }}
run: cargo publish --locked $DRY_RUN

publish-npm:
needs: [publish]
if: startsWith(github.ref, 'refs/tags/v')
runs-on: ubuntu-latest
permissions:
contents: read
# For trusted publishing.
id-token: write
defaults:
run:
working-directory: npm/weval
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
# Trusted publishing needs npm >= 11.5.1.
- uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
with:
node-version: 24
package-manager-cache: false
- name: Check the package matches the tag
run: |
test "v$(node -p 'require("./package.json").version')" = "$GITHUB_REF_NAME"
grep -qxF "const TAG = \"$GITHUB_REF_NAME\";" index.js
- name: Publish to npm
env:
DRY_RUN: ${{ github.repository != 'bytecodealliance/weval' && '--dry-run' || '' }}
# Keep prereleases (ex. `v0.6.0-rc.0`) off the `latest` dist-tag.
DIST_TAG: ${{ contains(github.ref_name, '-') && 'next' || 'latest' }}
run: npm publish --access public --tag "$DIST_TAG" $DRY_RUN
39 changes: 39 additions & 0 deletions .github/workflows/tag-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: Tag release

# Tags a merged release PR (from create-release-pr.yml) and starts release.yml
# on the tag.
on:
pull_request:
types: [closed]
branches: [main]

permissions: {}

jobs:
tag-release:
if: >-
github.event.pull_request.merged
&& startsWith(github.event.pull_request.head.ref, 'prep-release-v')
&& github.event.pull_request.head.repo.full_name == github.repository
runs-on: ubuntu-latest
permissions:
# To create the tag.
contents: write
# To start release.yml.
actions: write
steps:
# The tag is created with GITHUB_TOKEN, and pushes made with that token
# don't trigger workflows, so release.yml is started explicitly.
- name: Tag release
env:
GH_TOKEN: ${{ github.token }}
BRANCH: ${{ github.event.pull_request.head.ref }}
SHA: ${{ github.event.pull_request.merge_commit_sha }}
run: |
VERSION="${BRANCH#prep-release-v}"
if ! [[ "$VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+(-[0-9A-Za-z.-]+)?$ ]]; then
echo "::error::Invalid release branch [$BRANCH]"
exit 1
fi
gh api --method POST "repos/$GITHUB_REPOSITORY/git/refs" -f "ref=refs/tags/v$VERSION" -f "sha=$SHA"
gh workflow run release.yml --repo "$GITHUB_REPOSITORY" --ref "v$VERSION"
Empty file added CHANGELOG.md
Empty file.
25 changes: 11 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,20 +41,17 @@ appending the specialized functions and filling in function pointers in

See the API in `include/weval.h` for more.

### Releasing Checklist

- Bump the version in `Cargo.toml` and `cargo check` to ensure `Cargo.lock` is
updated as well.
- Bump the tag version (`TAG` constant) in `npm/weval/index.js`.
- Bump the npm package version in `npm/weval/package.json`.
- Run `npm i` in `npm/weval/` to ensure the `package-lock.json` file is
updated.

- Commit all of this as a "version bump" PR.
- Push it to `main` and ensure CI completes successfully.
- Tag as `v0.x.y` and push that tag.
- `cargo publish` from the root.
- `npm publish` from `npm/weval/`.
### Releasing

1. Run the [Create release PR](.github/workflows/create-release-pr.yml)
workflow from the Actions tab with the version to release (ex. `0.6.0`, or
`0.6.0-rc.0` for a prerelease). It opens a PR that bumps the version in
`Cargo.toml`, `Cargo.lock` and `npm/weval/`, and updates `CHANGELOG.md`.
2. Review and merge the PR.
3. [Tag release](.github/workflows/tag-release.yml) then tags the merge commit
as `v<version>` and starts the [Release](.github/workflows/release.yml)
workflow on it, which creates the GitHub release and publishes to crates.io
and npm.

### Further Details

Expand Down
53 changes: 53 additions & 0 deletions cliff.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# git-cliff configuration for CHANGELOG.md, used by create-release-pr.yml.
#
# https://git-cliff.org/docs/configuration

[remote.github]
owner = "bytecodealliance"
repo = "weval"

[changelog]
header = """
# Changelog
"""
body = """
{%- if version %}
## [{{ version | trim_start_matches(pat="v") }}] - {{ timestamp | date(format="%Y-%m-%d") }}
{%- else %}
## [unreleased]
{%- endif %}
{% for group, commits in commits | group_by(attribute="group") %}
### {{ group | striptags | trim | upper_first }}
{% for commit in commits %}
* {% if commit.scope %}*({{ commit.scope }})* {% endif %}\
{% if commit.breaking %}[**breaking**] {% endif %}\
{{ commit.message | split(pat="\n") | first | trim }}\
{% if commit.remote.username %} by @{{ commit.remote.username }}{% endif %}\
{% if commit.remote.pr_number %} in #{{ commit.remote.pr_number }}{% endif %}
{%- endfor %}
{% endfor %}
"""
trim = true

[git]
conventional_commits = true
filter_unconventional = false
split_commits = false
protect_breaking_commits = false
filter_commits = false
topo_order = false
sort_commits = "newest"
tag_pattern = "^v[0-9]+\\.[0-9]+\\.[0-9]+$"
commit_parsers = [
{ message = "^Merge (pull request|branch)", skip = true },
{ message = "^(release|Release)", skip = true },
{ message = "^feat", group = "<!-- 0 -->🚀 Features" },
{ message = "^fix", group = "<!-- 1 -->🐛 Bug Fixes" },
{ message = "^refactor", group = "<!-- 2 -->🚜 Refactor" },
{ message = "^doc", group = "<!-- 3 -->📚 Documentation" },
{ message = "^perf", group = "<!-- 4 -->⚡ Performance" },
{ message = "^style", group = "<!-- 5 -->🎨 Styling" },
{ message = "^test", group = "<!-- 6 -->🧪 Testing" },
{ message = "^(chore|ci|build)", group = "<!-- 7 -->⚙️ Miscellaneous Tasks" },
{ message = ".*", group = "<!-- 8 -->Other Changes" },
]
2 changes: 1 addition & 1 deletion npm/weval/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading