Release: 1.1.7-beta.1751879666 (#247) #36
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Release (Simplified) | |
on: | |
push: | |
branches: | |
- main | |
concurrency: ${{ github.workflow }}-${{ github.ref }} | |
jobs: | |
release: | |
name: Release | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write | |
issues: write | |
pull-requests: write | |
id-token: write | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Setup Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: '22.10.0' | |
registry-url: 'https://registry.npmjs.org/' | |
- name: Setup pnpm | |
uses: pnpm/action-setup@v2 | |
with: | |
version: latest | |
- name: Install dependencies | |
run: pnpm install | |
- name: Run quality checks | |
run: | | |
echo "Running type checks..." | |
pnpm typecheck | |
pnpm -r typecheck || true | |
echo "Running linting..." | |
pnpm lint | |
pnpm -r lint || true | |
- name: Build packages | |
run: | | |
echo "Building all packages..." | |
pnpm build:all | |
- name: Check beta versions | |
id: check-versions | |
run: | | |
# Check if any package has beta version | |
HAS_BETA=false | |
BETA_PACKAGES="" | |
# Check main package | |
MAIN_VERSION=$(node -p "require('./package.json').version") | |
if [[ $MAIN_VERSION == *"-beta"* ]]; then | |
HAS_BETA=true | |
BETA_PACKAGES="vue-pivottable" | |
# Extract base version without beta suffix for release branch | |
BASE_VERSION=$(echo $MAIN_VERSION | sed 's/-beta.*//') | |
echo "base_version=$BASE_VERSION" >> $GITHUB_OUTPUT | |
fi | |
# Check sub-packages | |
for pkg in packages/*/; do | |
if [ -d "$pkg" ] && [ -f "$pkg/package.json" ]; then | |
PKG_NAME=$(basename "$pkg") | |
PKG_VERSION=$(cd "$pkg" && node -p "require('./package.json').version") | |
if [[ $PKG_VERSION == *"-beta"* ]]; then | |
HAS_BETA=true | |
BETA_PACKAGES="$BETA_PACKAGES $PKG_NAME" | |
fi | |
fi | |
done | |
echo "has_beta=$HAS_BETA" >> $GITHUB_OUTPUT | |
echo "beta_packages=$BETA_PACKAGES" >> $GITHUB_OUTPUT | |
# Use main package version for release branch, or highest version | |
if [ -z "${BASE_VERSION}" ]; then | |
# If main package is not beta, use its version for release branch | |
BASE_VERSION=$(echo $MAIN_VERSION | sed 's/-beta.*//') | |
echo "base_version=$BASE_VERSION" >> $GITHUB_OUTPUT | |
fi | |
echo "Found beta packages: $BETA_PACKAGES" | |
- name: Update versions to stable | |
if: steps.check-versions.outputs.has_beta == 'true' | |
run: | | |
# Update main package only if it has beta | |
MAIN_VERSION=$(node -p "require('./package.json').version") | |
if [[ $MAIN_VERSION == *"-beta"* ]]; then | |
npm version ${{ steps.check-versions.outputs.base_version }} --no-git-tag-version | |
fi | |
# Update sub-packages | |
for pkg in packages/*/; do | |
if [ -d "$pkg" ] && [ -f "$pkg/package.json" ]; then | |
cd "$pkg" | |
PKG_VERSION=$(node -p "require('./package.json').version") | |
if [[ $PKG_VERSION == *"-beta"* ]]; then | |
# Remove all beta suffixes (handle multiple -beta occurrences) | |
PKG_BASE=$(echo $PKG_VERSION | sed 's/-beta.*$//') | |
npm version $PKG_BASE --no-git-tag-version | |
fi | |
cd - | |
fi | |
done | |
- name: Create release branch | |
id: create-release | |
if: steps.check-versions.outputs.has_beta == 'true' | |
run: | | |
VERSION=${{ steps.check-versions.outputs.base_version }} | |
RELEASE_BRANCH="release/v${VERSION}" | |
# Delete existing release branch if it exists | |
git push origin --delete $RELEASE_BRANCH 2>/dev/null || echo "No existing branch to delete" | |
git checkout -b $RELEASE_BRANCH | |
git config user.name "github-actions[bot]" | |
git config user.email "github-actions[bot]@users.noreply.github.com" | |
git add -A | |
git commit -m "chore: release v${VERSION}" || echo "No changes" | |
git push origin $RELEASE_BRANCH | |
echo "release_branch=$RELEASE_BRANCH" >> $GITHUB_OUTPUT | |
echo "version=$VERSION" >> $GITHUB_OUTPUT | |
- name: Checkout release branch | |
if: steps.check-versions.outputs.has_beta == 'true' | |
run: | | |
git checkout ${{ steps.create-release.outputs.release_branch }} | |
git pull origin ${{ steps.create-release.outputs.release_branch }} | |
- name: Publish to npm | |
if: steps.check-versions.outputs.has_beta == 'true' | |
run: | | |
# Publish with latest tag | |
node scripts/release-packages.cjs | |
env: | |
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | |
NPM_TOKEN: ${{ secrets.NPM_TOKEN }} | |
NPM_TOKEN_SUMIN: ${{ secrets.NPM_TOKEN_SUMIN }} | |
- name: Create GitHub Releases | |
if: steps.check-versions.outputs.has_beta == 'true' | |
run: | | |
# Create release for each package with stable version | |
create_release() { | |
local PKG_NAME=$1 | |
local PKG_VERSION=$2 | |
local NPM_NAME=$3 | |
echo "Creating release for $PKG_NAME@$PKG_VERSION" | |
# Delete existing beta release if it exists | |
gh release delete "${PKG_NAME}@${PKG_VERSION}" --yes 2>/dev/null || true | |
gh release create "${PKG_NAME}@${PKG_VERSION}" \ | |
--title "${PKG_NAME}@${PKG_VERSION}" \ | |
--notes "## 🚀 Stable Release | |
This release promotes the beta version to stable. | |
Install with: \`npm install ${NPM_NAME}@latest\` | |
### Version: ${PKG_VERSION}" \ | |
--target ${{ github.sha }} | |
} | |
# Get version info from current branch | |
VERSION="${{ steps.create-release.outputs.version }}" | |
# Check main package | |
MAIN_VERSION=$(node -p "require('./package.json').version") | |
if [ "$MAIN_VERSION" = "$VERSION" ]; then | |
create_release "vue-pivottable" "$MAIN_VERSION" "vue-pivottable" | |
fi | |
# Check sub-packages | |
for pkg in packages/*/; do | |
if [ -d "$pkg" ] && [ -f "$pkg/package.json" ]; then | |
FULL_PKG_NAME=$(cd "$pkg" && node -p "require('./package.json').name") | |
PKG_VERSION=$(cd "$pkg" && node -p "require('./package.json').version") | |
# Only create release if version doesn't contain beta | |
if [[ $PKG_VERSION != *"-beta"* ]]; then | |
create_release "$FULL_PKG_NAME" "$PKG_VERSION" "$FULL_PKG_NAME" | |
fi | |
fi | |
done | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Sync with develop | |
if: steps.check-versions.outputs.has_beta == 'true' | |
run: | | |
# Configure git | |
git config user.name "github-actions[bot]" | |
git config user.email "github-actions[bot]@users.noreply.github.com" | |
# Fetch latest develop | |
git fetch origin develop:develop | |
# Merge release branch into develop | |
git checkout develop | |
git merge ${{ steps.create-release.outputs.release_branch }} --no-edit -m "chore: sync release ${{ steps.create-release.outputs.release_branch }} to develop" | |
git push origin develop | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Create PR to main | |
if: steps.check-versions.outputs.has_beta == 'true' | |
run: | | |
VERSION="${{ steps.create-release.outputs.release_branch }}" | |
gh pr create \ | |
--base main \ | |
--head "${{ steps.create-release.outputs.release_branch }}" \ | |
--title "chore: update main with $VERSION" \ | |
--body "## 📦 Release Update | |
This PR updates main branch with: | |
- ✅ Stable version numbers (beta suffix removed) | |
- ✅ Updated package.json files | |
- ✅ npm packages published | |
- ✅ GitHub releases created | |
### Published Packages | |
$(node -p " | |
const main = require('./package.json'); | |
let packages = \`- vue-pivottable@\${main.version}\`; | |
const fs = require('fs'); | |
const path = require('path'); | |
const packagesDir = './packages'; | |
if (fs.existsSync(packagesDir)) { | |
fs.readdirSync(packagesDir).forEach(dir => { | |
const pkgPath = path.join(packagesDir, dir, 'package.json'); | |
if (fs.existsSync(pkgPath)) { | |
const pkg = require(path.resolve(pkgPath)); | |
packages += \`\\n- \${pkg.name}@\${pkg.version}\`; | |
} | |
}); | |
} | |
packages | |
") | |
**Note**: This release has been automatically synced with develop branch." \ | |
|| echo "PR to main already exists or creation failed" | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |