feat(release): add resilience infrastructure and cross-platform relea… #7
Workflow file for this run
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 | |
| on: | |
| push: | |
| tags: ['v*'] | |
| concurrency: | |
| group: release-${{ github.ref }} | |
| cancel-in-progress: false | |
| env: | |
| CARGO_TERM_COLOR: always | |
| jobs: | |
| # ============================================================ | |
| # Build Release Binaries | |
| # ============================================================ | |
| build: | |
| name: Build | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: | |
| - { os: ubuntu-latest, target: x86_64-unknown-linux-gnu, cross: false } | |
| - { os: ubuntu-latest, target: aarch64-unknown-linux-gnu, cross: true } | |
| - { os: macos-latest, target: x86_64-apple-darwin, cross: false } | |
| - { os: macos-latest, target: aarch64-apple-darwin, cross: false } | |
| - { os: windows-latest, target: x86_64-pc-windows-msvc, cross: false } | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: dtolnay/rust-toolchain@stable | |
| with: | |
| targets: ${{ matrix.target }} | |
| - uses: Swatinem/rust-cache@v2 | |
| with: | |
| key: release-${{ matrix.target }} | |
| - name: Install cross | |
| if: matrix.cross | |
| uses: taiki-e/install-action@cross | |
| - name: Build | |
| run: ${{ matrix.cross && 'cross' || 'cargo' }} build --release --target ${{ matrix.target }} | |
| - name: Package (Unix) | |
| if: runner.os != 'Windows' | |
| run: | | |
| cd target/${{ matrix.target }}/release | |
| tar -czvf ../../../palrun-${{ matrix.target }}.tar.gz palrun pal | |
| - name: Package (Windows) | |
| if: runner.os == 'Windows' | |
| run: Compress-Archive -Path target/${{ matrix.target }}/release/palrun.exe, target/${{ matrix.target }}/release/pal.exe -DestinationPath palrun-${{ matrix.target }}.zip | |
| - uses: actions/upload-artifact@v4 | |
| with: | |
| name: palrun-${{ matrix.target }} | |
| path: palrun-${{ matrix.target }}.* | |
| if-no-files-found: error | |
| # ============================================================ | |
| # Generate SBOM | |
| # ============================================================ | |
| sbom: | |
| name: SBOM | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: dtolnay/rust-toolchain@stable | |
| - name: Generate | |
| run: | | |
| cargo install cargo-sbom | |
| cargo sbom --output-format cyclone_dx_json_1_4 > sbom.json | |
| - uses: actions/upload-artifact@v4 | |
| with: | |
| name: sbom | |
| path: sbom.json | |
| # ============================================================ | |
| # Create GitHub Release | |
| # ============================================================ | |
| release: | |
| name: Release | |
| needs: [build, sbom] | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| outputs: | |
| version: ${{ steps.meta.outputs.version }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Extract metadata | |
| id: meta | |
| run: | | |
| VERSION=${GITHUB_REF#refs/tags/v} | |
| echo "version=$VERSION" >> $GITHUB_OUTPUT | |
| echo "prerelease=$([[ "$VERSION" == *-* ]] && echo true || echo false)" >> $GITHUB_OUTPUT | |
| - uses: actions/download-artifact@v4 | |
| with: | |
| path: artifacts | |
| - name: Prepare assets | |
| run: | | |
| mkdir release | |
| find artifacts -type f \( -name "*.tar.gz" -o -name "*.zip" -o -name "*.json" \) -exec mv {} release/ \; | |
| cd release && sha256sum * > SHA256SUMS.txt | |
| - name: Generate changelog | |
| run: | | |
| cargo install git-cliff || true | |
| git cliff --latest --strip header > CHANGELOG.md 2>/dev/null || echo "See commits for changes" > CHANGELOG.md | |
| - uses: softprops/action-gh-release@v2 | |
| with: | |
| files: release/* | |
| body_path: CHANGELOG.md | |
| prerelease: ${{ steps.meta.outputs.prerelease }} | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| # ============================================================ | |
| # Publish Packages | |
| # ============================================================ | |
| publish-npm: | |
| name: npm | |
| needs: [release] | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| id-token: write | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/setup-node@v4 | |
| with: | |
| node-version: '22' | |
| registry-url: 'https://registry.npmjs.org' | |
| - name: Publish | |
| working-directory: npm | |
| run: | | |
| VERSION=${{ needs.release.outputs.version }} | |
| npm version $VERSION --no-git-tag-version --allow-same-version | |
| if [[ "$VERSION" == *-* ]]; then | |
| TAG=$(echo "$VERSION" | sed 's/.*-\([a-zA-Z]*\).*/\1/') | |
| npm publish --access public --tag "$TAG" | |
| else | |
| npm publish --access public | |
| fi | |
| publish-crates: | |
| name: crates.io | |
| needs: [release] | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: dtolnay/rust-toolchain@stable | |
| - name: Publish | |
| run: cargo publish --token ${{ secrets.CARGO_REGISTRY_TOKEN }} | |
| continue-on-error: true | |
| update-homebrew: | |
| name: Homebrew | |
| needs: [release] | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| ref: main | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| - uses: actions/download-artifact@v4 | |
| with: | |
| path: artifacts | |
| - name: Update formula | |
| run: | | |
| VERSION=${{ needs.release.outputs.version }} | |
| # Calculate SHA256 for each platform | |
| SHA_DARWIN_ARM=$(sha256sum artifacts/palrun-aarch64-apple-darwin/palrun-aarch64-apple-darwin.tar.gz | cut -d' ' -f1) | |
| SHA_DARWIN_X64=$(sha256sum artifacts/palrun-x86_64-apple-darwin/palrun-x86_64-apple-darwin.tar.gz | cut -d' ' -f1) | |
| SHA_LINUX_ARM=$(sha256sum artifacts/palrun-aarch64-unknown-linux-gnu/palrun-aarch64-unknown-linux-gnu.tar.gz | cut -d' ' -f1) | |
| SHA_LINUX_X64=$(sha256sum artifacts/palrun-x86_64-unknown-linux-gnu/palrun-x86_64-unknown-linux-gnu.tar.gz | cut -d' ' -f1) | |
| # Update formula | |
| cat > HomebrewFormula/palrun.rb << EOF | |
| class Palrun < Formula | |
| desc "AI command palette for your terminal - discover and run project commands instantly" | |
| homepage "https://github.com/GLINCKER/palrun" | |
| version "${VERSION}" | |
| license "MIT" | |
| on_macos do | |
| on_arm do | |
| url "https://github.com/GLINCKER/palrun/releases/download/v${VERSION}/palrun-aarch64-apple-darwin.tar.gz" | |
| sha256 "${SHA_DARWIN_ARM}" | |
| end | |
| on_intel do | |
| url "https://github.com/GLINCKER/palrun/releases/download/v${VERSION}/palrun-x86_64-apple-darwin.tar.gz" | |
| sha256 "${SHA_DARWIN_X64}" | |
| end | |
| end | |
| on_linux do | |
| on_arm do | |
| url "https://github.com/GLINCKER/palrun/releases/download/v${VERSION}/palrun-aarch64-unknown-linux-gnu.tar.gz" | |
| sha256 "${SHA_LINUX_ARM}" | |
| end | |
| on_intel do | |
| url "https://github.com/GLINCKER/palrun/releases/download/v${VERSION}/palrun-x86_64-unknown-linux-gnu.tar.gz" | |
| sha256 "${SHA_LINUX_X64}" | |
| end | |
| end | |
| def install | |
| bin.install "palrun" | |
| bin.install "pal" | |
| end | |
| test do | |
| assert_match version.to_s, shell_output("#{bin}/palrun --version") | |
| end | |
| end | |
| EOF | |
| - name: Commit formula | |
| run: | | |
| git config user.name "github-actions[bot]" | |
| git config user.email "github-actions[bot]@users.noreply.github.com" | |
| git add HomebrewFormula/palrun.rb | |
| git commit -m "chore(homebrew): update formula to v${{ needs.release.outputs.version }}" || exit 0 | |
| git push |