optimize bit tricks #56
This file contains hidden or 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
| on: | |
| push: | |
| branches: | |
| - main | |
| name: Release | |
| env: | |
| CARGO_TERM_COLOR: always | |
| jobs: | |
| build-apk: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - uses: actions-rs/toolchain@v1 | |
| with: | |
| override: true | |
| target: aarch64-linux-android | |
| profile: minimal | |
| toolchain: stable | |
| - uses: Swatinem/rust-cache@v2 | |
| - name: Install cargo-ndk | |
| run: cargo install --locked cargo-ndk | |
| - name: Build Native Library | |
| run: cargo ndk -t arm64-v8a -o app/src/main/jniLibs build --package solitaire-game --release | |
| - name: Assemble Apk | |
| run: | | |
| ./gradlew assemble | |
| cp app/build/outputs/apk/release/app-release.apk peg-solitaire.apk | |
| - uses: actions/upload-artifact@v6 | |
| with: | |
| name: android-apk | |
| path: ./peg-solitaire.apk | |
| build-wasm: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - uses: actions-rs/toolchain@v1 | |
| with: | |
| override: true | |
| target: wasm32-unknown-unknown | |
| profile: minimal | |
| toolchain: stable | |
| - uses: Swatinem/rust-cache@v2 | |
| - name: Cache wasm-bindgen-cli | |
| id: cache-wasm-bindgen | |
| uses: actions/cache@v5 | |
| with: | |
| path: ~/.cargo/bin/wasm-bindgen | |
| key: wasm-bindgen-${{ hashFiles('Cargo.lock') }} | |
| - name: Install Bindgen | |
| if: steps.cache-wasm-bindgen.outputs.cache-hit != 'true' | |
| run: | | |
| WASM_BINDGEN_VERSION=$(cargo metadata --format-version 1 | \ | |
| jq -r '.packages[] | select(.name == "wasm-bindgen") | .version') | |
| cargo install wasm-bindgen-cli --version $WASM_BINDGEN_VERSION | |
| - name: Install Binaryen | |
| run: sudo apt install binaryen | |
| - name: Install Brotli | |
| run: sudo apt install brotli | |
| - name: Build WASM dist | |
| run: make | |
| - name: Upload build artifact | |
| uses: actions/upload-artifact@v6 | |
| with: | |
| name: wasm-dist | |
| path: www/ | |
| - name: Upload github pages artifact | |
| id: deployment | |
| uses: actions/upload-pages-artifact@v4 | |
| with: | |
| path: www/ | |
| build-linux-x86_64: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - uses: actions-rs/toolchain@v1 | |
| with: | |
| override: true | |
| target: wasm32-unknown-unknown | |
| profile: minimal | |
| toolchain: stable | |
| - uses: Swatinem/rust-cache@v2 | |
| - name: install dependencies | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install g++ pkg-config libx11-dev libasound2-dev libudev-dev libxkbcommon-x11-0 libwayland-dev libxkbcommon-dev | |
| - name: release build | |
| run: | | |
| cargo build --release | |
| cp target/release/peg-solitaire peg-solitaire-linux-x86_64 | |
| - name: Upload build artifact | |
| uses: actions/upload-artifact@v6 | |
| with: | |
| name: peg-solitaire-linux-x86_64 | |
| path: peg-solitaire-linux-x86_64 | |
| build-macos-aarch64: | |
| runs-on: macos-latest | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - uses: actions-rs/toolchain@v1 | |
| with: | |
| override: true | |
| target: wasm32-unknown-unknown | |
| profile: minimal | |
| toolchain: stable | |
| - uses: Swatinem/rust-cache@v2 | |
| - name: release build | |
| run: | | |
| cargo build --release | |
| cp target/release/peg-solitaire peg-solitaire-macos-aarch64 | |
| - name: Upload build artifact | |
| uses: actions/upload-artifact@v6 | |
| with: | |
| name: peg-solitaire-macos-aarch64 | |
| path: peg-solitaire-macos-aarch64 | |
| build-windows: | |
| runs-on: windows-latest | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - uses: actions-rs/toolchain@v1 | |
| with: | |
| override: true | |
| target: wasm32-unknown-unknown | |
| profile: minimal | |
| toolchain: stable | |
| - uses: Swatinem/rust-cache@v2 | |
| - name: release build | |
| run: | | |
| cargo build --release | |
| cp target/release/peg-solitaire.exe peg-solitaire-windows-x86_64.exe | |
| - name: Upload build artifact | |
| uses: actions/upload-artifact@v6 | |
| with: | |
| name: peg-solitaire-windows-x86_64 | |
| path: peg-solitaire-windows-x86_64.exe | |
| release: | |
| needs: [build-apk, build-wasm, build-linux-x86_64, build-macos-aarch64, build-windows] | |
| permissions: | |
| contents: write | |
| pages: write | |
| id-token: write | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Download Build Artifacts | |
| uses: actions/download-artifact@v8 | |
| - name: Zip WASM dist | |
| run: zip -r wasm-dist.zip wasm-dist/ | |
| - name: Create GitHub Release | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| tag_name: ${{ github.event.inputs.name || github.ref_name }} | |
| name: ${{ github.event.inputs.name || github.ref_name }} | |
| files: | | |
| android-apk/peg-solitaire.apk | |
| wasm-dist.zip | |
| peg-solitaire-linux-x86_64/peg-solitaire-linux-x86_64 | |
| peg-solitaire-windows-x86_64/peg-solitaire-windows-x86_64.exe | |
| peg-solitaire-macos-aarch64/peg-solitaire-macos-aarch64 | |
| generate_release_notes: true # Auto-generates changelog | |
| draft: false | |
| prerelease: ${{ contains(github.ref_name, '-rc') || contains(github.ref_name, '-beta') }} | |
| deploy: | |
| environment: | |
| name: github-pages | |
| url: ${{ steps.deployment.outputs.page_url }} | |
| runs-on: ubuntu-latest | |
| needs: [build-wasm] | |
| permissions: | |
| contents: read | |
| pages: write | |
| id-token: write | |
| steps: | |
| - name: Deploy to GitHub Pages | |
| id: deployment | |
| uses: actions/deploy-pages@v4 |