Fix tests and lints for new version of Rust (#848) #552
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
# One approach to testing changes to the asset upload to release process is to: | |
# 1. Fork this repo to your personal account | |
# 2. Go into the repo settings on your fork, go to _Actions_, go to _General_, under _Workflow permissions_, select _Read and Write permissions_, then _Save_ | |
# 3. Add your fork as a new remote and push your branch to it | |
# 4. Publish a release in your personal fork with the target of the release set to the branch with your changes | |
# 5. Confirm the workflow completes and that assets are attached to the release as expected | |
name: Build Assets | |
on: | |
# Build and attach assets to any published releases | |
release: | |
types: | |
- published | |
# Test on main | |
push: | |
branches: | |
- main | |
jobs: | |
compile_plugin: | |
name: compile_plugin | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Read wizer version | |
id: wizer_version | |
shell: bash | |
run: | | |
VERSION=$(cargo metadata --format-version=1 --locked | jq '.packages[] | select(.name == "wizer") | .version' -r) | |
echo "WIZER_VERSION=$VERSION" >> $GITHUB_OUTPUT | |
- name: Install wizer | |
shell: bash | |
run: | | |
wget -nv https://github.com/bytecodealliance/wizer/releases/download/v${{ steps.wizer_version.outputs.WIZER_VERSION }}/wizer-v${{ steps.wizer_version.outputs.WIZER_VERSION }}-x86_64-linux.tar.xz -O /tmp/wizer.tar.xz | |
mkdir /tmp/wizer | |
tar xvf /tmp/wizer.tar.xz --strip-components=1 -C /tmp/wizer | |
echo "/tmp/wizer" >> $GITHUB_PATH | |
- name: Make plugin | |
run: make plugin | |
- name: Upload plugin to artifacts | |
uses: actions/upload-artifact@v4 | |
with: | |
name: plugin | |
path: target/wasm32-wasip1/release/plugin.wasm | |
- name: Wizen and archive wizened plugin | |
run: | | |
wizer target/wasm32-wasip1/release/plugin.wasm --allow-wasi --init-func initialize_runtime --wasm-bulk-memory true -o target/wasm32-wasip1/release/plugin_wizened.wasm | |
gzip -k -f target/wasm32-wasip1/release/plugin_wizened.wasm && mv target/wasm32-wasip1/release/plugin_wizened.wasm.gz plugin.wasm.gz | |
- name: Upload archived plugin to artifacts | |
uses: actions/upload-artifact@v4 | |
with: | |
name: plugin.wasm.gz | |
path: plugin.wasm.gz | |
- name: Upload archived plugin to release | |
if: github.event_name == 'release' | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: gh release upload ${{ github.event.release.tag_name }} plugin.wasm.gz | |
- name: Generate archived plugin hash | |
run: shasum -a 256 plugin.wasm.gz | awk '{ print $1 }' > plugin.wasm.gz.sha256 | |
- name: Upload asset hash to artifacts | |
uses: actions/upload-artifact@v4 | |
with: | |
name: plugin.wasm.gz.sha256 | |
path: plugin.wasm.gz.sha256 | |
- name: Upload asset hash to release | |
if: github.event_name == 'release' | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: gh release upload ${{ github.event.release.tag_name }} plugin.wasm.gz.sha256 | |
compile_cli: | |
name: compile_cli-${{ matrix.name }} | |
needs: compile_plugin | |
runs-on: ${{ matrix.os }} | |
strategy: | |
matrix: | |
include: | |
- name: linux | |
os: ubuntu-20.04 # Use oldest supported non-deprecated version so we link against older glibc version which allows running binary on a wider set of Linux systems | |
path: target/x86_64-unknown-linux-gnu/release/javy | |
asset_name: javy-x86_64-linux-${{ github.event.release.tag_name }} | |
shasum_cmd: sha256sum | |
target: x86_64-unknown-linux-gnu | |
- name: linux-arm64 | |
os: ubuntu-20.04 # Use oldest supported non-deprecated version so we link against older glibc version which allows running binary on a wider set of Linux systems | |
path: target/aarch64-unknown-linux-gnu/release/javy | |
asset_name: javy-arm-linux-${{ github.event.release.tag_name }} | |
shasum_cmd: sha256sum | |
target: aarch64-unknown-linux-gnu | |
- name: macos | |
os: macos-latest | |
path: target/x86_64-apple-darwin/release/javy | |
asset_name: javy-x86_64-macos-${{ github.event.release.tag_name }} | |
shasum_cmd: shasum -a 256 | |
target: x86_64-apple-darwin | |
- name: macos-arm64 | |
os: macos-latest | |
path: target/aarch64-apple-darwin/release/javy | |
asset_name: javy-arm-macos-${{ github.event.release.tag_name }} | |
shasum_cmd: shasum -a 256 | |
target: aarch64-apple-darwin | |
- name: windows | |
os: windows-latest | |
path: target\x86_64-pc-windows-msvc\release\javy.exe | |
asset_name: javy-x86_64-windows-${{ github.event.release.tag_name }} | |
shasum_cmd: sha256sum | |
target: x86_64-pc-windows-msvc | |
steps: | |
- uses: actions/checkout@v4 | |
# Should no-op except for macos-arm and linux-arm cases where that target won't be installed | |
- name: Install target | |
run: rustup target add ${{ matrix.target }} | |
# wasmtime-fiber and binaryen fail to compile without this | |
- name: Install Aarch64 GCC toolchain | |
run: sudo apt-get update && sudo apt-get --assume-yes install gcc-aarch64-linux-gnu g++-aarch64-linux-gnu | |
if: matrix.target == 'aarch64-unknown-linux-gnu' | |
- uses: actions/download-artifact@v4 | |
with: | |
name: plugin | |
path: target/wasm32-wasip1/release/ | |
- name: Build CLI ${{ matrix.os }} | |
run: cargo build --release --target ${{ matrix.target }} --package javy-cli | |
env: | |
CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER: aarch64-linux-gnu-gcc | |
- name: Archive assets | |
run: gzip -k -f ${{ matrix.path }} && mv ${{ matrix.path }}.gz ${{ matrix.asset_name }}.gz | |
- name: Upload assets to artifacts | |
uses: actions/upload-artifact@v4 | |
with: | |
name: ${{ matrix.asset_name }}.gz | |
path: ${{ matrix.asset_name }}.gz | |
- name: Upload assets to release | |
if: github.event_name == 'release' | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: gh release upload ${{ github.event.release.tag_name }} ${{ matrix.asset_name }}.gz | |
- name: Generate asset hash | |
run: ${{ matrix.shasum_cmd }} ${{ matrix.asset_name }}.gz | awk '{ print $1 }' > ${{ matrix.asset_name }}.gz.sha256 | |
- name: Upload asset hash to artifacts | |
uses: actions/upload-artifact@v4 | |
with: | |
name: ${{ matrix.asset_name }}.gz.sha256 | |
path: ${{ matrix.asset_name }}.gz.sha256 | |
- name: Upload asset hash to release | |
if: github.event_name == 'release' | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: gh release upload ${{ github.event.release.tag_name }} ${{ matrix.asset_name }}.gz.sha256 |