-
Notifications
You must be signed in to change notification settings - Fork 0
92 lines (78 loc) · 2.59 KB
/
build-plugin.yml
File metadata and controls
92 lines (78 loc) · 2.59 KB
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
name: Build Plugin
on:
push:
branches: [main]
tags: ['v*']
pull_request:
workflow_dispatch:
permissions:
contents: write
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Install Rust toolchain (wasm32-wasip1)
uses: dtolnay/rust-toolchain@v1
with:
toolchain: stable
targets: wasm32-wasip1
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: 20
- name: Determine plugin metadata
run: |
set -eux
PLUGIN_ID=$(jq -r '.id' plugin.json)
PLUGIN_VERSION=$(jq -r '.version' plugin.json)
echo "PLUGIN_ID=$PLUGIN_ID" >> "$GITHUB_ENV"
echo "PLUGIN_VERSION=$PLUGIN_VERSION" >> "$GITHUB_ENV"
echo "PLUGIN_ZIP=${PLUGIN_ID}-plugin.zip" >> "$GITHUB_ENV"
- name: Install frontend deps
run: npm ci || npm i --no-audit --no-fund
working-directory: frontend
- name: Build frontend bundle
run: npm run build
working-directory: frontend
- name: Build backend wasm
run: cargo build --release --target wasm32-wasip1
working-directory: backend
- name: Package plugin assets
run: |
set -eux
DIST=dist
rm -rf "$DIST"
mkdir -p "$DIST/backend"
WASM=$(find backend/target/wasm32-wasip1/release -maxdepth 1 -name '*.wasm' | head -n1)
cp "$WASM" "$DIST/backend/plugin.wasm"
cp frontend/dist/index.mjs "$DIST/index.mjs"
cp plugin.json "$DIST/plugin.json"
(cd "$DIST" && zip -r "../${PLUGIN_ZIP}" .)
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: ${{ env.PLUGIN_ID }}-plugin
path: ${{ env.PLUGIN_ZIP }}
- name: Create release
if: startsWith(github.ref, 'refs/tags/')
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref_name }}
release_name: ${{ github.ref_name }}
draft: false
prerelease: false
- name: Upload release asset
if: startsWith(github.ref, 'refs/tags/')
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ${{ env.PLUGIN_ZIP }}
asset_name: ${{ env.PLUGIN_ZIP }}
asset_content_type: application/zip