1+ name : Release Branch Deploy
2+
3+ on :
4+ push :
5+ branches :
6+ - ' release/v*'
7+
8+ concurrency : ${{ github.workflow }}-${{ github.ref }}
9+
10+ jobs :
11+ deploy-and-sync :
12+ name : Deploy and Sync
13+ runs-on : ubuntu-latest
14+ permissions :
15+ contents : write
16+ issues : write
17+ pull-requests : write
18+ id-token : write
19+ steps :
20+ - name : Checkout
21+ uses : actions/checkout@v4
22+ with :
23+ fetch-depth : 0
24+ token : ${{ secrets.GITHUB_TOKEN }}
25+
26+ - name : Setup Node.js
27+ uses : actions/setup-node@v4
28+ with :
29+ node-version : ' 22.10.0'
30+ registry-url : ' https://registry.npmjs.org/'
31+
32+ - name : Setup pnpm
33+ uses : pnpm/action-setup@v2
34+ with :
35+ version : latest
36+
37+ - name : Install dependencies
38+ run : pnpm install
39+
40+ - name : Build packages
41+ run : |
42+ echo "Building all packages..."
43+ pnpm build:all
44+
45+ - name : Publish to npm
46+ run : |
47+ # Publish with latest tag
48+ node scripts/release-packages.cjs
49+ env :
50+ NODE_AUTH_TOKEN : ${{ secrets.NPM_TOKEN }}
51+ NPM_TOKEN : ${{ secrets.NPM_TOKEN }}
52+ NPM_TOKEN_SUMIN : ${{ secrets.NPM_TOKEN_SUMIN }}
53+
54+ - name : Create GitHub Releases
55+ run : |
56+ # Create release for each package with stable version
57+ create_release() {
58+ local PKG_NAME=$1
59+ local PKG_VERSION=$2
60+ local NPM_NAME=$3
61+
62+ echo "Creating release for $PKG_NAME@$PKG_VERSION"
63+
64+ # Delete existing beta release if it exists
65+ gh release delete "${PKG_NAME}@${PKG_VERSION}" --yes 2>/dev/null || true
66+
67+ gh release create "${PKG_NAME}@${PKG_VERSION}" \
68+ --title "${PKG_NAME}@${PKG_VERSION}" \
69+ --notes "## 🚀 Stable Release
70+
71+ This release promotes the beta version to stable.
72+
73+ Install with: \`npm install ${NPM_NAME}@latest\`
74+
75+ ### Version: ${PKG_VERSION}" \
76+ --target ${{ github.sha }}
77+ }
78+
79+ # Get version info from current branch
80+ CURRENT_BRANCH="${{ github.ref_name }}"
81+ VERSION="${CURRENT_BRANCH#release/v}"
82+
83+ # Check main package
84+ MAIN_VERSION=$(node -p "require('./package.json').version")
85+ if [ "$MAIN_VERSION" = "$VERSION" ]; then
86+ create_release "vue-pivottable" "$MAIN_VERSION" "vue-pivottable"
87+ fi
88+
89+ # Check sub-packages
90+ for pkg in packages/*/; do
91+ if [ -d "$pkg" ] && [ -f "$pkg/package.json" ]; then
92+ FULL_PKG_NAME=$(cd "$pkg" && node -p "require('./package.json').name")
93+ PKG_VERSION=$(cd "$pkg" && node -p "require('./package.json').version")
94+
95+ # Only create release if version doesn't contain beta
96+ if [[ $PKG_VERSION != *"-beta"* ]]; then
97+ create_release "$FULL_PKG_NAME" "$PKG_VERSION" "$FULL_PKG_NAME"
98+ fi
99+ fi
100+ done
101+ env :
102+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
103+
104+ - name : Sync with develop
105+ run : |
106+ # Configure git
107+ git config user.name "github-actions[bot]"
108+ git config user.email "github-actions[bot]@users.noreply.github.com"
109+
110+ # Create a temporary branch for merging
111+ TEMP_BRANCH="temp-sync-$(date +%s)"
112+ git checkout -b $TEMP_BRANCH
113+
114+ # Merge into develop
115+ git checkout develop
116+ git pull origin develop
117+ git merge $TEMP_BRANCH --no-edit -m "chore: sync release ${{ github.ref_name }} to develop"
118+ git push origin develop
119+ env :
120+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
121+
122+ - name : Create PR to main
123+ run : |
124+ VERSION="${{ github.ref_name }}"
125+
126+ gh pr create \
127+ --base main \
128+ --head "${{ github.ref_name }}" \
129+ --title "chore: update main with $VERSION" \
130+ --body "## 📦 Release Update
131+
132+ This PR updates main branch with:
133+ - ✅ Stable version numbers (beta suffix removed)
134+ - ✅ Updated package.json files
135+ - ✅ npm packages published
136+ - ✅ GitHub releases created
137+
138+ ### Published Packages
139+ $(node -p "
140+ const main = require('./package.json');
141+ let packages = \`- vue-pivottable@\${main.version}\`;
142+ const fs = require('fs');
143+ const path = require('path');
144+ const packagesDir = './packages';
145+ if (fs.existsSync(packagesDir)) {
146+ fs.readdirSync(packagesDir).forEach(dir => {
147+ const pkgPath = path.join(packagesDir, dir, 'package.json');
148+ if (fs.existsSync(pkgPath)) {
149+ const pkg = require(pkgPath);
150+ packages += \`\\n- \${pkg.name}@\${pkg.version}\`;
151+ }
152+ });
153+ }
154+ packages
155+ ")
156+
157+ **Note**: This release has been automatically synced with develop branch." \
158+ || echo "PR to main already exists or creation failed"
159+ env :
160+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
0 commit comments