ci: simplify release packaging #44
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: Prototype continuous integration | |
| on: | |
| push: | |
| pull_request: | |
| env: | |
| CARGO_TERM_COLOR: always | |
| jobs: | |
| build_and_test: | |
| runs-on: ubuntu-latest | |
| strategy: | |
| matrix: | |
| toolchain: | |
| - stable | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - run: rustup update ${{ matrix.toolchain }} && rustup default ${{ matrix.toolchain }} | |
| - run: cargo build --verbose | |
| - run: cargo test --verbose | |
| release: | |
| if: startsWith(github.ref, 'refs/tags/v') | |
| runs-on: ubuntu-latest | |
| needs: build_and_test | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - run: rustup update stable && rustup default stable | |
| - name: Extract version from tag | |
| id: extract | |
| run: echo "version=${GITHUB_REF##*/}" >> "$GITHUB_OUTPUT" | |
| - run: cargo build --release | |
| - name: Archive and rename binary | |
| run: | | |
| VERSION=${{ steps.extract.outputs.version }} | |
| PLATFORM=linux-x86_64 | |
| mkdir -p target/dist | |
| cp target/release/libscal3.so target/dist/libscal3-$VERSION-$PLATFORM.so | |
| - run: cargo publish --locked | |
| env: | |
| CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }} | |
| - name: Create GitHub Release with uploaded binary | |
| run: | | |
| VERSION=${{ steps.extract.outputs.version }} | |
| PLATFORM=linux-x86_64 | |
| gh release create "${{ steps.extract.outputs.version }}" target/dist/libscal3-$VERSION-$PLATFORM.so \ | |
| --title "Release ${{ steps.extract.outputs.version }}" \ | |
| --verify-tag | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |