Update build.yml #62
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This workflow will do a clean installation of node dependencies, cache/restore them, build the source code and run tests across different versions of node | |
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions | |
name: WebAssembly Playgound CI | |
on: | |
push: | |
branches: [ "main" ] | |
tags: [ "v*" ] | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
submodules: true | |
- name: Install Rust toolchain | |
uses: actions-rs/toolchain@v1 | |
with: | |
toolchain: 1.76.0 | |
override: true | |
- uses: Swatinem/rust-cache@v2 | |
- name: Setup Rust tools | |
run: cargo install wasm-pack | |
- name: Use Node.js 16.x | |
uses: actions/setup-node@v3 | |
with: | |
node-version: 16.x | |
cache: 'npm' | |
- run: npm install | |
- run: npm run build | |
- run: npx tsc -p src | |
- if: ${{ contains(github.ref, 'tags/v') }} | |
run: node build/dist/main.js --release | |
- if: ${{ !contains(github.ref, 'tags/v') }} | |
run: node build/dist/main.js | |
- name: Save App Bundle | |
uses: actions/upload-artifact@v2 | |
with: | |
name: wasm-playground-app-bundle | |
path: dist | |
deploy-development: | |
needs: [ build ] | |
if: ${{ !contains(github.ref, 'tags/v') }} | |
runs-on: ubuntu-latest | |
steps: | |
- run: mkdir dev | |
- name: Restore Bundles | |
uses: actions/download-artifact@v2 | |
with: | |
name: wasm-playground-app-bundle | |
path: dev | |
- run: | | |
sed -i -e "s|wasm-playground.kamenokosoft.com|wasm-playground.kamenokosoft.com/dev|g" dev/index.html | |
sed -i -e "s|wasm-playground.kamenokosoft.com|wasm-playground.kamenokosoft.com/dev|g" dev/config.js | |
sed -i -e "s|https://wasm-playground.kamenokosoft.com/callback|https://wasm-playground.kamenokosoft.com/dev/callback|g" dev/extensions/github-authentication/dist/browser/extension.js | |
- name: Deploy | |
uses: peaceiris/actions-gh-pages@v3 | |
with: | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
publish_dir: . | |
keep_files: true | |
deploy: | |
needs: [ build ] | |
if: ${{ contains(github.ref, 'tags/v') }} | |
runs-on: ubuntu-latest | |
steps: | |
- name: Restore Bundles | |
uses: actions/download-artifact@v2 | |
with: | |
name: wasm-playground-app-bundle | |
path: dist | |
- run: cd dist && tar -czvf ../wasm-playground.tar.gz . | |
- uses: actions/create-release@v1 | |
if: ${{ contains(github.ref, 'tags/v') }} | |
id: create-release | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
tag_name: ${{ github.ref }} | |
release_name: Release ${{ github.ref }} | |
- uses: actions/upload-release-asset@v1 | |
if: ${{ contains(github.ref, 'tags/v') }} | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ steps.create-release.outputs.upload_url }} | |
asset_path: wasm-playground.tar.gz | |
asset_name: wasm-playground.tar.gz | |
asset_content_type: application/gzip | |
- name: Deploy | |
uses: peaceiris/actions-gh-pages@v3 | |
with: | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
publish_dir: dist | |
keep_files: true |