Skip to content

Commit c411bd7

Browse files
committed
init full wasm release workflow,manually set rustflags, change used
relay,rename pwa to wasm, fix build
1 parent 35b5b92 commit c411bd7

30 files changed

+78
-17
lines changed

.cargo/config.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[env]
22
# our dev nostr relay
3-
NOSTR_RELAY = "wss://bitcr-cloud-run-03-550030097098.europe-west1.run.app"
3+
NOSTR_RELAY = "wss://bitcr-cloud-run-04-550030097098.europe-west1.run.app"
44

55
# more detailed logs
66
RUST_LOG = "info"

.github/workflows/rust.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,9 @@ jobs:
4848
run: |
4949
curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh
5050
51-
- name: Build WASM for PWA
51+
- name: Build WASM version
5252
run: |
53-
cd crates/bcr-ebill-pwa
53+
cd crates/bcr-ebill-wasm
5454
wasm-pack build --target web
5555
5656
- name: Install required cargo

.github/workflows/wasm_release.yml

Lines changed: 67 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,23 @@ name: WASM Release
22

33
on:
44
workflow_dispatch:
5+
inputs:
6+
changelog:
7+
description: "Changelog (optional)"
8+
required: false
9+
default: ""
10+
11+
permissions:
12+
contents: write
13+
packages: write
514

615
jobs:
716
release:
817
name: WASM Release and Publish
918
runs-on: ubuntu-latest
1019

1120
# Restrict execution to specific users
12-
if: github.ref == 'refs/heads/master' && contains(["mtbitcr", "zupzup", "tompro"], github.actor)
13-
14-
permissions:
15-
contents: write
16-
packages: write
21+
if: contains(fromJson('["mtbitcr", "zupzup", "tompro"]'), github.actor)
1722

1823
steps:
1924
- name: Checkout repository
@@ -24,7 +29,7 @@ jobs:
2429
- name: Extract version from Cargo.toml
2530
id: get_version
2631
run: |
27-
VERSION=$(grep -m 1 '^version =' crates/bcr-ebill-pwa/Cargo.toml | cut -d '"' -f2)
32+
VERSION=$(grep -m 1 '^version =' crates/bcr-ebill-wasm/Cargo.toml | cut -d '"' -f2)
2833
echo "VERSION=$VERSION" >> $GITHUB_ENV
2934
echo "Detected version: v$VERSION"
3035
@@ -35,6 +40,62 @@ jobs:
3540
exit 1
3641
fi
3742
43+
- name: Install Node.js
44+
uses: actions/setup-node@v3
45+
with:
46+
node-version: 20
47+
registry-url: "https://registry.npmjs.org"
48+
49+
- name: Install Rust toolchain
50+
uses: actions-rust-lang/setup-rust-toolchain@v1
51+
with:
52+
toolchain: 1.85.0
53+
3854
- name: Install wasm-pack
3955
run: |
4056
curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh
57+
58+
- name: Build with wasm-pack
59+
env:
60+
RUSTFLAGS: '--cfg getrandom_backend="wasm_js"'
61+
run: |
62+
cd crates/bcr-ebill-wasm
63+
wasm-pack build --target web --scope bitcredit --out-name index
64+
65+
- name: Create and push git tag
66+
run: |
67+
git config user.name "github-actions[bot]"
68+
git config user.email "github-actions[bot]@users.noreply.github.com"
69+
git tag "v${{ env.VERSION }}"
70+
git push origin "v${{ env.VERSION }}"
71+
72+
- name: Create GitHub Release
73+
uses: softprops/action-gh-release@v2
74+
with:
75+
tag_name: v${{ env.VERSION }}
76+
name: Release v${{ env.VERSION }}
77+
body: |
78+
${{ inputs.changelog }}
79+
80+
**Version:** v${{ env.VERSION }}
81+
draft: false
82+
prerelease: false
83+
84+
- name: Upload WASM artifacts to Release
85+
env:
86+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
87+
run: |
88+
cd crates/bcr-ebill-wasm/pkg
89+
for file in *; do
90+
if [[ "$file" != ".gitignore" ]]; then
91+
gh release upload "v${{ env.VERSION }}" "$file"
92+
fi
93+
done
94+
95+
- name: Publish to npm
96+
env:
97+
NODE_AUTH_TOKEN: ${{ secrets.NPM_SECRET }}
98+
run: |
99+
cd crates/bcr-ebill-wasm/pkg
100+
npm publish --access public
101+

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[workspace]
22
resolver = "3"
3-
members = [ "crates/bcr-ebill-web", "crates/bcr-ebill-core", "crates/bcr-ebill-api", "crates/bcr-ebill-persistence" , "crates/bcr-ebill-transport", "crates/bcr-ebill-pwa"]
3+
members = [ "crates/bcr-ebill-web", "crates/bcr-ebill-core", "crates/bcr-ebill-api", "crates/bcr-ebill-persistence" , "crates/bcr-ebill-transport", "crates/bcr-ebill-wasm"]
44

55

66
[workspace.dependencies]

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ The project consists of the following crates:
1111
* `bcr-ebill-transport` - network transport traits and Nostr implementation
1212
* `bcr-ebill-api` - API of the E-Bills project, contains most of the business logic
1313
* `bcr-ebill-web` - Entrypoint for Web applications using the Rocket web server
14-
* `bcr-ebill-pwa` - Entrypoint for WASM-based Progress Web Apps
14+
* `bcr-ebill-wasm` - Entrypoint for WASM version of the E-Bill API
1515

1616
### Entrypoints
1717

File renamed without changes.

crates/bcr-ebill-pwa/Cargo.toml renamed to crates/bcr-ebill-wasm/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[package]
2-
name = "bcr-ebill-pwa"
2+
name = "bcr-ebill-wasm"
33
version = "0.3.0"
44
edition = "2024"
55

File renamed without changes.

crates/bcr-ebill-pwa/main.js renamed to crates/bcr-ebill-wasm/main.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import * as wasm from '../pkg/bcr_ebill_pwa.js';
1+
import * as wasm from '../pkg/bcr_ebill_wasm.js';
22

33
document.getElementById("fileInput").addEventListener("change", uploadFile);
44
document.getElementById("notif").addEventListener("click", triggerNotif);
File renamed without changes.

0 commit comments

Comments
 (0)