fix build #57
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 | |
| on: | |
| push: | |
| branches: | |
| - master | |
| - v[0-9]+.[0-9]+.x | |
| tags: | |
| - v* | |
| workflow_dispatch: | |
| jobs: | |
| build: | |
| name: ${{ matrix.target }} | |
| strategy: | |
| matrix: | |
| include: | |
| - target: x86_64-apple-darwin | |
| runner: macos-13 | |
| - target: aarch64-apple-darwin | |
| runner: macos-latest | |
| - target: x86_64-unknown-linux-gnu | |
| runner: ubuntu-latest | |
| - target: x86_64-unknown-linux-musl | |
| runner: ubuntu-latest | |
| - target: aarch64-unknown-linux-gnu | |
| runner: ubuntu-latest | |
| - target: aarch64-unknown-linux-musl | |
| runner: ubuntu-latest | |
| - target: x86_64-pc-windows-msvc | |
| runner: windows-latest | |
| runs-on: ${{ matrix.runner }} | |
| steps: | |
| - name: Checkout Code | |
| uses: actions/checkout@v4 | |
| - name: Cache Cargo | |
| uses: actions/cache@v4 | |
| with: | |
| path: | | |
| ~/.cargo/registry/index/ | |
| ~/.cargo/registry/cache/ | |
| ~/.cargo/git/db/ | |
| target/ | |
| !./target/*/*/*.zip | |
| !./target/*/*/*.tar.gz | |
| key: ${{ matrix.target }}-cargo-${{ hashFiles('**/Cargo.toml') }} | |
| - name: Update Rust Toolchain | |
| run: | | |
| rustup update stable | |
| rustup component add rustfmt rust-src clippy | |
| rustup target add ${{ matrix.target }} | |
| rustup target add wasm32-unknown-unknown | |
| - name: Run Tests (univ) | |
| run: cargo test --features univ | |
| - name: Run Tests (wasm) | |
| run: | | |
| cargo install wasm-pack --force | |
| wasm-pack test --node ./lib --features wasm | |
| - name: Clippy Check | |
| run: cargo clippy --all-targets | |
| - name: Format Check | |
| run: cargo fmt --check | |
| - name: Build Release (linux) | |
| if: contains(matrix.target, 'linux') | |
| run: | | |
| cargo install cross --force | |
| cross build --release --target ${{ matrix.target }} | |
| - name: Build Release (darwin or windows) | |
| if: ${{ !contains(matrix.target, 'linux') }} | |
| run: cargo build --release --target ${{ matrix.target }} | |
| # - name: Code Sign (darwin) | |
| # if: contains(matrix.target, 'darwin') | |
| # env: | |
| # APPLE_CODESIGN_KEY: '${{ secrets.APPLE_CODESIGN_KEY }}' | |
| # APPLE_CODESIGN_PASSWORD: '${{ secrets.APPLE_CODESIGN_PASSWORD }}' | |
| # echo Key is $(echo $APPLE_CODESIGN_KEY | base64 -d | wc -c) bytes | |
| # rcodesign sign target/release/basjoofan --code-signature-flags=runtime --p12-password=$APPLE_CODESIGN_PASSWORD --p12-file=<(echo $APPLE_CODESIGN_KEY | base64 -d) --entitlements-xml-file=cli/entitlements.plist | |
| # - name: Compress Archive (darwin or linux) | |
| # if: contains(matrix.target, 'darwin') || contains(matrix.target, 'linux') | |
| # run: zip -rj target/${{ matrix.target }}/release/basjoofan-${{ matrix.target }}.zip target/${{ matrix.target }}/release/basjoofan | |
| # - name: Compress Archive (windows) | |
| # if: contains(matrix.target, 'windows') | |
| # run: Compress-Archive -CompressionLevel Optimal -Force -Path target/${{ matrix.target }}/release/basjoofan.exe -DestinationPath target/${{ matrix.target }}/release/basjoofan-${{ matrix.target }}.zip | |
| - name: Echo Version (darwin or linux) | |
| if: contains(matrix.target, 'darwin') || contains(matrix.target, 'linux') | |
| run: echo version=$(grep '^version' ./cmd/Cargo.toml | head -1 | cut -d '"' -f2) >> $GITHUB_ENV | |
| - name: Naming (darwin or linux) | |
| if: contains(matrix.target, 'darwin') || contains(matrix.target, 'linux') | |
| run: mv target/${{ matrix.target }}/release/basjoofan target/${{ matrix.target }}/release/basjoofan-${{ env.version }}-${{ matrix.target }} | |
| - name: Echo Version (windows) | |
| if: contains(matrix.target, 'windows') | |
| run: echo version=$((Get-Content ./cmd/Cargo.toml | Select-String '^version').ToString().Split('"')[1]) >> $GITHUB_ENV | |
| - name: Naming (windows) | |
| if: contains(matrix.target, 'windows') | |
| run: Rename-Item -Path target/${{ matrix.target }}/release/basjoofan.exe -NewName target/${{ matrix.target }}/release/basjoofan-${{ env.version }}-${{ matrix.target }}.exe | |
| - name: Upload Artifacts | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: basjoofan-${{ matrix.target }} | |
| path: target/${{ matrix.target }}/release/basjoofan-${{ env.version }}-${{ matrix.target }}${{ contains(matrix.target, 'windows') && '.exe' || '' }} | |
| if-no-files-found: error | |
| - name: Release Version | |
| uses: softprops/action-gh-release@v2 | |
| if: startsWith(github.ref, 'refs/tags/') | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| with: | |
| files: target/${{ matrix.target }}/release/basjoofan-${{ env.version }}-${{ matrix.target }}${{ contains(matrix.target, 'windows') && '.exe' || '' }} | |
| draft: true |