Skip to content

feat: 0.2.4 — slim npm package, always download binary from GitHub #4

feat: 0.2.4 — slim npm package, always download binary from GitHub

feat: 0.2.4 — slim npm package, always download binary from GitHub #4

Workflow file for this run

name: Release CLI
on:
push:
tags:
- "v*"
permissions:
contents: write
jobs:
build:
name: Build ${{ matrix.artifact }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- os: macos-latest # Apple Silicon (arm64)
artifact: muapi-darwin-arm64
- os: ubuntu-22.04 # Linux x86_64
artifact: muapi-linux-x86_64
- os: ubuntu-24.04-arm # Linux arm64
artifact: muapi-linux-arm64
- os: windows-latest # Windows x86_64
artifact: muapi-windows-x86_64.exe
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.11"
- name: Install CLI + PyInstaller
run: |
pip install --upgrade pip
pip install .
pip install pyinstaller
- name: Build binary (Unix)
if: runner.os != 'Windows'
run: |
pyinstaller \
--onefile \
--name muapi \
--distpath ./dist \
cli_entry.py
- name: Build binary (Windows)
if: runner.os == 'Windows'
shell: pwsh
run: |
pyinstaller `
--onefile `
--name muapi `
--distpath ./dist `
cli_entry.py
- name: Rename artifact (Unix)
if: runner.os != 'Windows'
run: mv dist/muapi dist/${{ matrix.artifact }}
- name: Rename artifact (Windows)
if: runner.os == 'Windows'
shell: pwsh
run: Move-Item dist\muapi.exe dist\${{ matrix.artifact }}
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.artifact }}
path: dist/${{ matrix.artifact }}
retention-days: 1
release:
name: Create GitHub Release
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: artifacts
- name: Flatten artifact directories
run: |
mkdir -p release_assets
find artifacts -type f -exec cp {} release_assets/ \;
chmod +x release_assets/muapi-darwin-* release_assets/muapi-linux-* 2>/dev/null || true
ls -lh release_assets/
- name: Create Release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ github.ref_name }}
name: muapi-cli ${{ github.ref_name }}
body: |
## muapi-cli ${{ github.ref_name }}
### Install via npm
```bash
npm install -g muapi-cli
```
### Install via pip
```bash
pip install muapi-cli
```
### Manual binary download
| Platform | Binary |
|---|---|
| macOS Apple Silicon | `muapi-darwin-arm64` |
| Linux x86_64 | `muapi-linux-x86_64` |
| Linux ARM64 | `muapi-linux-arm64` |
| Windows x86_64 | `muapi-windows-x86_64.exe` |
draft: false
prerelease: false
files: release_assets/*
publish-npm:
name: Publish to npm
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: "20"
registry-url: "https://registry.npmjs.org"
- name: Set version from tag
run: |
VERSION="${GITHUB_REF_NAME#v}"
jq --arg v "$VERSION" '.version = $v' npm/package.json > /tmp/pkg.json
mv /tmp/pkg.json npm/package.json
echo "Publishing npm version $VERSION"
- name: Publish
run: npm publish --access public
working-directory: npm
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
publish-pypi:
name: Publish to PyPI
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.11"
- name: Set version from tag
run: |
VERSION="${GITHUB_REF_NAME#v}"
sed -i "s/^version = .*/version = \"$VERSION\"/" pyproject.toml
echo "Publishing PyPI version $VERSION"
- name: Build
run: |
pip install hatch
hatch build
- name: Publish
uses: pypa/gh-action-pypi-publish@release/v1
with:
packages-dir: dist/
password: ${{ secrets.PYPI_TOKEN }}