Skip to content

Release version 0.1.16 #35

Release version 0.1.16

Release version 0.1.16 #35

name: Publish Platform Packages
on:
push:
branches: [br_release]
permissions:
contents: write
env:
# Version is read from package.json - update with: node scripts/update-version.js <version>
NPM_TAG: 'latest'
DRY_RUN: 'false'
jobs:
download-binaries:
name: Download gopher-orch binaries
runs-on: ubuntu-latest
outputs:
version: ${{ steps.version.outputs.version }}
version_tag: ${{ steps.version.outputs.version_tag }}
npm_version: ${{ steps.version.outputs.npm_version }}
dry_run: ${{ steps.version.outputs.dry_run }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Read version from package.json
id: version
run: |
VERSION=$(node -p "require('./package.json').version")
VERSION_TAG="v${VERSION}"
# Strip optional .A suffix (X.Y.Z.A -> X.Y.Z) for gopher-orch release tag
ORCH_VERSION=$(echo "$VERSION" | sed 's/^\([0-9]*\.[0-9]*\.[0-9]*\).*/\1/')
ORCH_TAG="v${ORCH_VERSION}"
# Convert X.Y.Z.A -> X.Y.Z-A for npm semver compatibility
NPM_VERSION=$(echo "$VERSION" | sed 's/^\([0-9]*\.[0-9]*\.[0-9]*\)\.\([0-9]*\)$/\1-\2/')
echo "version=${VERSION}" >> $GITHUB_OUTPUT
echo "version_tag=${VERSION_TAG}" >> $GITHUB_OUTPUT
echo "orch_tag=${ORCH_TAG}" >> $GITHUB_OUTPUT
echo "npm_version=${NPM_VERSION}" >> $GITHUB_OUTPUT
echo "dry_run=${{ env.DRY_RUN }}" >> $GITHUB_OUTPUT
echo "Version: ${VERSION}"
echo "Version Tag: ${VERSION_TAG}"
echo "Orch Tag: ${ORCH_TAG}"
echo "NPM Version: ${NPM_VERSION}"
- name: Download all release assets
env:
GH_TOKEN: ${{ secrets.GOPHER_ORCH_TOKEN }}
run: |
# Download all assets from the private gopher-orch repo
# Use orch_tag (X.Y.Z) to download from gopher-orch, stripping optional .A suffix
gh release download ${{ steps.version.outputs.orch_tag }} \
-R GopherSecurity/gopher-orch \
-D downloads
# Extract to platform-specific directories
mkdir -p artifacts/linux-x64 artifacts/linux-arm64
mkdir -p artifacts/darwin-x64 artifacts/darwin-arm64
mkdir -p artifacts/win32-x64 artifacts/win32-arm64
tar -xzf downloads/libgopher-orch-linux-x64.tar.gz -C artifacts/linux-x64
tar -xzf downloads/libgopher-orch-linux-arm64.tar.gz -C artifacts/linux-arm64
tar -xzf downloads/libgopher-orch-macos-x64.tar.gz -C artifacts/darwin-x64
tar -xzf downloads/libgopher-orch-macos-arm64.tar.gz -C artifacts/darwin-arm64
unzip -o downloads/libgopher-orch-windows-x64.zip -d artifacts/win32-x64
unzip -o downloads/libgopher-orch-windows-arm64.zip -d artifacts/win32-arm64
- name: List downloaded artifacts
run: |
echo "=== Downloaded artifacts ==="
find artifacts -type f \( -name "*.so" -o -name "*.dylib" -o -name "*.dll" \) | head -20
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: native-binaries
path: artifacts/
retention-days: 1
publish-platform-packages:
name: Publish ${{ matrix.platform }} package
needs: download-binaries
runs-on: ubuntu-latest
strategy:
matrix:
include:
- platform: darwin-arm64
lib_pattern: "*.dylib"
- platform: darwin-x64
lib_pattern: "*.dylib"
- platform: linux-arm64
lib_pattern: "*.so*"
- platform: linux-x64
lib_pattern: "*.so*"
- platform: win32-arm64
lib_pattern: "*.dll"
- platform: win32-x64
lib_pattern: "*.dll"
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
registry-url: 'https://registry.npmjs.org'
- name: Download artifacts
uses: actions/download-artifact@v4
with:
name: native-binaries
path: artifacts/
- name: Copy binaries to package
run: |
mkdir -p packages/${{ matrix.platform }}/lib
# Copy library files (handle various directory structures)
# Check lib/ directory
if [ -d "artifacts/${{ matrix.platform }}/lib" ]; then
cp artifacts/${{ matrix.platform }}/lib/${{ matrix.lib_pattern }} packages/${{ matrix.platform }}/lib/ 2>/dev/null || true
fi
# Check bin/ directory (Windows DLLs are here)
if [ -d "artifacts/${{ matrix.platform }}/bin" ]; then
cp artifacts/${{ matrix.platform }}/bin/${{ matrix.lib_pattern }} packages/${{ matrix.platform }}/lib/ 2>/dev/null || true
fi
# Check flat structure
cp artifacts/${{ matrix.platform }}/${{ matrix.lib_pattern }} packages/${{ matrix.platform }}/lib/ 2>/dev/null || true
# List what we copied
echo "=== Package contents for ${{ matrix.platform }} ==="
ls -la packages/${{ matrix.platform }}/lib/
- name: Update package version
run: |
cd packages/${{ matrix.platform }}
NPM_VERSION="${{ needs.download-binaries.outputs.npm_version }}"
echo "Setting package version to: ${NPM_VERSION}"
npm version "$NPM_VERSION" --no-git-tag-version --allow-same-version
- name: Publish to npm
if: ${{ env.DRY_RUN != 'true' }}
run: |
cd packages/${{ matrix.platform }}
npm publish --access public --tag ${{ env.NPM_TAG }}
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Dry run - show package contents
if: ${{ env.DRY_RUN == 'true' }}
run: |
cd packages/${{ matrix.platform }}
echo "=== Would publish package ==="
cat package.json
echo ""
echo "=== Library files ==="
ls -la lib/
publish-main-package:
name: Publish main package
needs: [download-binaries, publish-platform-packages]
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
registry-url: 'https://registry.npmjs.org'
- name: Install dependencies
run: npm install --ignore-optional
- name: Build
run: npm run build
- name: Set npm-compatible version
run: |
NPM_VERSION="${{ needs.download-binaries.outputs.npm_version }}"
PKG_VERSION=$(node -p "require('./package.json').version")
echo "NPM version: ${NPM_VERSION}"
echo "Package version: ${PKG_VERSION}"
# Always set npm-compatible version (converts X.Y.Z.A to X.Y.Z-A)
npm version "$NPM_VERSION" --no-git-tag-version --allow-same-version
# Update optionalDependencies to use the npm-compatible version
node -e "
const fs = require('fs');
const pkg = JSON.parse(fs.readFileSync('package.json', 'utf8'));
if (pkg.optionalDependencies) {
for (const dep of Object.keys(pkg.optionalDependencies)) {
if (dep.startsWith('@gopher.security/gopher-orch-')) {
pkg.optionalDependencies[dep] = '${NPM_VERSION}';
}
}
fs.writeFileSync('package.json', JSON.stringify(pkg, null, 2) + '\n');
}
"
echo "Final package.json:"
cat package.json | grep -A 10 optionalDependencies
- name: Publish to npm
if: ${{ env.DRY_RUN != 'true' }}
run: npm publish --access public --tag ${{ env.NPM_TAG }}
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Dry run - show package info
if: ${{ env.DRY_RUN == 'true' }}
run: |
echo "=== Would publish main package ==="
cat package.json
create-release:
name: Create GitHub Release
needs: [download-binaries, publish-main-package]
runs-on: ubuntu-latest
if: needs.download-binaries.outputs.dry_run != 'true'
permissions:
contents: write
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Generate release notes
run: |
VERSION="${{ needs.download-binaries.outputs.version }}"
VERSION_TAG="${{ needs.download-binaries.outputs.version_tag }}"
# Build Information
NPM_VERSION="${{ needs.download-binaries.outputs.npm_version }}"
cat > RELEASE_NOTES.md << EOF
**npm:** https://www.npmjs.com/package/@gopher.security/gopher-mcp-js
## Build Information
- **Date:** $(date -u +"%Y-%m-%d %H:%M:%S UTC")
- **Commit:** ${{ github.sha }}
- **Version:** ${VERSION}
- **npm package:** \`@gopher.security/gopher-mcp-js@${NPM_VERSION}\`
- **Install:** \`npm install @gopher.security/gopher-mcp-js@${NPM_VERSION}\`
EOF
# Extract What's Changed from CHANGELOG.md
echo "## What's Changed" >> RELEASE_NOTES.md
echo "" >> RELEASE_NOTES.md
if [ -f "CHANGELOG.md" ]; then
# First try: extract the current version's section [X.Y.Z] or [X.Y.Z.A]
# (dump-version.sh converts [Unreleased] to [X.Y.Z] before push)
ESCAPED_VERSION=$(echo "$VERSION" | sed 's/\./\\./g')
sed -n "/^## \[${ESCAPED_VERSION}\]/,/^## \[/p" CHANGELOG.md | \
grep -v "^## \[" | \
sed '/^$/d' >> RELEASE_NOTES.md || true
# Fallback: try [Unreleased] section if version section not found
if [ $(wc -l < RELEASE_NOTES.md) -le 10 ]; then
sed -n '/^## \[Unreleased\]/,/^## \[/p' CHANGELOG.md | \
grep -v "^## \[" | \
sed '/^$/d' >> RELEASE_NOTES.md || true
fi
# Final fallback: get the first versioned section
if [ $(wc -l < RELEASE_NOTES.md) -le 10 ]; then
sed -n '/^## \[[0-9]/,/^## \[/p' CHANGELOG.md | \
head -50 | \
grep -v "^## \[" >> RELEASE_NOTES.md || true
fi
fi
# If still empty, list recent commits
if [ $(wc -l < RELEASE_NOTES.md) -le 10 ]; then
echo "### Changed" >> RELEASE_NOTES.md
echo "" >> RELEASE_NOTES.md
git log --pretty=format:"- %s" --no-merges -20 >> RELEASE_NOTES.md || true
fi
# Add full changelog link
PREV_TAG=$(git tag --sort=-creatordate | grep -E "^v[0-9]" | grep -v "^${VERSION_TAG}$" | head -1)
if [ -n "$PREV_TAG" ]; then
echo "" >> RELEASE_NOTES.md
echo "**Full Changelog**: https://github.com/${{ github.repository }}/compare/${PREV_TAG}...${VERSION_TAG}" >> RELEASE_NOTES.md
fi
echo ""
echo "=== Release Notes ==="
cat RELEASE_NOTES.md
- name: Create GitHub Release
uses: softprops/action-gh-release@v1
with:
tag_name: ${{ needs.download-binaries.outputs.version_tag }}
name: gopher-orch ${{ needs.download-binaries.outputs.version_tag }}
body_path: RELEASE_NOTES.md
draft: false
prerelease: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}