chore(workflow): remove pull-requests permission from rust.yml #10
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 CI | |
| on: | |
| push: | |
| branches: ["master"] | |
| permissions: | |
| contents: write | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.ref }} | |
| cancel-in-progress: true | |
| env: | |
| CARGO_TERM_COLOR: always | |
| CRATE_NAME: rust-commit-tracker | |
| jobs: | |
| release-please: | |
| runs-on: ubuntu-latest | |
| outputs: | |
| release_created: ${{ steps.release.outputs.release_created }} | |
| tag_name: ${{ steps.release.outputs.tag_name }} | |
| version: ${{ steps.release.outputs.version }} | |
| upload_url: ${{ steps.release.outputs.upload_url }} | |
| steps: | |
| - uses: googleapis/release-please-action@v4 | |
| id: release | |
| with: | |
| release-type: rust | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| test: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Install Rust toolchain | |
| uses: dtolnay/rust-toolchain@stable | |
| - name: Build | |
| run: cargo build --verbose | |
| - name: Run tests | |
| run: cargo test --verbose | |
| build-binaries: | |
| needs: [release-please, test] | |
| if: needs.release-please.outputs.release_created == 'true' | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| matrix: | |
| include: | |
| - target: x86_64-pc-windows-gnu | |
| os: ubuntu-latest | |
| asset_name_suffix: .exe | |
| archive_format: zip | |
| - target: x86_64-unknown-linux-gnu | |
| os: ubuntu-latest | |
| asset_name_suffix: "" | |
| archive_format: tar.gz | |
| - target: x86_64-apple-darwin | |
| os: macos-latest | |
| asset_name_suffix: "" | |
| archive_format: tar.gz | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Install Rust toolchain for target | |
| uses: dtolnay/rust-toolchain@stable | |
| with: | |
| toolchain: stable | |
| targets: ${{ matrix.target }} | |
| - name: Install cross-compilation tools (for Windows target on Linux) | |
| if: matrix.target == 'x86_64-pc-windows-gnu' && runner.os == 'Linux' | |
| run: | | |
| sudo apt-get update -y | |
| sudo apt-get install -y gcc-mingw-w64-x86-64 | |
| - name: Build release binary | |
| run: | | |
| # Set linker for windows cross-compilation if on Linux runner | |
| if [ "${{ matrix.target }}" = "x86_64-pc-windows-gnu" ] && [ "${{ runner.os }}" = "Linux" ]; then | |
| export CARGO_TARGET_X86_64_PC_WINDOWS_GNU_LINKER=x86_64-w64-mingw32-gcc | |
| fi | |
| cargo build --release --target ${{ matrix.target }} --verbose | |
| - name: Determine Asset Names | |
| id: asset_names | |
| shell: bash | |
| run: | | |
| local_crate_name="${{ env.CRATE_NAME }}" | |
| local_tag_name="${{ needs.release-please.outputs.tag_name }}" | |
| binary_filename="${local_crate_name}${{ matrix.asset_name_suffix }}" | |
| archive_filename="${local_crate_name}-${local_tag_name}-${{ matrix.target }}.${{ matrix.archive_format }}" | |
| echo "binary_path=target/${{ matrix.target }}/release/${binary_filename}" >> $GITHUB_OUTPUT | |
| echo "archive_path=dist/${archive_filename}" >> $GITHUB_OUTPUT | |
| echo "asset_upload_name=${archive_filename}" >> $GITHUB_OUTPUT | |
| echo "packaged_binary_name=${binary_filename}" >> $GITHUB_OUTPUT | |
| - name: Package binary | |
| shell: bash | |
| run: | | |
| mkdir -p dist | |
| cp "${{ steps.asset_names.outputs.binary_path }}" "dist/${{ steps.asset_names.outputs.packaged_binary_name }}" | |
| cd dist | |
| if [ "${{ matrix.archive_format }}" = "zip" ]; then | |
| zip -r "${{ steps.asset_names.outputs.asset_upload_name }}" "${{ steps.asset_names.outputs.packaged_binary_name }}" | |
| else | |
| tar -czf "${{ steps.asset_names.outputs.asset_upload_name }}" "${{ steps.asset_names.outputs.packaged_binary_name }}" | |
| fi | |
| cd .. | |
| - name: Upload Release Asset | |
| uses: actions/upload-release-asset@v1 | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| with: | |
| upload_url: ${{ needs.release-please.outputs.upload_url }} | |
| asset_path: ${{ steps.asset_names.outputs.archive_path }} | |
| asset_name: ${{ steps.asset_names.outputs.asset_upload_name }} | |
| asset_content_type: application/octet-stream | |
| publish-crate: | |
| needs: [release-please, test] | |
| if: needs.release-please.outputs.release_created == 'true' | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| ref: ${{ needs.release-please.outputs.tag_name }} | |
| - name: Install Rust toolchain | |
| uses: dtolnay/rust-toolchain@stable | |
| - name: Publish to crates.io | |
| run: cargo publish --token ${{ secrets.CARGO_REGISTRY_TOKEN }} |