-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Copy CI from wasm-tools * Use a merge queue * Automate releases/publishes * Fix a typo
- Loading branch information
1 parent
f319360
commit 746cd34
Showing
7 changed files
with
636 additions
and
68 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,79 @@ | ||
name: CI | ||
on: | ||
push: | ||
branches: [main] | ||
pull_request: | ||
branches: [main] | ||
merge_group: | ||
|
||
# Cancel any in-flight jobs for the same PR/branch so there's only one active | ||
# at a time | ||
concurrency: | ||
group: ${{ github.workflow }}-${{ github.ref }} | ||
cancel-in-progress: true | ||
|
||
defaults: | ||
run: | ||
shell: bash | ||
|
||
jobs: | ||
build: | ||
name: Build wasm-component-ld | ||
runs-on: ${{ matrix.os }} | ||
strategy: | ||
matrix: | ||
include: | ||
- build: x86_64-linux | ||
os: ubuntu-latest | ||
- build: x86_64-macos | ||
os: macos-latest | ||
- build: aarch64-macos | ||
os: macos-latest | ||
target: aarch64-apple-darwin | ||
- build: x86_64-windows | ||
os: windows-latest | ||
- build: aarch64-linux | ||
os: ubuntu-latest | ||
target: aarch64-unknown-linux-gnu | ||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
submodules: true | ||
- run: rustup update stable --no-self-update && rustup default stable | ||
- uses: bytecodealliance/wasmtime/.github/actions/[email protected] | ||
with: | ||
name: ${{ matrix.build }} | ||
if: matrix.build != 'wasm32-wasi' | ||
- run: | | ||
echo CARGO_BUILD_TARGET=${{ matrix.target }} >> $GITHUB_ENV | ||
rustup target add ${{ matrix.target }} | ||
if: matrix.target != '' | ||
- run: $CENTOS cargo build --release | ||
- run: ./ci/build-tarballs.sh "${{ matrix.build }}" "${{ matrix.target }}" | ||
- uses: actions/upload-artifact@v3 | ||
with: | ||
name: bins-${{ matrix.build }} | ||
path: dist | ||
|
||
test: | ||
name: Test | ||
runs-on: ${{ matrix.os }} | ||
strategy: | ||
matrix: | ||
include: | ||
- os: ubuntu-latest | ||
rust: stable | ||
- os: ubuntu-latest | ||
rust: beta | ||
- os: ubuntu-latest | ||
rust: nightly | ||
- os: macos-latest | ||
rust: stable | ||
- os: windows-latest | ||
rust: stable | ||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
submodules: true | ||
- name: Install Rust (rustup) | ||
run: rustup update stable --no-self-update && rustup default stable | ||
shell: bash | ||
run: rustup update ${{ matrix.rust }} --no-self-update && rustup default ${{ matrix.rust }} | ||
- run: rustup target add wasm32-wasi | ||
- run: cargo test --locked | ||
|
||
|
@@ -38,4 +84,28 @@ jobs: | |
- uses: actions/checkout@v4 | ||
- name: Install Rust | ||
run: rustup update stable && rustup default stable && rustup component add rustfmt | ||
- run: cargo fmt --check | ||
# Note that this doesn't use `cargo fmt` because that doesn't format | ||
# modules-defined-in-macros which is in use in `wast` for example. This is | ||
# the best alternative I can come up with at this time | ||
- run: find . -name '*.rs' | xargs rustfmt --check --edition 2021 | ||
|
||
# "Join node" which the merge queue waits on. | ||
ci-status: | ||
name: Record the result of testing and building steps | ||
runs-on: ubuntu-latest | ||
needs: | ||
- test | ||
- rustfmt | ||
- build | ||
if: always() | ||
|
||
steps: | ||
- name: Successful test and build | ||
if: ${{ !(contains(needs.*.result, 'failure')) }} | ||
run: exit 0 | ||
- name: Failing test and build | ||
if: ${{ contains(needs.*.result, 'failure') }} | ||
run: exit 1 | ||
- name: Report failure on cancellation | ||
if: ${{ contains(needs.*.result, 'cancelled') || cancelled() }} | ||
run: exit 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
# Publication half of the release process for this repository. This runs on | ||
# pushes to `main` and will detect a magical string in commit messages. When | ||
# found a tag will be created, pushed, and then everything is published. | ||
|
||
name: Publish Artifacts | ||
on: | ||
push: | ||
branches: [main] | ||
|
||
permissions: | ||
contents: write | ||
|
||
jobs: | ||
create_tag: | ||
name: Publish artifacts of build | ||
runs-on: ubuntu-latest | ||
if: | | ||
github.repository_owner == 'alexcrichton' | ||
&& github.event_name == 'push' | ||
&& github.ref == 'refs/heads/main' | ||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
submodules: true | ||
fetch-depth: 0 | ||
|
||
- run: rustup update stable && rustup default stable | ||
|
||
# If this is a push to `main` see if the push has an indicator saying that | ||
# a tag should be made. If so create one and push it. | ||
- name: Test if tag is needed | ||
run: | | ||
git log ${{ github.event.before }}...${{ github.event.after }} | tee main.log | ||
version=$(./ci/print-current-version.sh) | ||
echo "version: $version" | ||
echo "version=$version" >> $GITHUB_OUTPUT | ||
echo "sha=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT | ||
if grep -q "automatically-tag-and-release-this-commit" main.log; then | ||
echo push-tag | ||
echo "push_tag=yes" >> $GITHUB_OUTPUT | ||
else | ||
echo no-push-tag | ||
echo "push_tag=no" >> $GITHUB_OUTPUT | ||
fi | ||
id: tag | ||
|
||
- name: Push the tag | ||
run: | | ||
git_refs_url=$(jq .repository.git_refs_url $GITHUB_EVENT_PATH | tr -d '"' | sed 's/{\/sha}//g') | ||
curl -iX POST $git_refs_url \ | ||
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \ | ||
-d @- << EOF | ||
{ | ||
"ref": "refs/tags/v${{ steps.tag.outputs.version }}", | ||
"sha": "${{ steps.tag.outputs.sha }}" | ||
} | ||
EOF | ||
if: steps.tag.outputs.push_tag == 'yes' | ||
|
||
- run: | | ||
sha=${{ github.sha }} | ||
run_id=$( | ||
gh api -H 'Accept: application/vnd.github+json' \ | ||
/repos/${{ github.repository }}/actions/workflows/main.yml/runs\?exclude_pull_requests=true \ | ||
| jq '.workflow_runs' \ | ||
| jq "map(select(.head_commit.id == \"$sha\"))[0].id" \ | ||
) | ||
gh run download $run_id | ||
ls | ||
find bins-* | ||
mkdir dist | ||
mv bins-*/* dist | ||
env: | ||
GH_TOKEN: ${{ github.token }} | ||
- uses: softprops/action-gh-release@v1 | ||
if: steps.tag.outputs.push_tag == 'yes' | ||
with: | ||
files: "dist/*" | ||
tag_name: v${{ steps.tag.outputs.version }} | ||
|
||
- run: | | ||
rm -rf dist main.log | ||
rustc ci/publish.rs | ||
./publish publish | ||
env: | ||
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }} | ||
if: steps.tag.outputs.push_tag == 'yes' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
# Initiation half of the release process for this repository. | ||
# | ||
# This is triggered manually through the github actions UI and will execute | ||
# `./publish bump` (or `bump-patch`). Afterwards the result will be pushed to a | ||
# branch in the main repository and a PR will be opened. This PR, when merged, | ||
# will trigger the second half in `publish.yml`. | ||
|
||
name: "Automated Release Process" | ||
on: | ||
# Allow manually triggering this request via the button on the action | ||
# workflow page. | ||
workflow_dispatch: | ||
inputs: | ||
action: | ||
description: 'Publish script argument: "bump", or "bump-patch"' | ||
required: false | ||
default: 'bump' | ||
|
||
jobs: | ||
release_process: | ||
name: Run the release process | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
submodules: true | ||
- name: Setup | ||
run: | | ||
rustc ci/publish.rs | ||
git config user.name 'Auto Release Process' | ||
git config user.email '[email protected]' | ||
git remote set-url origin https://git:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }} | ||
- name: Bump version number | ||
run: ./publish ${{ github.event.inputs.action }} | ||
|
||
- name: Prep PR metadata | ||
run: | | ||
set -ex | ||
git fetch origin | ||
cur=$(./ci/print-current-version.sh) | ||
git commit --allow-empty -a -F-<<EOF | ||
Release ${{ github.event.repository.name }} $cur | ||
[automatically-tag-and-release-this-commit] | ||
EOF | ||
# Push the result to a branch and setup metadata for the step below | ||
# that creates a PR | ||
git push origin HEAD:ci/release-$cur | ||
echo "PR_HEAD=ci/release-$cur" >> $GITHUB_ENV | ||
echo "PR_TITLE=Release ${{ github.event.repository.name }} $cur" >> $GITHUB_ENV | ||
echo "PR_BASE=main" >> $GITHUB_ENV | ||
cat > pr-body <<-EOF | ||
This is an automated pull request from CI to release | ||
${{ github.event.repository.name }} $cur when merged. The commit | ||
message for this PR has a marker that is detected by CI to create | ||
tags and publish crate artifacts. | ||
When first opened this PR will not have CI run because it is generated | ||
by a bot. A maintainer should close this PR and then reopen it to | ||
trigger CI to execute which will then enable merging this PR. | ||
EOF | ||
- name: Make a PR | ||
run: gh pr create -B "$PR_BASE" -H "$PR_HEAD" --title "$PR_TITLE" --body "$(cat ./pr-body)" | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
/target | ||
publish | ||
tmp | ||
dist |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
#!/bin/sh | ||
grep '^version =' Cargo.toml | head -n 1 | sed 's/.*"\(.*\)"/\1/' |
Oops, something went wrong.