Skip to content

Commit 94634d3

Browse files
authored
Merge pull request #3 from supabase-community/bo/feat/ci
ci: add ci workflow
2 parents 2f50b8b + f9ca628 commit 94634d3

File tree

4 files changed

+108
-4962
lines changed

4 files changed

+108
-4962
lines changed
+96
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

+1-1
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

+11-5
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ This example reads the [realtime GitHub events](https://api.github.com/events) i
99

1010
```bash
1111
├── src
12-
│   ├── bindings.rs # Wasm package bindings file which is generated by the Component Model, we don't need to change it.
1312
│   └── lib.rs # The package source code. We will implement the FDW logic, in this file.
1413
├── supabase-wrappers-wit # The Wasm Interface Type provided by Supabase. See below for a detailed description.
1514
│   ├── http.wit
@@ -95,7 +94,7 @@ This will build the Wasm file in `target/wasm32-unknown-unknown/release/wasm_fdw
9594

9695
## Use with Supabase
9796

98-
You can use your Wasm FDW on the Supabase platform as long as the Wrappers extension version is `>=0.4.2`.
97+
You can use your Wasm FDW on the Supabase platform as long as the Wrappers extension version is `>=0.4.1`.
9998

10099
### Checking Wrappers version
101100

@@ -119,16 +118,18 @@ create foreign data wrapper wasm_wrapper
119118
validator wasm_fdw_validator;
120119
```
121120

122-
Create foreign server and foreign table:
121+
Create foreign server and foreign table like below,
123122

124123
```sql
125124
create server example_server
126125
foreign data wrapper wasm_wrapper
127126
options (
128-
-- change the url to your Wasm package url
129-
fdw_package_url 'https://github.com/supabase/wasm-fdw-example/releases/download/wasm_fdw_example_v0.1.0/wasm_fdw_example.wasm',
127+
-- change below fdw_pacakge_* options accordingly
128+
-- check available releases at https://github.com/supabase-community/wasm-fdw-example/releases
129+
fdw_package_url 'https://github.com/supabase-community/wasm-fdw-example/releases/download/v0.1.0/wasm_fdw_example.wasm',
130130
fdw_package_name 'my-company:example-fdw',
131131
fdw_package_version '0.1.0',
132+
fdw_package_checksum '7d0b902440ac2ef1af85d09807145247f14d1d8fd4d700227e5a4d84c8145409',
132133
api_url 'https://api.github.com'
133134
);
134135

@@ -206,6 +207,11 @@ lto = true
206207
cargo component build --release --target wasm32-unknown-unknown
207208
```
208209

210+
### Automation
211+
212+
If you host 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 of CI workflow.
213+
214+
209215
## Other examples
210216

211217
Some other Wasm foreign data wrapper projects developed by Supabase team:

0 commit comments

Comments
 (0)