Skip to content

Add cover image, GitHub topics, and commandcode branding #2

Add cover image, GitHub topics, and commandcode branding

Add cover image, GitHub topics, and commandcode branding #2

Workflow file for this run

name: Release
on:
push:
branches: [main]
concurrency: ${{ github.workflow }}-${{ github.ref }}
jobs:
test-rust:
strategy:
matrix:
include:
- os: macos-latest
target: aarch64-apple-darwin
- os: ubuntu-latest
target: x86_64-unknown-linux-gnu
- os: windows-latest
target: x86_64-pc-windows-msvc
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
- name: Run Rust tests
working-directory: rust
run: cargo test
build-binaries:
needs: test-rust
strategy:
matrix:
include:
- target: aarch64-apple-darwin
os: macos-latest
npm_pkg: darwin-arm64
binary: kill-the-port
- target: x86_64-apple-darwin
os: macos-latest
npm_pkg: darwin-x64
binary: kill-the-port
- target: x86_64-unknown-linux-gnu
os: ubuntu-latest
npm_pkg: linux-x64
binary: kill-the-port
- target: aarch64-unknown-linux-gnu
os: ubuntu-latest
npm_pkg: linux-arm64
binary: kill-the-port
- target: x86_64-pc-windows-msvc
os: windows-latest
npm_pkg: win32-x64
binary: kill-the-port.exe
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- name: Install Rust
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
- name: Build
working-directory: rust
run: cargo build --release --target ${{ matrix.target }}
env:
CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER: aarch64-linux-gnu-gcc
- name: Move binary
shell: bash
run: |
mkdir -p npm/${{ matrix.npm_pkg }}/bin
cp rust/target/${{ matrix.target }}/release/${{ matrix.binary }} npm/${{ matrix.npm_pkg }}/bin/
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: binary-${{ matrix.npm_pkg }}
path: npm/${{ matrix.npm_pkg }}/bin/
release:
needs: build-binaries
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 22
registry-url: 'https://registry.npmjs.org'
- name: Download all binaries
uses: actions/download-artifact@v4
with:
pattern: binary-*
merge-multiple: false
- name: Place binaries
run: |
for dir in binary-*; do
pkg="${dir#binary-}"
mkdir -p "npm/${pkg}/bin"
cp "${dir}"/* "npm/${pkg}/bin/"
chmod +x "npm/${pkg}/bin/"* 2>/dev/null || true
done
- run: npm ci
- run: npm run lint
- run: npm run build
- name: Create Release Pull Request or Publish
id: changesets
uses: changesets/action@v1
with:
publish: npm run release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Publish platform packages
if: steps.changesets.outputs.published == 'true'
run: |
for pkg in npm/*/; do
echo "Publishing ${pkg}..."
cd "${pkg}"
npm publish --access public || true
cd ../..
done
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}