Skip to content

fix(ci): add --allow-dirty for crates.io and NPM_TOKEN for npm #10

fix(ci): add --allow-dirty for crates.io and NPM_TOKEN for npm

fix(ci): add --allow-dirty for crates.io and NPM_TOKEN for npm #10

Workflow file for this run

name: Release
on:
push:
tags: ['v*']
concurrency:
group: release-${{ github.ref }}
cancel-in-progress: false
env:
CARGO_TERM_COLOR: always
CARGO_INCREMENTAL: 0
CARGO_NET_RETRY: 10
RUSTUP_MAX_RETRIES: 10
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 }}
cache-all-crates: true
cache-on-failure: true
- 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
- uses: Swatinem/rust-cache@v2
with:
cache-all-crates: true
- name: Cache cargo-sbom
uses: actions/cache@v4
with:
path: ~/.cargo/bin/cargo-sbom
key: cargo-sbom-${{ runner.os }}
- name: Install cargo-sbom
run: command -v cargo-sbom || cargo install cargo-sbom
- name: Generate
run: 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: Cache git-cliff
uses: actions/cache@v4
with:
path: ~/.cargo/bin/git-cliff
key: git-cliff-${{ runner.os }}
- name: Generate changelog
run: |
command -v git-cliff || cargo install git-cliff
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
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
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" --provenance
else
npm publish --access public --provenance
fi
continue-on-error: true # Don't block release if npm fails
publish-crates:
name: crates.io
needs: [release]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
- name: Publish
run: cargo publish --token ${{ secrets.CARGO_REGISTRY_TOKEN }} --allow-dirty
continue-on-error: true
update-homebrew:
name: Homebrew
needs: [release]
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: 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 }}
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)
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: Create PR for formula update
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
VERSION=${{ needs.release.outputs.version }}
BRANCH="chore/homebrew-v${VERSION}"
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git checkout -b "$BRANCH"
git add HomebrewFormula/palrun.rb
git commit -m "chore(homebrew): update formula to v${VERSION}" || exit 0
git push -u origin "$BRANCH"
gh pr create \
--title "chore(homebrew): update formula to v${VERSION}" \
--body "Auto-generated PR to update Homebrew formula for release v${VERSION}" \
--base main \
--head "$BRANCH"