-
Notifications
You must be signed in to change notification settings - Fork 15
96 lines (80 loc) · 3.08 KB
/
release_wasm_fdw.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
name: Release
on:
push:
tags:
- 'v[0-9]+.[0-9]+.[0-9]+' # Push events to matching wasm fdw tag, i.e. 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: 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 stable && \
rustup --version && \
rustc --version && \
cargo --version
# add wasm32-unknown-unknown target
rustup target add wasm32-unknown-unknown
# install Wasm component
cargo install cargo-component --locked
- name: Build Wasm FDW
run: |
cargo component build --release --target wasm32-unknown-unknown
- name: Calculate Wasm file checksum
uses: jmgilman/actions-generate-checksum@v1
with:
method: sha256
output: checksum.txt
patterns: |
./target/wasm32-unknown-unknown/release/*.wasm
- name: Get project metadata JSON
id: metadata
run: |
METADATA_JSON=`cargo metadata --format-version 1 --no-deps --offline`
echo "METADATA_JSON=$METADATA_JSON" >> "$GITHUB_OUTPUT"
- name: Extract package info
id: extract
env:
TAG: ${{ github.ref_name }}
run: |
PACKAGE="${{ fromJson(steps.metadata.outputs.METADATA_JSON).packages[0].metadata.component.package }}"
VERSION=`echo "${TAG}" | sed -E 's/v(.*)/\1/'`
CHECKSUM=`head -1 checksum.txt | sed -E 's/^(.*) .*/\1/'`
echo "PACKAGE=$PACKAGE" >> "$GITHUB_OUTPUT"
echo "VERSION=$VERSION" >> "$GITHUB_OUTPUT"
echo "CHECKSUM=$CHECKSUM" >> "$GITHUB_OUTPUT"
- name: Create README.txt
env:
PACKAGE: ${{ steps.extract.outputs.PACKAGE }}
VERSION: ${{ steps.extract.outputs.VERSION }}
CHECKSUM: ${{ steps.extract.outputs.CHECKSUM }}
run: |
cat > README.txt <<EOF
To use this Wasm foreign data wrapper on Supabase, create a foreign server like below,
create server example_server
foreign data wrapper wasm_wrapper
options (
fdw_package_url 'https://github.com/supabase-community/wasm-fdw-example/releases/download/v${VERSION}/wasm_fdw_example.wasm',
fdw_package_name '${PACKAGE}',
fdw_package_version '${VERSION}',
fdw_package_checksum '${CHECKSUM}',
api_url 'https://api.github.com'
);
For more detials, please visit https://github.com/supabase-community/wasm-fdw-example.
EOF
- name: Create release
id: create_release
uses: softprops/action-gh-release@v2
with:
generate_release_notes: true
make_latest: true
files: |
README.txt
checksum.txt
./target/wasm32-unknown-unknown/release/*.wasm