Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(hackathon): build and publish a wasm web build #94

Merged
merged 6 commits into from
Nov 13, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
build and publish a wasm web build
Samuel-B-D committed Nov 13, 2024
commit 2985d2bb062c8f200a1afb6c060bd4e1530c1c6d
72 changes: 63 additions & 9 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -24,7 +24,12 @@ on:
required: true
type: boolean
wasm:
description: Publish a wasm version (npmjs)
description: Publish a wasm (bundler) version (npmjs)
default: true
required: true
type: boolean
wasm_web:
description: Publish a wasm (web) version (npmjs)
default: true
required: true
type: boolean
@@ -67,10 +72,6 @@ jobs:
with:
github_token: ${{ secrets.DEVOLUTIONSBOT_WRITE_TOKEN }}

- name: Publish
run: npm publish --tag ${{ inputs.beta && 'beta' || 'latest' }}
working-directory: dist/bundler

- run: rm $HOME/.npmrc

- name: Configure NPM
@@ -80,10 +81,63 @@ jobs:
run: npm publish --tag ${{ inputs.beta && 'beta' || 'latest' }}
working-directory: dist/bundler

- name: Update Artifactory Cache
run: gh workflow run update-artifactory-cache.yml --repo Devolutions/scheduled-tasks --field package_name="slauth"
env:
GH_TOKEN: ${{ secrets.DEVOLUTIONSBOT_WRITE_TOKEN }}
build-wasm-web:
environment: npm-publish
if: ${{ inputs.wasm_web }}
runs-on: ubuntu-latest

steps:
- name: Checkout repo
uses: actions/checkout@v4

- name: Checkout action
uses: actions/checkout@v4
with:
repository: Devolutions/actions
path: actions
ref: v2
token: ${{ secrets.DEVOLUTIONSBOT_WRITE_TOKEN }}

- name: Setup wasm
run: |
curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh
wasm-pack --version

- name: Build
run: sh build-web.sh
working-directory: wrappers/wasm

- name: Upload artifact
uses: actions/upload-artifact@v4.3.6
with:
name: wasm-web
path: dist/web

- name: Setup .npmrc config file
uses: ./actions/npmrc-setup
with:
github_token: ${{ secrets.DEVOLUTIONSBOT_WRITE_TOKEN }}

- run: rm $HOME/.npmrc

- name: Configure NPM
run: npm config set "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}"

- name: Publish
run: npm publish --tag ${{ inputs.beta && 'beta' || 'latest' }}
working-directory: dist/web

update-artifactory-cache:
environment: npm-publish
if: ${{ !failure() && !cancelled() && (inputs.wasm || inputs.wasm_web) }}
runs-on: ubuntu-latest
needs: [build-wasm, build-wasm-web]

steps:
- name: Update Artifactory Cache
run: gh workflow run update-artifactory-cache.yml --repo Devolutions/scheduled-tasks --field package_name="slauth"
env:
GH_TOKEN: ${{ secrets.DEVOLUTIONSBOT_WRITE_TOKEN }}

build-android:
environment: cloudsmith-publish
13 changes: 13 additions & 0 deletions wrappers/wasm/build-web.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/bash

# https://stackoverflow.com/a/246128/1775923
SOURCE=${BASH_SOURCE[0]}
while [ -L "$SOURCE" ]; do
DIR=$( cd -P "$( dirname "$SOURCE" )" >/dev/null 2>&1 && pwd )
SOURCE=$(readlink "$SOURCE")
[[ $SOURCE != /* ]] && SOURCE=$DIR/$SOURCE
done
DIR=$( cd -P "$( dirname "$SOURCE" )" >/dev/null 2>&1 && pwd )

wasm-pack build --scope devolutions --out-dir ./dist/web --target web -- --no-default-features --features "webauthn"
sed -i 's/"@devolutions\/slauth"/"@devolutions\/slauth-web"/' ${DIR}/../../dist/web/package.json