ci: add cross-compile workflow for release binaries #1
Workflow file for this run
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: Release NoteNest Binaries | |
| on: | |
| push: | |
| tags: | |
| - 'v*' | |
| workflow_dispatch: | |
| permissions: | |
| contents: write | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| strategy: | |
| matrix: | |
| target: | |
| - aarch64-unknown-linux-musl | |
| - x86_64-unknown-linux-musl | |
| env: | |
| BINARY_NAME: notenest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Install Rust | |
| uses: dtolnay/rust-toolchain@stable | |
| - name: Cache cargo | |
| uses: Swatinem/rust-cache@v2 | |
| - name: Install Cross | |
| run: cargo install cross --locked | |
| - name: Build with Cross | |
| run: cross build --target ${{ matrix.target }} --release --verbose | |
| - name: Create Release Archive | |
| run: | | |
| mkdir -p dist | |
| cp target/${{ matrix.target }}/release/$BINARY_NAME dist/$BINARY_NAME | |
| tar -czvf dist/${{ matrix.target }}.tar.gz -C dist $BINARY_NAME | |
| rm dist/$BINARY_NAME | |
| - name: Upload workflow artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: notenest-${{ matrix.target }} | |
| path: dist/${{ matrix.target }}.tar.gz | |
| - name: Upload release assets | |
| if: startsWith(github.ref, 'refs/tags/') | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| files: dist/${{ matrix.target }}.tar.gz | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |