From 1d5aa5024c97e511fb7d2f675ad4aee7e3135727 Mon Sep 17 00:00:00 2001 From: obarlik Date: Wed, 20 Aug 2025 22:52:17 +0300 Subject: [PATCH 1/3] feat: Add automated release workflow MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ๐Ÿš€ Automated release system on PR merge to master: - Semantic versioning based on PR title (feat:/patch/BREAKING CHANGE) - Auto version bump + commit + tag + GitHub release - Automated NPM publishing - Comprehensive release notes with PR details - Support for major/minor/patch version detection --- .github/workflows/auto-release.yml | 145 +++++++++++++++++++++++++++++ 1 file changed, 145 insertions(+) create mode 100644 .github/workflows/auto-release.yml diff --git a/.github/workflows/auto-release.yml b/.github/workflows/auto-release.yml new file mode 100644 index 0000000..9b9373e --- /dev/null +++ b/.github/workflows/auto-release.yml @@ -0,0 +1,145 @@ +name: ๐Ÿš€ Automated Release on PR Merge + +on: + pull_request: + types: [closed] + branches: [master, main] + +jobs: + auto-release: + if: github.event.pull_request.merged == true && github.event.pull_request.base.ref == 'master' + runs-on: ubuntu-latest + + permissions: + contents: write + pull-requests: read + + steps: + - name: ๐Ÿ›’ Checkout code + uses: actions/checkout@v4 + with: + fetch-depth: 0 + token: ${{ secrets.GITHUB_TOKEN }} + + - name: ๐Ÿ“ฆ Setup Node.js + uses: actions/setup-node@v4 + with: + node-version: '18' + registry-url: 'https://registry.npmjs.org' + + - name: ๐Ÿ“ฅ Install dependencies + run: npm ci + + - name: ๐Ÿงช Run tests + run: npm test + + - name: ๐Ÿ—๏ธ Build package + run: npm run build + + - name: ๐Ÿ” Analyze PR for version bump + id: version + run: | + PR_TITLE="${{ github.event.pull_request.title }}" + PR_BODY="${{ github.event.pull_request.body }}" + + echo "๐Ÿ” Analyzing PR: $PR_TITLE" + + # Check for breaking changes + if echo "$PR_TITLE $PR_BODY" | grep -iE "(BREAKING CHANGE|breaking:|major:|MAJOR)"; then + echo "bump=major" >> $GITHUB_OUTPUT + echo "๐Ÿ“ˆ Detected MAJOR version bump" + elif echo "$PR_TITLE" | grep -iE "(feat:|feature:|minor:|MINOR)"; then + echo "bump=minor" >> $GITHUB_OUTPUT + echo "๐Ÿ“ˆ Detected MINOR version bump" + else + echo "bump=patch" >> $GITHUB_OUTPUT + echo "๐Ÿ“ˆ Detected PATCH version bump" + fi + + - name: ๐Ÿ“ˆ Bump version + id: bump + run: | + CURRENT_VERSION=$(node -p "require('./package.json').version") + NEW_VERSION=$(npm version ${{ steps.version.outputs.bump }} --no-git-tag-version) + echo "version=$NEW_VERSION" >> $GITHUB_OUTPUT + echo "current_version=v$CURRENT_VERSION" >> $GITHUB_OUTPUT + echo "๐Ÿ“ฆ Version bump: v$CURRENT_VERSION โ†’ $NEW_VERSION" + + - name: ๐Ÿ“ Generate release notes + id: release_notes + run: | + PR_NUMBER="${{ github.event.pull_request.number }}" + PR_TITLE="${{ github.event.pull_request.title }}" + PR_AUTHOR="${{ github.event.pull_request.user.login }}" + PR_BODY="${{ github.event.pull_request.body }}" + NEW_VERSION="${{ steps.bump.outputs.version }}" + + RELEASE_NOTES="## ๐ŸŽ‰ Release $NEW_VERSION + + **Merged PR:** $PR_TITLE (#$PR_NUMBER) + **Author:** @$PR_AUTHOR + **Version Bump:** ${{ steps.version.outputs.bump }} + + ### ๐Ÿ“‹ Changes: + $PR_BODY + + --- + + ### ๐Ÿ“ฆ Installation: + \`\`\`bash + npm install @codechu/flow-core-container@$NEW_VERSION + \`\`\` + + ### ๐Ÿ”— Links: + - **NPM Package:** https://www.npmjs.com/package/@codechu/flow-core-container + - **Full Changelog:** https://github.com/${{ github.repository }}/compare/${{ steps.bump.outputs.current_version }}...$NEW_VERSION" + + # Save to file to avoid shell escaping issues + cat > release_notes.md << 'EOF' + $RELEASE_NOTES + EOF + + echo "Generated release notes for $NEW_VERSION" + + - name: ๐Ÿ’พ Commit version bump + run: | + git config --local user.name "github-actions[bot]" + git config --local user.email "github-actions[bot]@users.noreply.github.com" + + git add package.json package-lock.json + git commit -m "๐Ÿ”– Release ${{ steps.bump.outputs.version }} + + Automated version bump from PR merge (#${{ github.event.pull_request.number }}) + Author: @${{ github.event.pull_request.user.login }} + Type: ${{ steps.version.outputs.bump }}" + + git push origin master + + - name: ๐Ÿท๏ธ Create tag and GitHub release + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + NEW_VERSION="${{ steps.bump.outputs.version }}" + + # Create and push tag + git tag $NEW_VERSION + git push origin $NEW_VERSION + + # Create GitHub release + gh release create $NEW_VERSION \ + --title "๐Ÿท๏ธ $NEW_VERSION - Auto Release" \ + --notes-file release_notes.md \ + --latest + + - name: ๐Ÿ“ฆ Publish to NPM + run: npm publish + env: + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} + + - name: ๐ŸŽ‰ Success notification + run: | + NEW_VERSION="${{ steps.bump.outputs.version }}" + echo "โœ… Successfully released $NEW_VERSION" + echo "๐Ÿ“ฆ NPM: https://www.npmjs.com/package/@codechu/flow-core-container" + echo "๐Ÿ”— Release: https://github.com/${{ github.repository }}/releases/tag/$NEW_VERSION" + echo "๐Ÿ“‹ PR: https://github.com/${{ github.repository }}/pull/${{ github.event.pull_request.number }}" \ No newline at end of file From 412dc2682278dfeb16d7844da12c91c1ee1f746a Mon Sep 17 00:00:00 2001 From: obarlik Date: Wed, 20 Aug 2025 23:02:11 +0300 Subject: [PATCH 2/3] feat: Add FIRST RELEASE logic - 0.0.0 always becomes 1.0.0 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ๐ŸŽฏ Enhanced automated release workflow: - First release (0.0.0) always bumps to 1.0.0 - Subsequent releases follow semantic versioning - Perfect for clean release numbering from start --- .github/workflows/auto-release.yml | 11 ++++++++++- package.json | 2 +- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/.github/workflows/auto-release.yml b/.github/workflows/auto-release.yml index 9b9373e..ce0cee9 100644 --- a/.github/workflows/auto-release.yml +++ b/.github/workflows/auto-release.yml @@ -60,7 +60,16 @@ jobs: id: bump run: | CURRENT_VERSION=$(node -p "require('./package.json').version") - NEW_VERSION=$(npm version ${{ steps.version.outputs.bump }} --no-git-tag-version) + + # ๐ŸŽ‰ FIRST RELEASE LOGIC: If 0.0.0, always go to 1.0.0 + if [ "$CURRENT_VERSION" = "0.0.0" ]; then + NEW_VERSION=$(npm version 1.0.0 --no-git-tag-version) + echo "๐ŸŽ‰ FIRST RELEASE: Bumping directly to v1.0.0" + else + NEW_VERSION=$(npm version ${{ steps.version.outputs.bump }} --no-git-tag-version) + echo "๐Ÿ“ˆ Regular version bump: ${{ steps.version.outputs.bump }}" + fi + echo "version=$NEW_VERSION" >> $GITHUB_OUTPUT echo "current_version=v$CURRENT_VERSION" >> $GITHUB_OUTPUT echo "๐Ÿ“ฆ Version bump: v$CURRENT_VERSION โ†’ $NEW_VERSION" diff --git a/package.json b/package.json index 97b8e5c..45b5430 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@codechu/flow-core-container", - "version": "1.0.0", + "version": "0.0.0", "type": "module", "description": "Flow ecosystem container abstractions - Pure interfaces for dependency injection and service location with zero logic", "keywords": [ From f2334fc8de27323b291a7819dd2f815eb3b57195 Mon Sep 17 00:00:00 2001 From: obarlik Date: Wed, 20 Aug 2025 23:11:24 +0300 Subject: [PATCH 3/3] enhance: Implement safe version detection system MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ๐Ÿ›ก๏ธ Safe + Smart Automated Versioning: โœ… Manual Override: [patch|minor|major] syntax โœ… Exact Prefix Matching: Prevents false positives โœ… Safe Default: Unknown patterns โ†’ PATCH โœ… Smart Detection: ๐Ÿ”ด MAJOR: BREAKING CHANGE:|breaking:|MAJOR:|NEW VERSION: ๐ŸŸก MINOR: feat:|feature:|add:|enhance: ๐ŸŸข PATCH: Everything else (safe) Examples: - 'feat: New interface' โ†’ v1.1.0 - 'NEW VERSION: Architecture' โ†’ v2.0.0 - 'fix: Bug [major]' โ†’ v2.0.0 (manual) - 'Random text' โ†’ v1.0.1 (safe default) --- .github/workflows/auto-release.yml | 31 ++++++++++++++++++++++-------- 1 file changed, 23 insertions(+), 8 deletions(-) diff --git a/.github/workflows/auto-release.yml b/.github/workflows/auto-release.yml index ce0cee9..eb37f64 100644 --- a/.github/workflows/auto-release.yml +++ b/.github/workflows/auto-release.yml @@ -36,24 +36,39 @@ jobs: - name: ๐Ÿ—๏ธ Build package run: npm run build - - name: ๐Ÿ” Analyze PR for version bump + - name: ๐Ÿ” Safe version detection with manual override id: version run: | PR_TITLE="${{ github.event.pull_request.title }}" - PR_BODY="${{ github.event.pull_request.body }}" echo "๐Ÿ” Analyzing PR: $PR_TITLE" - # Check for breaking changes - if echo "$PR_TITLE $PR_BODY" | grep -iE "(BREAKING CHANGE|breaking:|major:|MAJOR)"; then + # ๐ŸŽฏ 1. MANUAL OVERRIDE (highest priority) + if echo "$PR_TITLE" | grep -E "\[(patch|minor|major)\]"; then + MANUAL_VERSION=$(echo "$PR_TITLE" | grep -oE "(patch|minor|major)") + echo "bump=$MANUAL_VERSION" >> $GITHUB_OUTPUT + echo "๐ŸŽฏ MANUAL OVERRIDE: $MANUAL_VERSION" + + # ๐Ÿ”ด 2. MAJOR - Exact prefix match only + elif [[ "$PR_TITLE" == "BREAKING CHANGE:"* ]] || \ + [[ "$PR_TITLE" == "breaking:"* ]] || \ + [[ "$PR_TITLE" == "MAJOR:"* ]] || \ + [[ "$PR_TITLE" == "NEW VERSION:"* ]]; then echo "bump=major" >> $GITHUB_OUTPUT - echo "๐Ÿ“ˆ Detected MAJOR version bump" - elif echo "$PR_TITLE" | grep -iE "(feat:|feature:|minor:|MINOR)"; then + echo "๐Ÿ”ด MAJOR: Breaking change or new version" + + # ๐ŸŸก 3. MINOR - Exact prefix match only + elif [[ "$PR_TITLE" == "feat:"* ]] || \ + [[ "$PR_TITLE" == "feature:"* ]] || \ + [[ "$PR_TITLE" == "add:"* ]] || \ + [[ "$PR_TITLE" == "enhance:"* ]]; then echo "bump=minor" >> $GITHUB_OUTPUT - echo "๐Ÿ“ˆ Detected MINOR version bump" + echo "๐ŸŸก MINOR: New feature" + + # ๐ŸŸข 4. PATCH - Safe default else echo "bump=patch" >> $GITHUB_OUTPUT - echo "๐Ÿ“ˆ Detected PATCH version bump" + echo "๐ŸŸข PATCH: Bug fix or maintenance (safe default)" fi - name: ๐Ÿ“ˆ Bump version