Skip to content

Commit 4622ea6

Browse files
authored
Prepare CI/automation for releasing (#498)
* Rename `wit-bindgen-gen-guest-rust` to `wit-bindgen` This commit creates a crate called `wit-bindgen` to be used from Rust. While the name `wit-bindgen-gen-guest-rust` makes sense in the context of other generators when using it specifically from Rust I think it makes more sense to have the crate simply called `wit-bindgen` for integration since the only context that name is used within is guest bindings generator for Rust code. * Add release CI automation for `wit-bindgen` This is cobbled together from the `wasm-tools` and `wasmtime` repositories and the idea is: * A `publish.rs` script is added for managing versions and publication to crates.io. * Tags will upload binaries to GitHub releases * CI is added for binary release builds of the CLI * Fix copy/paste error
1 parent ef00821 commit 4622ea6

File tree

33 files changed

+570
-71
lines changed

33 files changed

+570
-71
lines changed

.github/workflows/build.yml

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
name: Build
2+
on:
3+
push:
4+
tags:
5+
pull_request:
6+
branches:
7+
- main
8+
9+
defaults:
10+
run:
11+
shell: bash
12+
13+
concurrency:
14+
group: ${{ github.workflow }}-${{ github.ref }}
15+
cancel-in-progress: true
16+
17+
permissions:
18+
contents: write
19+
20+
jobs:
21+
build:
22+
name: Build wit-bindgen
23+
runs-on: ${{ matrix.os }}
24+
if: github.event_name != 'push' || startsWith(github.ref, 'refs/tags/wit-bindgen-cli-')
25+
strategy:
26+
matrix:
27+
include:
28+
- build: x86_64-linux
29+
os: ubuntu-latest
30+
- build: x86_64-macos
31+
os: macos-latest
32+
- build: aarch64-macos
33+
os: macos-latest
34+
target: aarch64-apple-darwin
35+
- build: x86_64-windows
36+
os: windows-latest
37+
- build: aarch64-linux
38+
os: ubuntu-latest
39+
target: aarch64-unknown-linux-gnu
40+
steps:
41+
- uses: actions/checkout@v3
42+
with:
43+
submodules: true
44+
- run: rustup update stable --no-self-update && rustup default stable
45+
- uses: bytecodealliance/wasmtime/.github/actions/[email protected]
46+
with:
47+
name: ${{ matrix.build }}
48+
- run: |
49+
echo CARGO_BUILD_TARGET=${{ matrix.target }} >> $GITHUB_ENV
50+
rustup target add ${{ matrix.target }}
51+
if: matrix.target != ''
52+
- run: $CENTOS cargo build --release
53+
- run: ./ci/build-tarballs.sh "${{ matrix.build }}" "${{ matrix.target }}"
54+
- uses: actions/upload-artifact@v3
55+
with:
56+
name: bins-${{ matrix.build }}
57+
path: dist
58+
59+
- uses: softprops/action-gh-release@v1
60+
if: startsWith(github.ref, 'refs/tags/') && github.repository == 'bytecodealliance/wit-bindgen'
61+
with:
62+
files: "dist/*"

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
target/
2+
publish
23
static
34
package-lock.json
45
node_modules

Cargo.lock

Lines changed: 14 additions & 14 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 & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "wit-bindgen-cli"
33
authors = ["Alex Crichton <[email protected]>"]
4-
version.workspace = true
4+
version = "0.3.0"
55
edition.workspace = true
66

77
[workspace]
@@ -13,7 +13,6 @@ resolver = "2"
1313

1414
[workspace.package]
1515
edition = "2021"
16-
version = "0.3.0"
1716

1817
[workspace.dependencies]
1918
anyhow = "1.0.65"
@@ -35,7 +34,7 @@ wit-bindgen-gen-guest-rust = { path = "crates/gen-guest-rust", version = "0.3.0"
3534
wit-bindgen-gen-guest-teavm-java = { path = 'crates/gen-guest-teavm-java', version = '0.3.0' }
3635
wit-bindgen-gen-markdown = { path = 'crates/gen-markdown', version = '0.3.0' }
3736
wit-bindgen-gen-rust-lib = { path = 'crates/gen-rust-lib', version = '0.3.0' }
38-
wit-bindgen-guest-rust = { path = 'crates/guest-rust', version = '0.3.0', default-features = false }
37+
wit-bindgen = { path = 'crates/guest-rust', version = '0.3.0', default-features = false }
3938
wit-bindgen-rust-macro-shared = { path = 'crates/rust-macro-shared', version = '0.3.0' }
4039

4140
[[bin]]

ci/build-tarballs.sh

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
#!/bin/bash
2+
3+
set -ex
4+
5+
platform=$1
6+
target=$2
7+
8+
rm -rf tmp
9+
mkdir tmp
10+
mkdir -p dist
11+
12+
tag=dev
13+
if [[ $GITHUB_REF == refs/tags/wit-bindgen-cli-* ]]; then
14+
tag=v${GITHUB_REF:26}
15+
fi
16+
17+
bin_pkgname=wit-bindgen-$tag-$platform
18+
19+
mkdir tmp/$bin_pkgname
20+
cp LICENSE README.md tmp/$bin_pkgname
21+
22+
fmt=tar
23+
if [ "$platform" = "x86_64-windows" ]; then
24+
cp target/release/wit-bindgen.exe tmp/$bin_pkgname
25+
fmt=zip
26+
elif [ "$target" = "" ]; then
27+
cp target/release/wit-bindgen tmp/$bin_pkgname
28+
else
29+
cp target/$target/release/wit-bindgen tmp/$bin_pkgname
30+
fi
31+
32+
33+
mktarball() {
34+
dir=$1
35+
if [ "$fmt" = "tar" ]; then
36+
tar czvf dist/$dir.tar.gz -C tmp $dir
37+
else
38+
# Note that this runs on Windows, and it looks like GitHub Actions doesn't
39+
# have a `zip` tool there, so we use something else
40+
(cd tmp && 7z a ../dist/$dir.zip $dir/)
41+
fi
42+
}
43+
44+
mktarball $bin_pkgname

ci/docker/aarch64-linux/Dockerfile

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
FROM ubuntu:16.04
2+
3+
RUN apt-get update -y && apt-get install -y gcc gcc-aarch64-linux-gnu ca-certificates git
4+
5+
ENV PATH=$PATH:/rust/bin
6+
ENV CARGO_BUILD_TARGET=aarch64-unknown-linux-gnu
7+
ENV CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=aarch64-linux-gnu-gcc

ci/docker/x86_64-linux/Dockerfile

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
FROM centos:7
2+
3+
RUN yum install -y git gcc
4+
5+
ENV PATH=$PATH:/rust/bin

0 commit comments

Comments
 (0)