Refactor/ProjectCatalogs #85
Workflow file for this run
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: Branch-Based Release Strategy | |
| on: | |
| # Manual workflow dispatch for all branches | |
| workflow_dispatch: | |
| inputs: | |
| force_release: | |
| description: 'Force create a release (even for non-main branches)' | |
| required: false | |
| default: false | |
| type: boolean | |
| # Automatic triggers | |
| push: | |
| branches: | |
| - main # Auto-release from main branch | |
| - 'feature/**' # Build and tag feature branches (no release) | |
| - 'fix/**' # Build and tag fix branches (no release) | |
| pull_request: | |
| branches: | |
| - main | |
| types: [opened, synchronize, reopened] | |
| permissions: | |
| contents: write | |
| pull-requests: read | |
| actions: read | |
| jobs: | |
| # π Generate release metadata and version information | |
| generate-release: | |
| name: Generate Release Metadata | |
| runs-on: ubuntu-latest | |
| outputs: | |
| new_version: ${{ steps.release.outputs.new_version }} | |
| release_type: ${{ steps.release.outputs.release_type }} | |
| previous_tag: ${{ steps.release.outputs.previous_tag }} | |
| should_release: ${{ steps.release.outputs.should_release }} | |
| should_publish: ${{ steps.release.outputs.should_publish }} | |
| branch_name: ${{ steps.release.outputs.branch_name }} | |
| commit_sha: ${{ github.sha }} | |
| steps: | |
| - name: Checkout Repository | |
| uses: actions/checkout@v4 | |
| with: | |
| ref: ${{ github.event_name == 'pull_request' && github.head_ref || github.ref }} | |
| fetch-depth: 0 # Full history for proper tag analysis | |
| - name: Generate Release Information | |
| id: release | |
| uses: ./.github/actions/ci/generate-release | |
| - name: Release Strategy Summary | |
| shell: bash | |
| run: | | |
| echo "π Branch-Based Release Strategy with Conditional Major Increment" | |
| echo "" | |
| echo "π Branch: ${{ steps.release.outputs.branch_name }}" | |
| echo "π·οΈ Version: ${{ steps.release.outputs.new_version }}" | |
| echo "π¦ Previous Version: ${{ steps.release.outputs.previous_tag }}" | |
| echo "π Release Type: ${{ steps.release.outputs.release_type }}" | |
| echo "π€ Trigger: ${{ github.event_name }}" | |
| echo "π Commit: ${{ github.sha }}" | |
| echo "" | |
| echo "Release Strategy Applied:" | |
| echo "π― Main Branch: Conditional major increment (only if minor=0 AND patch=0, otherwise increment patch with overflow logic)" | |
| echo "" | |
| echo "Main Branch Logic (NEW RULE):" | |
| echo "β’ If minor=0 AND patch=0: Increment major β major+1.0.0" | |
| echo "β’ If minorβ 0 OR patchβ 0: Keep major, increment patch β major.minor.(patch+1)" | |
| echo "β’ Overflow handling: If patch > 99 β minor+1, patch=0; if minor > 99 β major+1, minor=0" | |
| echo "" | |
| echo "Feature/Fix Branch Overflow Logic:" | |
| echo "β’ Feature branches: If patch + commits > 99 β patch = 0, minor += 1" | |
| echo "β’ Fix branches: If minor + commits > 99 β minor = 0, major += 1" | |
| echo "β’ Cascading overflow: If minor overflows during patch overflow β minor = 0, major += 1" | |
| # ποΈ Build artifacts and compile Bicep templates | |
| build: | |
| name: Build Artifacts | |
| runs-on: ubuntu-latest | |
| needs: generate-release | |
| if: needs.generate-release.outputs.should_release == 'true' | |
| steps: | |
| - name: Checkout Repository | |
| uses: actions/checkout@v4 | |
| with: | |
| ref: ${{ github.event_name == 'pull_request' && github.head_ref || github.ref }} | |
| fetch-depth: 0 | |
| - name: Build Bicep Templates and Create Artifacts | |
| id: build | |
| uses: ./.github/actions/ci/bicep-standard-ci | |
| with: | |
| branch_name: ${{ needs.generate-release.outputs.branch_name }} | |
| new_version: ${{ needs.generate-release.outputs.new_version }} | |
| should_publish: ${{ needs.generate-release.outputs.should_publish }} | |
| - name: Build Summary | |
| shell: bash | |
| run: | | |
| echo "π¦ Build Artifacts Created:" | |
| echo " - π Bicep templates compiled to ARM templates" | |
| echo " - ποΈ Infrastructure deployment files" | |
| echo " - π Release metadata and documentation" | |
| echo " - π·οΈ Version: ${{ needs.generate-release.outputs.new_version }}" | |
| echo " - π Branch: ${{ needs.generate-release.outputs.branch_name }}" | |
| # π’ Publish GitHub Release (only for main branch or forced releases) | |
| publish-release: | |
| name: Publish GitHub Release | |
| runs-on: ubuntu-latest | |
| needs: [generate-release, build] | |
| if: | | |
| needs.generate-release.outputs.should_release == 'true' && | |
| (needs.generate-release.outputs.should_publish == 'true' || | |
| github.event.inputs.force_release == 'true') | |
| steps: | |
| - name: Checkout Repository | |
| uses: actions/checkout@v4 | |
| with: | |
| ref: ${{ github.event_name == 'pull_request' && github.head_ref || github.ref }} | |
| fetch-depth: 0 | |
| - name: Download Build Artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: artifacts-${{ needs.generate-release.outputs.new_version }} | |
| path: ./artifacts | |
| - name: Generate Release Notes | |
| id: release_notes | |
| shell: bash | |
| run: | | |
| branch_name="${{ needs.generate-release.outputs.branch_name }}" | |
| release_type="${{ needs.generate-release.outputs.release_type }}" | |
| previous_tag="${{ needs.generate-release.outputs.previous_tag }}" | |
| new_version="${{ needs.generate-release.outputs.new_version }}" | |
| commit_sha="${{ needs.generate-release.outputs.commit_sha }}" | |
| # Determine if this is a prerelease | |
| is_prerelease="false" | |
| if [[ "$branch_name" != "main" ]] || [[ "$new_version" == *"-"* ]]; then | |
| is_prerelease="true" | |
| fi | |
| # Generate release body | |
| cat > release_notes.md << EOF | |
| ## π Branch-Based Release Strategy with Conditional Major Increment | |
| ### π Release Information | |
| - **π Branch:** \`$branch_name\` | |
| - **π·οΈ Version:** \`$new_version\` | |
| - **π¦ Previous Version:** \`$previous_tag\` | |
| - **π Release Type:** \`$release_type\` | |
| - **π€ Trigger:** ${{ github.event_name }} | |
| - **π Commit:** \`$commit_sha\` | |
| ### π― Release Strategy Applied | |
| **Main Branch:** Conditional major increment (only if minor=0 AND patch=0, otherwise increment patch with overflow logic) | |
| #### Main Branch Logic (NEW RULE) | |
| - **If minor=0 AND patch=0:** Increment major β major+1.0.0 | |
| - **If minorβ 0 OR patchβ 0:** Keep major, increment patch β major.minor.(patch+1) | |
| - **Overflow handling:** If patch > 99 β minor+1, patch=0; if minor > 99 β major+1, minor=0 | |
| #### Feature/Fix Branch Overflow Logic | |
| - **Feature branches:** If patch + commits > 99 β patch = 0, minor += 1 | |
| - **Fix branches:** If minor + commits > 99 β minor = 0, major += 1 | |
| - **Cascading overflow:** If minor overflows during patch overflow β minor = 0, major += 1 | |
| ### π¦ Artifacts | |
| - π Bicep templates compiled to ARM templates | |
| - ποΈ Infrastructure deployment files | |
| - π Release metadata and documentation | |
| ### π Links | |
| - [Commit History](https://github.com/${{ github.repository }}/commits/$branch_name) | |
| - [Compare Changes](https://github.com/${{ github.repository }}/compare/$previous_tag...$new_version) | |
| EOF | |
| echo "is_prerelease=$is_prerelease" >> $GITHUB_OUTPUT | |
| - name: Create GitHub Release | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| tag_name: ${{ needs.generate-release.outputs.new_version }} | |
| name: Release ${{ needs.generate-release.outputs.new_version }} | |
| body_path: release_notes.md | |
| draft: false | |
| prerelease: ${{ steps.release_notes.outputs.is_prerelease }} | |
| generate_release_notes: true | |
| files: | | |
| ./artifacts/**/* | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Release Published | |
| shell: bash | |
| run: | | |
| echo "π Release ${{ needs.generate-release.outputs.new_version }} has been published!" | |
| echo "π Release URL: https://github.com/${{ github.repository }}/releases/tag/${{ needs.generate-release.outputs.new_version }}" | |
| # π Summary job for workflow status | |
| summary: | |
| name: Workflow Summary | |
| runs-on: ubuntu-latest | |
| needs: [generate-release, build, publish-release] | |
| if: always() | |
| steps: | |
| - name: Workflow Summary | |
| shell: bash | |
| run: | | |
| echo "π Workflow Execution Summary" | |
| echo "================================" | |
| echo "" | |
| echo "π Branch: ${{ needs.generate-release.outputs.branch_name || 'N/A' }}" | |
| echo "π·οΈ Version: ${{ needs.generate-release.outputs.new_version || 'N/A' }}" | |
| echo "π Release Type: ${{ needs.generate-release.outputs.release_type || 'N/A' }}" | |
| echo "π€ Trigger: ${{ github.event_name }}" | |
| echo "" | |
| echo "π Job Status:" | |
| echo " - Generate Release: ${{ needs.generate-release.result }}" | |
| echo " - Build: ${{ needs.build.result }}" | |
| echo " - Publish Release: ${{ needs.publish-release.result }}" | |
| echo "" | |
| if [[ "${{ needs.publish-release.result }}" == "success" ]]; then | |
| echo "β Release published successfully!" | |
| elif [[ "${{ needs.generate-release.outputs.should_publish }}" == "false" ]]; then | |
| echo "βΉοΈ Development build completed. Tag created but no release published." | |
| else | |
| echo "β οΈ Workflow completed with issues. Check individual job logs." | |
| fi | |