Skip to content

Commit 13d27bf

Browse files
authored
Build a new release process for this repository (#844)
Like with the wasm-tools repository in bytecodealliance/wasm-tools#1416, this repository is going to follow suit with the same release process. Notably everything should now be largely automated in terms of publication and such so anyone can make a release so long as they have write access to the repository.
1 parent d679d1a commit 13d27bf

File tree

23 files changed

+460
-217
lines changed

23 files changed

+460
-217
lines changed

.github/workflows/build.yml

Lines changed: 0 additions & 62 deletions
This file was deleted.

.github/workflows/main.yml

Lines changed: 75 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
name: CI
2-
32
on:
4-
push:
5-
branches: [main]
63
pull_request:
7-
branches: [main]
4+
merge_group:
5+
86
defaults:
97
run:
108
shell: bash
@@ -16,6 +14,43 @@ concurrency:
1614
cancel-in-progress: true
1715

1816
jobs:
17+
build:
18+
name: Build wit-bindgen
19+
runs-on: ${{ matrix.os }}
20+
strategy:
21+
matrix:
22+
include:
23+
- build: x86_64-linux
24+
os: ubuntu-latest
25+
- build: x86_64-macos
26+
os: macos-latest
27+
- build: aarch64-macos
28+
os: macos-latest
29+
target: aarch64-apple-darwin
30+
- build: x86_64-windows
31+
os: windows-latest
32+
- build: aarch64-linux
33+
os: ubuntu-latest
34+
target: aarch64-unknown-linux-gnu
35+
steps:
36+
- uses: actions/checkout@v4
37+
with:
38+
submodules: true
39+
- run: rustup update stable --no-self-update && rustup default stable
40+
- uses: bytecodealliance/wasmtime/.github/actions/binary-compatible-builds@v17.0.1
41+
with:
42+
name: ${{ matrix.build }}
43+
- run: |
44+
echo CARGO_BUILD_TARGET=${{ matrix.target }} >> $GITHUB_ENV
45+
rustup target add ${{ matrix.target }}
46+
if: matrix.target != ''
47+
- run: $CENTOS cargo build --release
48+
- run: ./ci/build-tarballs.sh "${{ matrix.build }}" "${{ matrix.target }}"
49+
- uses: actions/upload-artifact@v3
50+
with:
51+
name: bins-${{ matrix.build }}
52+
path: dist
53+
1954
test:
2055
name: Test
2156
strategy:
@@ -103,3 +138,39 @@ jobs:
103138
run: rustup update stable && rustup default stable && rustup component add rustfmt
104139
- name: Format source code
105140
run: cargo fmt -- --check
141+
142+
verify-publish:
143+
if: github.repository_owner == 'bytecodealliance'
144+
runs-on: ubuntu-latest
145+
steps:
146+
- uses: actions/checkout@v4
147+
with:
148+
submodules: true
149+
- run: rustup update stable && rustup default stable
150+
- run: rustc ci/publish.rs
151+
# Make sure the tree is publish-able as-is
152+
- run: ./publish verify
153+
# Make sure we can bump version numbers for the next release
154+
- run: ./publish bump
155+
156+
# "Join node" which the merge queue waits on.
157+
ci-status:
158+
name: Record the result of testing and building steps
159+
runs-on: ubuntu-latest
160+
needs:
161+
- test
162+
- rustfmt
163+
- build
164+
- verify-publish
165+
if: always()
166+
167+
steps:
168+
- name: Successful test and build
169+
if: ${{ !(contains(needs.*.result, 'failure')) }}
170+
run: exit 0
171+
- name: Failing test and build
172+
if: ${{ contains(needs.*.result, 'failure') }}
173+
run: exit 1
174+
- name: Report failure on cancellation
175+
if: ${{ contains(needs.*.result, 'cancelled') || cancelled() }}
176+
run: exit 1

.github/workflows/publish.yml

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
# Publication half of the release process for this repository. This runs on
2+
# pushes to `main` and will detect a magical string in commit messages. When
3+
# found a tag will be created, pushed, and then everything is published.
4+
5+
name: Publish Artifacts
6+
on:
7+
push:
8+
branches: [main]
9+
10+
permissions:
11+
contents: write
12+
13+
jobs:
14+
create_tag:
15+
name: Publish artifacts of build
16+
runs-on: ubuntu-latest
17+
if: |
18+
github.repository_owner == 'bytecodealliance'
19+
&& github.event_name == 'push'
20+
&& github.ref == 'refs/heads/main'
21+
steps:
22+
- uses: actions/checkout@v4
23+
with:
24+
submodules: true
25+
fetch-depth: 0
26+
27+
- run: rustup update stable && rustup default stable
28+
29+
# If this is a push to `main` see if the push has an indicator saying that
30+
# a tag should be made. If so create one and push it.
31+
- name: Test if tag is needed
32+
run: |
33+
git log ${{ github.event.before }}...${{ github.event.after }} | tee main.log
34+
version=$(./ci/print-current-version.sh)
35+
echo "version: $version"
36+
echo "version=$version" >> $GITHUB_OUTPUT
37+
echo "sha=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT
38+
if grep -q "automatically-tag-and-release-this-commit" main.log; then
39+
echo push-tag
40+
echo "push_tag=yes" >> $GITHUB_OUTPUT
41+
else
42+
echo no-push-tag
43+
echo "push_tag=no" >> $GITHUB_OUTPUT
44+
fi
45+
id: tag
46+
47+
- name: Push the tag
48+
run: |
49+
git_refs_url=$(jq .repository.git_refs_url $GITHUB_EVENT_PATH | tr -d '"' | sed 's/{\/sha}//g')
50+
curl -iX POST $git_refs_url \
51+
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
52+
-d @- << EOF
53+
{
54+
"ref": "refs/tags/v${{ steps.tag.outputs.version }}",
55+
"sha": "${{ steps.tag.outputs.sha }}"
56+
}
57+
EOF
58+
if: steps.tag.outputs.push_tag == 'yes'
59+
60+
- run: |
61+
sha=${{ github.sha }}
62+
run_id=$(
63+
gh api -H 'Accept: application/vnd.github+json' \
64+
/repos/${{ github.repository }}/actions/workflows/main.yml/runs\?exclude_pull_requests=true \
65+
| jq '.workflow_runs' \
66+
| jq "map(select(.head_commit.id == \"$sha\"))[0].id" \
67+
)
68+
gh run download $run_id
69+
ls
70+
find bins-*
71+
mkdir dist
72+
mv bins-*/* dist
73+
env:
74+
GH_TOKEN: ${{ github.token }}
75+
76+
- uses: softprops/action-gh-release@v1
77+
if: steps.tag.outputs.push_tag == 'yes'
78+
with:
79+
files: "dist/*"
80+
tag_name: v${{ steps.tag.outputs.version }}
81+
82+
- run: |
83+
rm -rf dist main.log
84+
rustc ci/publish.rs
85+
./publish publish
86+
env:
87+
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
88+
if: steps.tag.outputs.push_tag == 'yes'

.github/workflows/release-process.yml

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
# Initiation half of the release process for this repository.
2+
#
3+
# This is triggered manually through the github actions UI and will execute
4+
# `./publish bump` (or `bump-patch`). Afterwards the result will be pushed to a
5+
# branch in the main repository and a PR will be opened. This PR, when merged,
6+
# will trigger the second half in `publish.yml`.
7+
8+
name: "Automated Release Process"
9+
on:
10+
# Allow manually triggering this request via the button on the action
11+
# workflow page.
12+
workflow_dispatch:
13+
inputs:
14+
action:
15+
description: 'Publish script argument: "bump", or "bump-patch"'
16+
required: false
17+
default: 'bump'
18+
19+
jobs:
20+
release_process:
21+
name: Run the release process
22+
runs-on: ubuntu-latest
23+
steps:
24+
- uses: actions/checkout@v4
25+
with:
26+
submodules: true
27+
- name: Setup
28+
run: |
29+
rustc ci/publish.rs
30+
git config user.name 'Auto Release Process'
31+
git config user.email 'auto-release-process@users.noreply.github.com'
32+
git remote set-url origin https://git:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}
33+
34+
- name: Bump version number
35+
run: ./publish ${{ github.event.inputs.action }}
36+
37+
- name: Prep PR metadata
38+
run: |
39+
set -ex
40+
git fetch origin
41+
42+
cur=$(./ci/print-current-version.sh)
43+
44+
git commit --allow-empty -a -F-<<EOF
45+
Release ${{ github.event.repository.name }} $cur
46+
47+
[automatically-tag-and-release-this-commit]
48+
EOF
49+
50+
# Push the result to a branch and setup metadata for the step below
51+
# that creates a PR
52+
git push origin HEAD:ci/release-$cur
53+
echo "PR_HEAD=ci/release-$cur" >> $GITHUB_ENV
54+
echo "PR_TITLE=Release ${{ github.event.repository.name }} $cur" >> $GITHUB_ENV
55+
echo "PR_BASE=main" >> $GITHUB_ENV
56+
cat > pr-body <<-EOF
57+
This is an automated pull request from CI to release
58+
${{ github.event.repository.name }} $cur when merged. The commit
59+
message for this PR has a marker that is detected by CI to create
60+
tags and publish crate artifacts.
61+
62+
When first opened this PR will not have CI run because it is generated
63+
by a bot. A maintainer should close this PR and then reopen it to
64+
trigger CI to execute which will then enable merging this PR.
65+
EOF
66+
67+
- name: Make a PR
68+
run: gh pr create -B "$PR_BASE" -H "$PR_HEAD" --title "$PR_TITLE" --body "$(cat ./pr-body)"
69+
env:
70+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

Cargo.lock

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "wit-bindgen-cli"
33
authors = ["Alex Crichton <alex@alexcrichton.com>"]
4-
version = "0.18.0"
4+
version.workspace = true
55
edition = { workspace = true }
66
repository = 'https://github.com/bytecodealliance/wit-bindgen'
77
license = "Apache-2.0 WITH LLVM-exception"
@@ -18,6 +18,7 @@ resolver = "2"
1818

1919
[workspace.package]
2020
edition = "2021"
21+
version = "0.18.0"
2122

2223
[workspace.dependencies]
2324
anyhow = "1.0.72"

README.md

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -459,3 +459,40 @@ cargo build
459459
```
460460

461461
Learn more how to run the tests in the [testing document](tests/README.md).
462+
463+
# Versioning and Releases
464+
465+
This repository's crates and CLI are all currently versioned at `0.X.Y` where
466+
`Y` is frequently `0` and `X` increases most of the time with publishes. This
467+
means that changes are published as possibly-API-breaking changes as development
468+
continues here.
469+
470+
Also, this repository does not currently have a strict release cadence. Releases
471+
are done on an as-needed basis. If you'd like a release done please feel free to
472+
reach out on [Zulip], file an issue, leave a comment on a PR, or otherwise
473+
contact a maintainer.
474+
475+
[Zulip]: https://bytecodealliance.zulipchat.com/
476+
477+
For maintainers, the release process looks like:
478+
479+
* Go to [this link](https://github.com/bytecodealliance/wit-bindgen/actions/workflows/release-process.yml)
480+
* Click on "Run workflow" in the UI.
481+
* Use the default `bump` argument and hit "Run workflow"
482+
* Wait for a PR to be created by CI. You can watch the "Actions" tab for if
483+
things go wrong.
484+
* When the PR opens, close it then reopen it. Don't ask questions.
485+
* Review the PR, approve it, then queue it for merge.
486+
487+
That should be it, but be sure to keep an eye on CI in case anything goes wrong.
488+
489+
# License
490+
491+
This project is licensed under the Apache 2.0 license with the LLVM exception.
492+
See [LICENSE](LICENSE) for more details.
493+
494+
### Contribution
495+
496+
Unless you explicitly state otherwise, any contribution intentionally submitted
497+
for inclusion in this project by you, as defined in the Apache-2.0 license,
498+
shall be licensed as above, without any additional terms or conditions.

0 commit comments

Comments
 (0)