Build and Release #2
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: | |
| jobs: | |
| get-data: | |
| name: Read Cargo TOML | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@master | |
| - name: Read Cargo TOML | |
| uses: SebRollen/toml-action@v1.2.0 | |
| id: read_toml | |
| with: | |
| file: "./base/Cargo.toml" | |
| field: "package.version" | |
| outputs: | |
| base_version: ${{ steps.read_toml.outputs.value }} | |
| draft-release: | |
| name: Create a draft release | |
| runs-on: ubuntu-latest | |
| needs: get-data | |
| permissions: | |
| contents: write | |
| steps: | |
| - name: Push Tag | |
| id: tag_version | |
| uses: mathieudutour/github-tag-action@v6.2 | |
| with: | |
| github_token: ${{ secrets.GITHUB_TOKEN }} | |
| custom_tag: ${{ needs.get-data.outputs.base_version }} | |
| - name: Create Release | |
| uses: ncipollo/release-action@v1.16.0 | |
| with: | |
| draft: true | |
| tag: ${{ steps.tag_version.outputs.new_tag }} | |
| name: Release ${{ steps.tag_version.outputs.new_tag }} | |
| outputs: | |
| tag: ${{ steps.tag_version.outputs.new_tag }} | |
| build: | |
| name: Build and Upload | |
| needs: draft-release | |
| permissions: | |
| contents: write | |
| strategy: | |
| matrix: | |
| include: | |
| - target: x86_64-pc-windows-gnu | |
| runs-on: ubuntu-latest | |
| artifact_name: module.dll | |
| folder: module | |
| runs-on: ${{ matrix.runs-on }} | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@master | |
| - name: Install Rust | |
| uses: actions-rs/toolchain@v1 | |
| with: | |
| target: ${{ matrix.target }} | |
| profile: minimal | |
| override: true | |
| - uses: Swatinem/rust-cache@v2 | |
| with: | |
| workspaces: "./${{ matrix.folder }} -> target" | |
| - name: Cross build binary | |
| uses: houseabsolute/actions-rust-cross@v1 | |
| with: | |
| command: build | |
| target: ${{ matrix.target }} | |
| args: "--locked --release" | |
| strip: true | |
| - name: Upload release | |
| uses: svenstaro/upload-release-action@v2 | |
| with: | |
| repo_token: ${{ secrets.GITHUB_TOKEN }} | |
| file: target/${{ matrix.target }}/release/${{ matrix.artifact_name }} | |
| asset_name: ${{ matrix.artifact_name }} | |
| tag: ${{ needs.draft-release.outputs.tag }} | |
| overwrite: true |