Release Please #51
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 Please | |
| on: | |
| workflow_dispatch: | |
| env: | |
| FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: "true" | |
| permissions: {} | |
| jobs: | |
| release-please: | |
| runs-on: ubuntu-latest | |
| env: | |
| FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: "true" | |
| permissions: | |
| contents: write | |
| pull-requests: write | |
| outputs: | |
| release_created: ${{ steps.release.outputs.release_created }} | |
| tag_name: ${{ steps.release.outputs.tag_name }} | |
| steps: | |
| - name: Release Please | |
| id: release | |
| uses: googleapis/release-please-action@v4.4.0 | |
| with: | |
| config-file: .github/release-please/config.json | |
| manifest-file: .github/release-please/manifest.json | |
| - name: Sync GitHub release notes body | |
| if: ${{ steps.release.outputs.release_created == 'true' && steps.release.outputs.tag_name != '' && steps.release.outputs.body != '' }} | |
| uses: actions/github-script@v8 | |
| env: | |
| RELEASE_TAG: ${{ steps.release.outputs.tag_name }} | |
| RELEASE_BODY: ${{ steps.release.outputs.body }} | |
| with: | |
| script: | | |
| const { owner, repo } = context.repo; | |
| const release = await github.rest.repos.getReleaseByTag({ | |
| owner, | |
| repo, | |
| tag: process.env.RELEASE_TAG, | |
| }); | |
| await github.rest.repos.updateRelease({ | |
| owner, | |
| repo, | |
| release_id: release.data.id, | |
| body: process.env.RELEASE_BODY, | |
| }); | |
| release-binaries: | |
| name: Build release binaries (${{ matrix.target }}) | |
| needs: release-please | |
| if: ${{ needs.release-please.outputs.release_created == 'true' && needs.release-please.outputs.tag_name != '' }} | |
| runs-on: ${{ matrix.runner }} | |
| env: | |
| FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: "true" | |
| permissions: | |
| contents: read | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: | |
| - runner: ubuntu-latest | |
| target: x86_64-unknown-linux-gnu | |
| binary_name: rustipo | |
| - runner: macos-15-intel | |
| target: x86_64-apple-darwin | |
| binary_name: rustipo | |
| - runner: macos-14 | |
| target: aarch64-apple-darwin | |
| binary_name: rustipo | |
| - runner: windows-latest | |
| target: x86_64-pc-windows-msvc | |
| binary_name: rustipo.exe | |
| steps: | |
| - name: Check out release tag | |
| uses: actions/checkout@v6 | |
| with: | |
| ref: ${{ needs.release-please.outputs.tag_name }} | |
| - name: Install Rust toolchain | |
| uses: dtolnay/rust-toolchain@stable | |
| with: | |
| targets: ${{ matrix.target }} | |
| - name: Cache Rust build outputs | |
| uses: Swatinem/rust-cache@v2 | |
| with: | |
| key: release-${{ matrix.target }} | |
| - name: Build release binary | |
| run: cargo build --release --locked --target ${{ matrix.target }} | |
| - name: Package release archive (Unix) | |
| if: runner.os != 'Windows' | |
| shell: bash | |
| env: | |
| RELEASE_TAG: ${{ needs.release-please.outputs.tag_name }} | |
| TARGET: ${{ matrix.target }} | |
| BINARY_NAME: ${{ matrix.binary_name }} | |
| run: | | |
| set -euo pipefail | |
| archive_stem="${RELEASE_TAG}-${TARGET}" | |
| stage_dir="$archive_stem" | |
| mkdir -p "$stage_dir" | |
| cp "target/${TARGET}/release/${BINARY_NAME}" "$stage_dir/" | |
| cp README.md LICENSE.md "$stage_dir/" | |
| tar -czf "${archive_stem}.tar.gz" "$stage_dir" | |
| - name: Package release archive (Windows) | |
| if: runner.os == 'Windows' | |
| shell: pwsh | |
| env: | |
| RELEASE_TAG: ${{ needs.release-please.outputs.tag_name }} | |
| TARGET: ${{ matrix.target }} | |
| BINARY_NAME: ${{ matrix.binary_name }} | |
| run: | | |
| $archiveStem = "$env:RELEASE_TAG-$env:TARGET" | |
| New-Item -ItemType Directory -Path $archiveStem | Out-Null | |
| Copy-Item "target/$env:TARGET/release/$env:BINARY_NAME" $archiveStem | |
| Copy-Item README.md $archiveStem | |
| Copy-Item LICENSE.md $archiveStem | |
| Compress-Archive -Path "$archiveStem/*" -DestinationPath "$archiveStem.zip" | |
| - name: Upload release archive artifact | |
| uses: actions/upload-artifact@v7 | |
| with: | |
| name: release-binary-${{ matrix.target }} | |
| path: ${{ github.workspace }}/${{ needs.release-please.outputs.tag_name }}-${{ matrix.target }}.* | |
| if-no-files-found: error | |
| publish-release-assets: | |
| name: Publish release assets | |
| runs-on: ubuntu-latest | |
| needs: | |
| - release-please | |
| - release-binaries | |
| if: ${{ needs.release-please.outputs.release_created == 'true' && needs.release-please.outputs.tag_name != '' }} | |
| env: | |
| FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: "true" | |
| permissions: | |
| contents: write | |
| steps: | |
| - name: Download packaged release archives | |
| uses: actions/download-artifact@v8 | |
| with: | |
| pattern: release-binary-* | |
| path: release-assets | |
| merge-multiple: true | |
| - name: Generate release checksums | |
| working-directory: release-assets | |
| env: | |
| RELEASE_TAG: ${{ needs.release-please.outputs.tag_name }} | |
| run: sha256sum * > "${RELEASE_TAG}-sha256sums.txt" | |
| - name: Upload release assets | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| tag_name: ${{ needs.release-please.outputs.tag_name }} | |
| files: release-assets/* | |
| fail_on_unmatched_files: true |