Files
personamanagmentlayer__pcl/.github/workflows/release.yml
dependabot[bot] 5b1f361746 ci(deps)(deps): bump actions/upload-artifact from 4 to 7 (#37)
Bumps [actions/upload-artifact](https://github.com/actions/upload-artifact) from 4 to 7.
- [Release notes](https://github.com/actions/upload-artifact/releases)
- [Commits](https://github.com/actions/upload-artifact/compare/v4...v7)

---
updated-dependencies:
- dependency-name: actions/upload-artifact
  dependency-version: '7'
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2026-09-05 05:10:11 +02:00

277 lines
9.5 KiB
YAML

name: Release
on:
push:
tags:
- 'v*.*.*'
workflow_dispatch:
inputs:
version:
description: 'Release version (e.g., 1.0.1)'
required: true
type: string
permissions:
contents: write
packages: write
jobs:
# ═══════════════════════════════════════════════════════════════════════════
# VALIDATE RELEASE
# ═══════════════════════════════════════════════════════════════════════════
validate:
name: Validate Release
runs-on: ubuntu-latest
outputs:
version: ${{ steps.version.outputs.version }}
steps:
- name: 📥 Checkout code
uses: actions/checkout@v6
with:
fetch-depth: 0
- name: 🔧 Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'npm'
- name: 📦 Install dependencies
run: npm ci
- name: 🔍 Extract version
id: version
run: |
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
VERSION="${{ github.event.inputs.version }}"
else
VERSION=${GITHUB_REF#refs/tags/v}
fi
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "📌 Release version: $VERSION"
- name: ✅ Verify package.json version
run: |
PKG_VERSION=$(node -p "require('./package.json').version")
RELEASE_VERSION="${{ steps.version.outputs.version }}"
if [ "$PKG_VERSION" != "$RELEASE_VERSION" ]; then
echo "❌ Version mismatch: package.json=$PKG_VERSION, release=$RELEASE_VERSION"
exit 1
fi
echo "✅ Version matches: $PKG_VERSION"
- name: 🧪 Run full test suite
run: npm test
- name: 🏗️ Build for release
run: npm run build
# ═══════════════════════════════════════════════════════════════════════════
# BUILD RELEASE
# ═══════════════════════════════════════════════════════════════════════════
build:
name: Build Release Assets
runs-on: ubuntu-latest
needs: [validate]
steps:
- name: 📥 Checkout code
uses: actions/checkout@v6
- name: 🔧 Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'npm'
- name: 📦 Install dependencies
run: npm ci
- name: 🏗️ Build project
run: npm run build:all
- name: 📦 Create tarball
run: npm pack
- name: 📤 Upload package artifact
uses: actions/upload-artifact@v7
with:
name: npm-package
path: '*.tgz'
- name: 📤 Upload dist artifact
uses: actions/upload-artifact@v7
with:
name: dist-release
path: dist/
# ═══════════════════════════════════════════════════════════════════════════
# PUBLISH TO NPM
# ═══════════════════════════════════════════════════════════════════════════
publish-npm:
name: Publish to npm
runs-on: ubuntu-latest
needs: [validate, build]
if: startsWith(github.ref, 'refs/tags/v')
steps:
- name: 📥 Checkout code
uses: actions/checkout@v6
- name: 🔧 Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
registry-url: 'https://registry.npmjs.org'
cache: 'npm'
- name: 📦 Install dependencies
run: npm ci
- name: 📥 Download build artifacts
uses: actions/download-artifact@v8
with:
name: dist-release
path: dist/
- name: 📤 Publish to npm (public)
run: npm publish --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: ✅ Verify npm publication
run: |
VERSION="${{ needs.validate.outputs.version }}"
echo "⏳ Waiting for npm registry propagation..."
sleep 30
npm view @pcl/sdk@$VERSION version
# ═══════════════════════════════════════════════════════════════════════════
# PUBLISH TO GITHUB PACKAGES
# ═══════════════════════════════════════════════════════════════════════════
publish-github:
name: Publish to GitHub Packages
runs-on: ubuntu-latest
needs: [validate, build]
if: startsWith(github.ref, 'refs/tags/v')
steps:
- name: 📥 Checkout code
uses: actions/checkout@v6
- name: 🔧 Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
registry-url: 'https://npm.pkg.github.com'
cache: 'npm'
- name: 📦 Install dependencies
run: npm ci
- name: 📥 Download build artifacts
uses: actions/download-artifact@v8
with:
name: dist-release
path: dist/
- name: 📤 Publish to GitHub Packages
run: npm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# ═══════════════════════════════════════════════════════════════════════════
# CREATE GITHUB RELEASE
# ═══════════════════════════════════════════════════════════════════════════
github-release:
name: Create GitHub Release
runs-on: ubuntu-latest
needs: [validate, build, publish-npm]
if: startsWith(github.ref, 'refs/tags/v')
steps:
- name: 📥 Checkout code
uses: actions/checkout@v6
with:
fetch-depth: 0
- name: 📥 Download package artifact
uses: actions/download-artifact@v8
with:
name: npm-package
- name: 📝 Generate release notes
id: release_notes
run: |
VERSION="${{ needs.validate.outputs.version }}"
PREV_TAG=$(git describe --tags --abbrev=0 HEAD^ 2>/dev/null || echo "")
if [ -z "$PREV_TAG" ]; then
CHANGELOG=$(git log --pretty=format:"- %s" --no-merges)
else
CHANGELOG=$(git log $PREV_TAG..HEAD --pretty=format:"- %s" --no-merges)
fi
cat > release_notes.md << EOF
# PCL v$VERSION
## 🚀 What's New
$CHANGELOG
## 📦 Installation
\`\`\`bash
npm install @pcl/sdk@$VERSION
\`\`\`
## 📚 Documentation
- [GitHub Repository](https://github.com/personamanagmentlayer/pcl)
- [Package on npm](https://www.npmjs.com/package/@pcl/sdk)
## 🐛 Bug Reports
Please report issues at: https://github.com/personamanagmentlayer/pcl/issues
EOF
echo "release_notes<<EOF" >> $GITHUB_OUTPUT
cat release_notes.md >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
- name: 🎉 Create GitHub Release
uses: softprops/action-gh-release@v1
with:
name: v${{ needs.validate.outputs.version }}
body: ${{ steps.release_notes.outputs.release_notes }}
files: '*.tgz'
draft: false
prerelease: ${{ contains(needs.validate.outputs.version, '-') }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# ═══════════════════════════════════════════════════════════════════════════
# NOTIFY
# ═══════════════════════════════════════════════════════════════════════════
notify:
name: 📢 Notify Release
runs-on: ubuntu-latest
needs: [validate, github-release]
if: startsWith(github.ref, 'refs/tags/v')
steps:
- name: 🎉 Release notification
run: |
VERSION="${{ needs.validate.outputs.version }}"
echo "✅ PCL v$VERSION has been successfully released!"
echo "📦 npm: https://www.npmjs.com/package/@pcl/sdk/v/$VERSION"
echo "🐙 GitHub: https://github.com/personamanagmentlayer/pcl/releases/tag/v$VERSION"