@@ -135,12 +135,126 @@ jobs:
135135 echo "release_branch=$RELEASE_BRANCH" >> $GITHUB_OUTPUT
136136 echo "version=$VERSION" >> $GITHUB_OUTPUT
137137
138- - name : Trigger release branch workflow
138+ - name : Checkout release branch
139139 if : steps.check-versions.outputs.has_beta == 'true'
140140 run : |
141- echo "Release branch created: ${{ steps.create-release.outputs.release_branch }}"
142- echo "The release branch workflow will handle:"
143- echo "- Publishing to npm"
144- echo "- Creating GitHub releases"
145- echo "- Syncing with develop (auto-merge)"
146- echo "- Creating PR to main"
141+ git checkout ${{ steps.create-release.outputs.release_branch }}
142+ git pull origin ${{ steps.create-release.outputs.release_branch }}
143+
144+ - name : Publish to npm
145+ if : steps.check-versions.outputs.has_beta == 'true'
146+ run : |
147+ # Publish with latest tag
148+ node scripts/release-packages.cjs
149+ env :
150+ NODE_AUTH_TOKEN : ${{ secrets.NPM_TOKEN }}
151+ NPM_TOKEN : ${{ secrets.NPM_TOKEN }}
152+ NPM_TOKEN_SUMIN : ${{ secrets.NPM_TOKEN_SUMIN }}
153+
154+ - name : Create GitHub Releases
155+ if : steps.check-versions.outputs.has_beta == 'true'
156+ run : |
157+ # Create release for each package with stable version
158+ create_release() {
159+ local PKG_NAME=$1
160+ local PKG_VERSION=$2
161+ local NPM_NAME=$3
162+
163+ echo "Creating release for $PKG_NAME@$PKG_VERSION"
164+
165+ # Delete existing beta release if it exists
166+ gh release delete "${PKG_NAME}@${PKG_VERSION}" --yes 2>/dev/null || true
167+
168+ gh release create "${PKG_NAME}@${PKG_VERSION}" \
169+ --title "${PKG_NAME}@${PKG_VERSION}" \
170+ --notes "## 🚀 Stable Release
171+
172+ This release promotes the beta version to stable.
173+
174+ Install with: \`npm install ${NPM_NAME}@latest\`
175+
176+ ### Version: ${PKG_VERSION}" \
177+ --target ${{ github.sha }}
178+ }
179+
180+ # Get version info from current branch
181+ VERSION="${{ steps.create-release.outputs.version }}"
182+
183+ # Check main package
184+ MAIN_VERSION=$(node -p "require('./package.json').version")
185+ if [ "$MAIN_VERSION" = "$VERSION" ]; then
186+ create_release "vue-pivottable" "$MAIN_VERSION" "vue-pivottable"
187+ fi
188+
189+ # Check sub-packages
190+ for pkg in packages/*/; do
191+ if [ -d "$pkg" ] && [ -f "$pkg/package.json" ]; then
192+ FULL_PKG_NAME=$(cd "$pkg" && node -p "require('./package.json').name")
193+ PKG_VERSION=$(cd "$pkg" && node -p "require('./package.json').version")
194+
195+ # Only create release if version doesn't contain beta
196+ if [[ $PKG_VERSION != *"-beta"* ]]; then
197+ create_release "$FULL_PKG_NAME" "$PKG_VERSION" "$FULL_PKG_NAME"
198+ fi
199+ fi
200+ done
201+ env :
202+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
203+
204+ - name : Sync with develop
205+ if : steps.check-versions.outputs.has_beta == 'true'
206+ run : |
207+ # Configure git
208+ git config user.name "github-actions[bot]"
209+ git config user.email "github-actions[bot]@users.noreply.github.com"
210+
211+ # Fetch latest develop
212+ git fetch origin develop:develop
213+
214+ # Merge release branch into develop
215+ git checkout develop
216+ git merge ${{ steps.create-release.outputs.release_branch }} --no-edit -m "chore: sync release ${{ steps.create-release.outputs.release_branch }} to develop"
217+ git push origin develop
218+ env :
219+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
220+
221+ - name : Create PR to main
222+ if : steps.check-versions.outputs.has_beta == 'true'
223+ run : |
224+ VERSION="${{ steps.create-release.outputs.release_branch }}"
225+
226+ gh pr create \
227+ --base main \
228+ --head "${{ steps.create-release.outputs.release_branch }}" \
229+ --title "chore: update main with $VERSION" \
230+ --body "## 📦 Release Update
231+
232+ This PR updates main branch with:
233+ - ✅ Stable version numbers (beta suffix removed)
234+ - ✅ Updated package.json files
235+ - ✅ npm packages published
236+ - ✅ GitHub releases created
237+
238+ ### Published Packages
239+ $(node -p "
240+ const main = require('./package.json');
241+ let packages = \`- vue-pivottable@\${main.version}\`;
242+ const fs = require('fs');
243+ const path = require('path');
244+ const packagesDir = './packages';
245+ if (fs.existsSync(packagesDir)) {
246+ fs.readdirSync(packagesDir).forEach(dir => {
247+ const pkgPath = path.join(packagesDir, dir, 'package.json');
248+ if (fs.existsSync(pkgPath)) {
249+ const pkg = require(pkgPath);
250+ packages += \`\\n- \${pkg.name}@\${pkg.version}\`;
251+ }
252+ });
253+ }
254+ packages
255+ ")
256+
257+ **Note**: This release has been automatically synced with develop branch." \
258+ || echo "PR to main already exists or creation failed"
259+ env :
260+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
0 commit comments