Files
feynman/.github/workflows/publish.yml
2026-03-25 01:06:11 -07:00

172 lines
5.7 KiB
YAML

name: Publish and Release
env:
FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: "true"
on:
push:
branches: [main]
workflow_dispatch:
jobs:
version-check:
runs-on: blacksmith-4vcpu-ubuntu-2404
outputs:
version: ${{ steps.version.outputs.version }}
should_publish: ${{ steps.version.outputs.should_publish }}
steps:
- uses: actions/checkout@v6
- uses: actions/setup-node@v5
with:
node-version: 24.14.0
- id: version
shell: bash
run: |
CURRENT=$(npm view @companion-ai/feynman version 2>/dev/null || echo "0.0.0")
LOCAL=$(node -p "require('./package.json').version")
echo "version=$LOCAL" >> "$GITHUB_OUTPUT"
if [ "$CURRENT" != "$LOCAL" ]; then
echo "should_publish=true" >> "$GITHUB_OUTPUT"
else
echo "should_publish=false" >> "$GITHUB_OUTPUT"
fi
publish-npm:
needs: version-check
if: needs.version-check.outputs.should_publish == 'true'
runs-on: blacksmith-4vcpu-ubuntu-2404
permissions:
contents: read
steps:
- uses: actions/checkout@v6
- uses: actions/setup-node@v5
with:
node-version: 24.14.0
registry-url: https://registry.npmjs.org
- run: npm ci --ignore-scripts
- run: npm run build
- run: npm test
- run: npm publish --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
build-native-bundles:
needs: version-check
strategy:
fail-fast: false
matrix:
include:
- id: linux-x64
os: blacksmith-4vcpu-ubuntu-2404
- id: darwin-x64
os: macos-15-intel
- id: darwin-arm64
os: macos-14
- id: win32-x64
os: blacksmith-4vcpu-windows-2025
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v6
- uses: actions/setup-node@v5
with:
node-version: 24.14.0
- run: npm ci --ignore-scripts
- run: npm run build
- run: npm run build:native-bundle
- name: Smoke native bundle (Unix)
if: matrix.id != 'win32-x64'
shell: bash
run: |
VERSION=$(node -p "require('./package.json').version")
tmp=$(mktemp -d)
tar -xzf "dist/release/feynman-${VERSION}-${{ matrix.id }}.tar.gz" -C "$tmp"
"$tmp/feynman-${VERSION}-${{ matrix.id }}/feynman" --help >/tmp/feynman-help.out
head -20 /tmp/feynman-help.out
- name: Smoke native bundle (Windows)
if: matrix.id == 'win32-x64'
shell: pwsh
run: |
$version = node -p "require('./package.json').version"
$tmp = Join-Path $env:RUNNER_TEMP ("feynman-smoke-" + [guid]::NewGuid().ToString("N"))
New-Item -ItemType Directory -Path $tmp | Out-Null
Expand-Archive -LiteralPath "dist/release/feynman-$version-win32-x64.zip" -DestinationPath $tmp -Force
$bundleRoot = Join-Path $tmp "feynman-$version-win32-x64"
& (Join-Path $bundleRoot "feynman.cmd") --help | Select-Object -First 20
- uses: actions/upload-artifact@v4
with:
name: native-${{ matrix.id }}
path: dist/release/*
release-edge:
needs:
- version-check
- build-native-bundles
if: needs.build-native-bundles.result == 'success'
runs-on: blacksmith-4vcpu-ubuntu-2404
permissions:
contents: write
steps:
- uses: actions/download-artifact@v4
with:
path: release-assets
merge-multiple: true
- shell: bash
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
VERSION: ${{ needs.version-check.outputs.version }}
run: |
NOTES="Rolling Feynman bundles from main for the curl/PowerShell installer."
if gh release view edge >/dev/null 2>&1; then
gh release view edge --json assets --jq '.assets[].name' | while IFS= read -r asset; do
[ -n "$asset" ] || continue
gh release delete-asset edge "$asset" --yes
done
gh release upload edge release-assets/*
gh release edit edge \
--title "edge" \
--notes "$NOTES" \
--prerelease \
--draft=false \
--target "$GITHUB_SHA"
else
gh release create edge release-assets/* \
--title "edge" \
--notes "$NOTES" \
--prerelease \
--latest=false \
--target "$GITHUB_SHA"
fi
release-github:
needs:
- version-check
- publish-npm
- build-native-bundles
if: needs.version-check.outputs.should_publish == 'true' && needs.build-native-bundles.result == 'success' && needs.publish-npm.result == 'success'
runs-on: blacksmith-4vcpu-ubuntu-2404
permissions:
contents: write
steps:
- uses: actions/download-artifact@v4
with:
path: release-assets
merge-multiple: true
- shell: bash
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
VERSION: ${{ needs.version-check.outputs.version }}
run: |
if gh release view "v$VERSION" >/dev/null 2>&1; then
gh release upload "v$VERSION" release-assets/* --clobber
gh release edit "v$VERSION" \
--title "v$VERSION" \
--notes "Standalone Feynman bundles for native installation." \
--draft=false \
--target "$GITHUB_SHA"
else
gh release create "v$VERSION" release-assets/* \
--title "v$VERSION" \
--notes "Standalone Feynman bundles for native installation." \
--target "$GITHUB_SHA"
fi