use script to determine target #42
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
| name: Build And Release | |
| on: [workflow_dispatch, push] | |
| jobs: | |
| Build: | |
| strategy: | |
| matrix: | |
| os: | |
| - ubuntu-latest | |
| - windows-latest | |
| - macos-latest | |
| arch: | |
| - x64 | |
| - arm64 | |
| runs-on: ${{matrix.os}} | |
| steps: | |
| - name: Checking out Repository | |
| uses: actions/checkout@v3 | |
| with: | |
| submodules: true | |
| - name: Install pnpm | |
| uses: pnpm/action-setup@v4 | |
| - name: Install Linux Dependencies | |
| if: runner.os == 'Linux' | |
| run: sudo apt-get install -y gcc-aarch64-linux-gnu g++-aarch64-linux-gnu | |
| - name: Get Target Name | |
| id: get_target | |
| env: | |
| npm_config_arch: ${{ matrix.arch }} | |
| run: | | |
| echo "target_name=$(node ./utils/getTarget.js)" >> $GITHUB_OUTPUT | |
| - name: Install Rust | |
| uses: dtolnay/rust-toolchain@master | |
| with: | |
| toolchain: stable | |
| targets: ${{ steps.get_target.outputs.target_name }} | |
| - name: Building | |
| env: | |
| npm_config_arch: ${{ matrix.arch }} | |
| run: pnpm install | |
| - name: Uploading | |
| if: ${{github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')}} | |
| uses: actions/upload-artifact@v5 | |
| with: | |
| name: bin-${{runner.os}}-${{matrix.arch}} | |
| path: bin/** | |
| Release: | |
| if: ${{github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')}} | |
| needs: Build | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checking out Repository | |
| uses: actions/checkout@v3 | |
| with: | |
| submodules: true | |
| - name: Download Artifacts | |
| uses: actions/download-artifact@v3 | |
| - name: Fix Directory Structure | |
| run: | | |
| mkdir bin | |
| mv bin-*/* bin/ | |
| rm -rf bin-* | |
| sudo chmod -R +x bin | |
| # this will only publish if the version has been updated | |
| - name: NPM Publish | |
| uses: JS-DevTools/[email protected] | |
| with: | |
| token: ${{secrets.NPM_TOKEN}} |