ci: install rustfmt for rust toolchain (#371) #10
Workflow file for this run
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
name: Wasm FDW Release | |
on: | |
push: | |
tags: | |
- 'wasm_*_fdw_v[0-9]+.[0-9]+.[0-9]+' # Push events to matching wasm fdw tag, i.e. wasm_snowflake_fdw_v1.0.2 | |
permissions: | |
contents: write | |
jobs: | |
release: | |
name: Create Wasm FDW Release | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Extract project and version from tag | |
id: extract_info | |
env: | |
TAG: ${{ github.ref_name }} | |
run: | | |
PROJECT=`echo "${TAG}" | sed -E 's/wasm_(.*_fdw)_v.*/\1/'` | |
VERSION=`echo "${TAG}" | sed -E 's/wasm_.*_fdw_v(.*)/\1/'` | |
echo "PROJECT=$PROJECT" >> "$GITHUB_OUTPUT" | |
echo "VERSION=$VERSION" >> "$GITHUB_OUTPUT" | |
- name: Set up Rust | |
run: | | |
# install Rust | |
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --no-modify-path --profile minimal --default-toolchain 1.81.0 && \ | |
rustup --version && \ | |
rustc --version && \ | |
cargo --version | |
# add wasm32-unknown-unknown target | |
rustup target add wasm32-unknown-unknown | |
# install Wasm component | |
cargo install cargo-component --version 0.13.2 | |
# install rustfmt for the toolchain | |
rustup component add rustfmt | |
# show all installed packagies | |
cargo install --list | |
- name: Build Wasm FDW | |
run: | | |
cd wasm-wrappers/fdw/${{ steps.extract_info.outputs.PROJECT }} | |
cargo component build --release --target wasm32-unknown-unknown | |
- name: Calculate Wasm file checksum | |
uses: jmgilman/actions-generate-checksum@v1 | |
with: | |
method: sha256 | |
output: wasm-wrappers/fdw/${{ steps.extract_info.outputs.PROJECT }}/checksum.txt | |
patterns: | | |
./wasm-wrappers/fdw/${{ steps.extract_info.outputs.PROJECT }}/target/wasm32-unknown-unknown/release/*.wasm | |
- name: Get project metadata JSON | |
id: metadata | |
run: | | |
cd wasm-wrappers/fdw/${{ steps.extract_info.outputs.PROJECT }} | |
METADATA_JSON=`cargo metadata --format-version 1 --no-deps --offline` | |
echo "METADATA_JSON=$METADATA_JSON" >> "$GITHUB_OUTPUT" | |
- name: Extract package info | |
id: extract | |
run: | | |
cd wasm-wrappers/fdw/${{ steps.extract_info.outputs.PROJECT }} | |
PACKAGE="${{ fromJson(steps.metadata.outputs.METADATA_JSON).packages[0].metadata.component.package }}" | |
CHECKSUM=`head -1 checksum.txt | sed -E 's/^(.*) .*/\1/'` | |
echo "PACKAGE=$PACKAGE" >> "$GITHUB_OUTPUT" | |
echo "CHECKSUM=$CHECKSUM" >> "$GITHUB_OUTPUT" | |
- name: Create README.txt | |
env: | |
TAG: ${{ github.ref_name }} | |
PROJECT: ${{ steps.extract_info.outputs.PROJECT }} | |
VERSION: ${{ steps.extract_info.outputs.VERSION }} | |
PACKAGE: ${{ steps.extract.outputs.PACKAGE }} | |
CHECKSUM: ${{ steps.extract.outputs.CHECKSUM }} | |
run: | | |
cd wasm-wrappers/fdw/${{ steps.extract_info.outputs.PROJECT }} | |
cat > README.txt <<EOF | |
To use this Wasm foreign data wrapper on Supabase, create a foreign server like below, | |
create extension if not exists wrappers with schema extensions; | |
create foreign data wrapper wasm_wrapper | |
handler wasm_fdw_handler | |
validator wasm_fdw_validator; | |
create server example_server | |
foreign data wrapper wasm_wrapper | |
options ( | |
fdw_package_url 'https://github.com/supabase/wrappers/releases/download/${TAG}/${PROJECT}.wasm', | |
fdw_package_name '${PACKAGE}', | |
fdw_package_version '${VERSION}', | |
fdw_package_checksum '${CHECKSUM}', | |
... | |
); | |
For more details, please visit https://fdw.dev. | |
EOF | |
- name: Create release | |
id: create_release | |
uses: softprops/action-gh-release@v2 | |
with: | |
generate_release_notes: true | |
make_latest: true | |
files: | | |
./wasm-wrappers/fdw/${{ steps.extract_info.outputs.PROJECT }}/README.txt | |
./wasm-wrappers/fdw/${{ steps.extract_info.outputs.PROJECT }}/checksum.txt | |
./wasm-wrappers/fdw/${{ steps.extract_info.outputs.PROJECT }}/target/wasm32-unknown-unknown/release/*.wasm | |