Build binaries #76
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 binaries | |
| permissions: | |
| contents: write | |
| on: | |
| release: | |
| types: | |
| - published | |
| workflow_dispatch: | |
| inputs: | |
| tag: | |
| required: false | |
| type: string | |
| windows: | |
| default: false | |
| type: boolean | |
| macos: | |
| default: false | |
| type: boolean | |
| env: | |
| CARGO_INCREMENTAL: 0 | |
| CARGO_NET_GIT_FETCH_WITH_CLI: true | |
| CARGO_NET_RETRY: 10 | |
| CARGO_TERM_COLOR: always | |
| RUST_BACKTRACE: 1 | |
| RUSTFLAGS: -D warnings | |
| RUSTUP_MAX_RETRIES: 10 | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.ref }}-${{ github.event_name }} | |
| cancel-in-progress: true | |
| jobs: | |
| build: | |
| name: ${{ matrix.target }} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| target: | |
| - aarch64-unknown-linux-gnu | |
| - x86_64-unknown-linux-gnu | |
| - aarch64-apple-darwin | |
| - x86_64-apple-darwin | |
| - aarch64-pc-windows-msvc | |
| - x86_64-pc-windows-msvc | |
| windows: | |
| - ${{ github.event_name == 'release' || inputs.windows }} | |
| macos: | |
| - ${{ github.event_name == 'release' || inputs.macos }} | |
| exclude: | |
| - macos: false | |
| target: aarch64-apple-darwin | |
| - macos: false | |
| target: x86_64-apple-darwin | |
| - windows: false | |
| target: aarch64-pc-windows-msvc | |
| - windows: false | |
| target: x86_64-pc-windows-msvc | |
| runs-on: | | |
| ${{ | |
| contains(matrix.target, 'x86_64-unknown-linux-') && 'ubuntu-24.04' || | |
| contains(matrix.target, 'aarch64-unknown-linux-') && 'ubuntu-24.04-arm' || | |
| contains(matrix.target, '-apple-') && 'macos-latest' || | |
| 'windows-latest' | |
| }} | |
| if: ${{ github.repository_owner == 'tonywu6' }} | |
| timeout-minutes: 60 | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - name: Install stable toolchain | |
| uses: dtolnay/rust-toolchain@3c5f7ea28cd621ae0bf5283f0e981fb97b8a7af9 | |
| with: | |
| toolchain: stable | |
| id: rustup | |
| - uses: tonywu6/[email protected] | |
| id: cache | |
| env: | |
| GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} | |
| with: | |
| deps: | | |
| ${{runner.os}} | |
| ${{runner.arch}} | |
| ${{steps.rustup.outputs.cachekey}} | |
| ${{hashFiles('**/Cargo.toml')}} | |
| ${{hashFiles('**/Cargo.lock')}} | |
| ${{github.workflow}} | |
| ${{github.run_id}} | |
| path: | | |
| .bin/ | |
| target/ | |
| - name: Which package? | |
| run: cargo xtask github which-package ${{ inputs.tag || github.event.release.tag_name }} | |
| id: bins | |
| - name: Build mdbook-rustdoc-links | |
| uses: taiki-e/upload-rust-binary-action@v1 | |
| with: | |
| target: ${{ matrix.target }} | |
| bin: mdbook-rustdoc-links | |
| archive: $bin-$target | |
| tar: unix | |
| zip: windows | |
| codesign: "-" | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| dry-run: ${{ !(github.event_name == 'release' || inputs.tag) }} | |
| ref: ${{ inputs.tag && format('refs/tags/{0}', inputs.tag) || github.ref }} | |
| if: ${{ steps.bins.outputs.mdbook-rustdoc-links }} | |
| - name: Build mdbook-permalinks | |
| uses: taiki-e/upload-rust-binary-action@v1 | |
| with: | |
| target: ${{ matrix.target }} | |
| bin: mdbook-permalinks | |
| archive: $bin-$target | |
| tar: unix | |
| zip: windows | |
| codesign: "-" | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| dry-run: ${{ !(github.event_name == 'release' || inputs.tag) }} | |
| ref: ${{ inputs.tag && format('refs/tags/{0}', inputs.tag) || github.ref }} | |
| if: ${{ steps.bins.outputs.mdbook-permalinks }} | |
| - uses: actions/upload-artifact@v7 | |
| with: | |
| path: | | |
| target/${{ matrix.target }}/release/mdbook-rustdoc-links | |
| target/${{ matrix.target }}/release/mdbook-rustdoc-links.exe | |
| target/${{ matrix.target }}/release/mdbook-permalinks | |
| target/${{ matrix.target }}/release/mdbook-permalinks.exe | |
| name: ${{ matrix.target }} | |
| if-no-files-found: warn | |
| retention-days: 1 | |
| if: github.event_name != 'release' |