name: Release
on:
push:
tags:
- 'v*'
env:
CARGO_TERM_COLOR: always
jobs:
build-release:
name: Build Release
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-latest
target: x86_64-unknown-linux-gnu
artifact: proc-linux-x86_64
- os: ubuntu-latest
target: aarch64-unknown-linux-gnu
artifact: proc-linux-aarch64
- os: macos-latest
target: x86_64-apple-darwin
artifact: proc-darwin-x86_64
- os: macos-latest
target: aarch64-apple-darwin
artifact: proc-darwin-aarch64
- os: windows-latest
target: x86_64-pc-windows-msvc
artifact: proc-windows-x86_64.exe
steps:
- uses: actions/checkout@v4
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
- name: Install cross-compilation tools (Linux ARM64)
if: matrix.target == 'aarch64-unknown-linux-gnu'
run: |
sudo apt-get update
sudo apt-get install -y gcc-aarch64-linux-gnu
echo '[target.aarch64-unknown-linux-gnu]' >> ~/.cargo/config.toml
echo 'linker = "aarch64-linux-gnu-gcc"' >> ~/.cargo/config.toml
- name: Build release
run: cargo build --release --target ${{ matrix.target }}
- name: Rename binary (Unix)
if: runner.os != 'Windows'
run: |
cp target/${{ matrix.target }}/release/proc ${{ matrix.artifact }}
chmod +x ${{ matrix.artifact }}
- name: Rename binary (Windows)
if: runner.os == 'Windows'
shell: pwsh
run: Copy-Item "target/${{ matrix.target }}/release/proc.exe" -Destination "${{ matrix.artifact }}"
- name: Create tarball (Unix)
if: runner.os != 'Windows'
run: tar -czvf ${{ matrix.artifact }}.tar.gz ${{ matrix.artifact }}
- name: Create zip (Windows)
if: runner.os == 'Windows'
shell: pwsh
run: Compress-Archive -Path ${{ matrix.artifact }} -DestinationPath "${{ matrix.artifact }}.zip"
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.artifact }}
path: |
${{ matrix.artifact }}
${{ matrix.artifact }}.tar.gz
${{ matrix.artifact }}.zip
if-no-files-found: warn
create-release:
name: Create Release
needs: build-release
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v4
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: artifacts
- name: Prepare release assets
run: |
mkdir -p release
find artifacts -type f -exec cp {} release/ \;
ls -la release/
- name: Generate checksums
working-directory: release
run: |
sha256sum * > checksums.txt
cat checksums.txt
- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
files: release/*
generate_release_notes: true
make_latest: true
publish-crate:
name: Publish to crates.io
needs: create-release
runs-on: ubuntu-latest
permissions:
id-token: write
contents: read
steps:
- uses: actions/checkout@v4
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
- name: Get crates.io token via OIDC
uses: rust-lang/crates-io-auth-action@v1
id: crates-io-auth
- name: Publish to crates.io
env:
CARGO_REGISTRY_TOKEN: ${{ steps.crates-io-auth.outputs.token }}
run: |
VERSION=$(grep '^version' Cargo.toml | head -1 | sed 's/.*"\(.*\)".*/\1/')
echo "Local version: $VERSION"
if cargo publish --allow-dirty 2>&1 | tee /tmp/publish.log; then
echo "Successfully published $VERSION to crates.io"
else
if grep -q "already exists" /tmp/publish.log; then
echo "Version $VERSION already published to crates.io, skipping"
else
echo "Failed to publish"
cat /tmp/publish.log
exit 1
fi
fi
publish-npm:
name: Publish to npm
needs: create-release
runs-on: ubuntu-latest
permissions:
id-token: write
contents: read
steps:
- uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '22'
registry-url: 'https://registry.npmjs.org'
- name: Publish to npm
working-directory: pkg/npm
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
run: |
VERSION=$(node -p "require('./package.json').version")
echo "Publishing version: $VERSION"
if npm publish --provenance --access public 2>&1 | tee /tmp/npm-publish.log; then
echo "Successfully published $VERSION to npm"
else
if grep -q "already exists" /tmp/npm-publish.log || grep -q "previously published" /tmp/npm-publish.log; then
echo "Version $VERSION already published to npm, skipping"
else
echo "Failed to publish"
cat /tmp/npm-publish.log
exit 1
fi
fi
update-homebrew:
name: Update Homebrew Tap
needs: create-release
runs-on: ubuntu-latest
steps:
- name: Checkout homebrew-proc tap
uses: actions/checkout@v4
with:
repository: yazeed/homebrew-proc
token: ${{ secrets.HOMEBREW_TAP_TOKEN }}
- name: Download checksums
run: |
gh release download ${{ github.ref_name }} --repo yazeed/proc --pattern "checksums.txt" --output checksums.txt
cat checksums.txt
env:
GH_TOKEN: ${{ github.token }}
- name: Update formula
run: |
VERSION="${{ github.ref_name }}"
VERSION="${VERSION#v}"
DARWIN_ARM64=$(grep "proc-darwin-aarch64.tar.gz" checksums.txt | cut -d' ' -f1)
DARWIN_X86=$(grep "proc-darwin-x86_64.tar.gz" checksums.txt | cut -d' ' -f1)
LINUX_ARM64=$(grep "proc-linux-aarch64.tar.gz" checksums.txt | cut -d' ' -f1)
LINUX_X86=$(grep "proc-linux-x86_64.tar.gz" checksums.txt | cut -d' ' -f1)
cat > Formula/proc.rb << EOF
class Proc < Formula
desc "Semantic CLI tool for process management"
homepage "https://github.com/yazeed/proc"
version "${VERSION}"
license "MIT"
on_macos do
if Hardware::CPU.arm?
url "https://github.com/yazeed/proc/releases/download/v#{version}/proc-darwin-aarch64.tar.gz"
sha256 "${DARWIN_ARM64}"
else
url "https://github.com/yazeed/proc/releases/download/v#{version}/proc-darwin-x86_64.tar.gz"
sha256 "${DARWIN_X86}"
end
end
on_linux do
if Hardware::CPU.arm?
url "https://github.com/yazeed/proc/releases/download/v#{version}/proc-linux-aarch64.tar.gz"
sha256 "${LINUX_ARM64}"
else
url "https://github.com/yazeed/proc/releases/download/v#{version}/proc-linux-x86_64.tar.gz"
sha256 "${LINUX_X86}"
end
end
def install
binary = Dir["proc-*"].first
bin.install binary => "proc"
end
test do
assert_match "proc", shell_output("#{bin}/proc --version")
end
end
EOF
# Remove leading spaces from heredoc
sed -i 's/^ //' Formula/proc.rb
- name: Commit and push
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add Formula/proc.rb
git diff --staged --quiet || git commit -m "proc ${{ github.ref_name }}"
git push
update-scoop:
name: Update Scoop Bucket
needs: create-release
runs-on: ubuntu-latest
steps:
- name: Checkout scoop-bucket-proc
uses: actions/checkout@v4
with:
repository: yazeed/scoop-bucket-proc
token: ${{ secrets.SCOOP_BUCKET_TOKEN }}
- name: Download checksums
run: |
gh release download ${{ github.ref_name }} --repo yazeed/proc --pattern "checksums.txt" --output checksums.txt
cat checksums.txt
env:
GH_TOKEN: ${{ github.token }}
- name: Update manifest
run: |
VERSION="${{ github.ref_name }}"
VERSION="${VERSION#v}"
WINDOWS_HASH=$(grep "proc-windows-x86_64.exe.zip" checksums.txt | cut -d' ' -f1)
cat > bucket/proc.json << 'EOF'
{
"version": "VERSION_PLACEHOLDER",
"description": "Semantic CLI tool for process management. Target by port, PID, name or path.",
"homepage": "https://github.com/yazeed/proc",
"license": "MIT",
"architecture": {
"64bit": {
"url": "https://github.com/yazeed/proc/releases/download/vVERSION_PLACEHOLDER/proc-windows-x86_64.exe.zip",
"hash": "HASH_PLACEHOLDER"
}
},
"bin": [["proc-windows-x86_64.exe", "proc"]],
"checkver": "github",
"autoupdate": {
"architecture": {
"64bit": {
"url": "https://github.com/yazeed/proc/releases/download/v$version/proc-windows-x86_64.exe.zip"
}
}
}
}
EOF
sed -i "s/VERSION_PLACEHOLDER/${VERSION}/g" bucket/proc.json
sed -i "s/HASH_PLACEHOLDER/${WINDOWS_HASH}/g" bucket/proc.json
sed -i 's/^ //' bucket/proc.json
- name: Commit and push
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add bucket/proc.json
git diff --staged --quiet || git commit -m "proc ${{ github.ref_name }}"
git push