Skip to content

Commit 83929b3

Browse files
committed
feat: add ci workflow
1 parent 530ba98 commit 83929b3

File tree

4 files changed

+107
-4965
lines changed

4 files changed

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

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ target/
88
*.a
99
*.swp
1010
*.log
11-
site/
1211
.bash_history
1312
.config/
1413
cmake*/
1514
.direnv
15+
src/bindings.rs

README.md

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,6 @@ This project is a normal Rust library project, so we will assume you have instal
2828

2929
The package source code, we will implement the `Guest` trait, which contains the FDW logic, in this file.
3030

31-
- src/bindings.rs
32-
33-
Wasm package bindings file which is generated by the Component Model, we don't need to change it.
34-
3531
- supabase-wrappers-wit/
3632

3733
The [Wasm Interface Type](https://github.com/bytecodealliance/wit-bindgen) (WIT) provided by Supabase, it defines the interfaces between the Wasm FDW (guest) and the Wasm runtime (host). For example, the `http.wit` defines the HTTP related types and functions can be used in the guest, and the `routines.wit` defines the functions the guest needs to implement.
@@ -86,7 +82,7 @@ This will build the Wasm file in `target/wasm32-unknown-unknown/release/wasm_fdw
8682

8783
## Use this example foreign data wrapper on Supabase platform
8884

89-
To use our own Wasm FDW on Supabase platform, make sure the Wrappers extension version is `>=0.4.2`. Go to `SQL Editor` in Supabase Studio and run below query to check its version:
85+
To use our own Wasm FDW on Supabase platform, make sure the Wrappers extension version is `>=0.4.1`. Go to `SQL Editor` in Supabase Studio and run below query to check its version:
9086

9187
```sql
9288
SELECT * FROM pg_available_extension_versions WHERE name = 'wrappers';
@@ -102,16 +98,18 @@ create foreign data wrapper wasm_wrapper
10298
validator wasm_fdw_validator;
10399
```
104100

105-
Create foreign server and foreign table:
101+
Create foreign server and foreign table like below,
106102

107103
```sql
108104
create server example_server
109105
foreign data wrapper wasm_wrapper
110106
options (
111-
-- change the url to your Wasm package url
112-
fdw_package_url 'https://github.com/supabase/wasm-fdw-example/releases/download/wasm_fdw_example_v0.1.0/wasm_fdw_example.wasm',
107+
-- change below fdw_pacakge_* options accordingly
108+
-- check available releases at https://github.com/supabase-community/wasm-fdw-example/releases
109+
fdw_package_url 'https://github.com/supabase-community/wasm-fdw-example/releases/download/v0.1.0/wasm_fdw_example.wasm',
113110
fdw_package_name 'my-company:example-fdw',
114111
fdw_package_version '0.1.0',
112+
fdw_package_checksum '7d0b902440ac2ef1af85d09807145247f14d1d8fd4d700227e5a4d84c8145409',
115113
api_url 'https://api.github.com'
116114
);
117115

@@ -189,6 +187,10 @@ lto = true
189187
cargo component build --release --target wasm32-unknown-unknown
190188
```
191189

190+
### Automation
191+
192+
If you host the project source code on GitHub, the building and release process can be automated, take a look at the `.github/workflow/release_wasm_fdw.yml` file to see an example.
193+
192194
## More Wasm foreign data wrapper projects
193195

194196
There are some other Wasm foreign data wrapper projects developed by Supabase team, you can check them out to see more examples.

0 commit comments

Comments
 (0)