Skip to content

feat: use rosu-mods #52

feat: use rosu-mods

feat: use rosu-mods #52

Workflow file for this run

name: CI
on:
push:
branches:
- main
- next
tags:
- '**'
pull_request:
workflow_dispatch:
jobs:
check:
name: Check files
runs-on: ubuntu-latest
steps:
- name: Checkout project
uses: actions/checkout@v4
- if: startsWith(github.ref, 'refs/tags/')
name: Check install link
run: |
if ! grep "npm install https://github.com/MaxOhn/rosu-pp-js/releases/download/${{ github.ref_name }}/rosu_pp_js_nodejs.tar.gz" README.md; then
echo "Did not find install link in readme: 'npm install https://github.com/MaxOhn/rosu-pp-js/releases/download/${{ github.ref_name }}/rosu_pp_js_nodejs.tar.gz'"
exit 1
fi
- name: Install stable toolchain
uses: dtolnay/rust-toolchain@stable
- name: Cache dependencies
uses: Swatinem/rust-cache@v2
- name: Install wasm-pack
run: curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh
- name: Build
run: wasm-pack build --target nodejs --out-dir pkg
- name: Check .d.ts file
run: |
if ! cmp --silent pkg/rosu_pp_js.d.ts rosu_pp_js.d.ts; then
echo ".d.ts file is not up to date"
cmp --print-bytes pkg/rosu_pp_js.d.ts rosu_pp_js.d.ts
cat pkg/rosu_pp_js.d.ts
exit 1
fi
build:
name: Build
runs-on: ubuntu-latest
strategy:
fail-fast: true
matrix:
target: [bundler, nodejs, web]
steps:
- name: Checkout project
uses: actions/checkout@v4
- name: Install stable toolchain
uses: dtolnay/rust-toolchain@stable
- name: Cache dependencies
uses: Swatinem/rust-cache@v2
- name: Install wasm-pack
run: curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh
- if: ${{ matrix.target != 'nodejs' }}
name: Optimize for size
run: echo "opt-level = \"z\"" >> Cargo.toml
- name: Build & zip
run: |
wasm-pack build --release --target ${{ matrix.target }} --out-dir pkg
ls -ghG pkg
tar -czvf rosu_pp_js_${{ matrix.target }}.tar.gz -C pkg .
- name: Upload tarballs
if: startsWith(github.ref, 'refs/tags/')
uses: actions/upload-artifact@v4
with:
name: rosu_pp_js_${{ matrix.target }}
path: rosu_pp_js_${{ matrix.target }}.tar.gz
release:
name: Release
needs: [check, build]
if: success() && startsWith(github.ref, 'refs/tags/')
runs-on: ubuntu-latest
steps:
- name: Get artifacts
uses: actions/download-artifact@v4
with:
merge-multiple: true
path: tars
- name: Upload to github release
uses: softprops/action-gh-release@v2
with:
files: tars/*.tar.gz
- name: Set up Node
uses: actions/setup-node@v4
with:
node-version: 20
- name: Extract nodejs tarball
run: |
mkdir extracted
tar -xzvf ./tars/rosu_pp_js_nodejs.tar.gz -C ./extracted
- name: Publish
uses: JS-DevTools/npm-publish@v3
with:
package: ./extracted
token: ${{ secrets.NPM_TOKEN }}