88 required : true
99 type : string
1010 default : master
11+ tag_format :
12+ required : false
13+ type : string
14+ default : " vX.Y.Z"
15+ description : " Repository tag format (e.g., vX.Y.Z or X.Y.Z)"
16+ create_changelog :
17+ required : false
18+ type : boolean
19+ default : true
20+ description : " Whether to create changelog and release (default: true)"
1121 secrets :
1222 GITHUB :
1323 required : true
1424 description : ' PAT of the user to run the jobs.'
1525
1626jobs :
17- release :
27+ # Job 1: Create Tag
28+ create-tag :
1829 runs-on : ubuntu-latest
1930 if : ${{ github.event.pull_request.merged == true && github.event.pull_request.base.ref == inputs.target_branch }}
31+ outputs :
32+ skip : ${{ steps.skip_tag.outputs.skip }}
33+ reason : ${{ steps.skip_tag.outputs.reason }}
34+ final_tag : ${{ steps.calc_version.outputs.final_tag }}
35+ version_type : ${{ steps.calc_version.outputs.version_type }}
36+ latest_tag : ${{ steps.get_latest_tag.outputs.latest_tag }}
2037
2138 steps :
2239 - name : 📦 Checkout Repository
6683 if : steps.skip_tag.outputs.skip == 'false'
6784 run : |
6885 BASE_VERSION="${{ steps.get_latest_tag.outputs.latest_tag }}"
69- IFS='.' read -r MAJOR MINOR PATCH <<< "$BASE_VERSION"
86+ # Remove v prefix if present for version calculation
87+ CLEAN_BASE_VERSION="${BASE_VERSION#v}"
88+ IFS='.' read -r MAJOR MINOR PATCH <<< "$CLEAN_BASE_VERSION"
7089 LABELS="${{ steps.pr_labels.outputs.labels }}"
7190
7291 if [[ "$LABELS" == *"major"* ]]; then
@@ -81,66 +100,44 @@ jobs:
81100 fi
82101
83102 NEW_VERSION="$MAJOR.$MINOR.$PATCH"
84- echo "new_version=$NEW_VERSION" >> $GITHUB_OUTPUT
103+
104+ # Apply tag format (add v prefix if needed)
105+ TAG_FORMAT="${{ inputs.tag_format }}"
106+ if [[ "$TAG_FORMAT" == v* ]]; then
107+ FINAL_TAG="v$NEW_VERSION"
108+ else
109+ FINAL_TAG="$NEW_VERSION"
110+ fi
111+
112+ echo "final_tag=$FINAL_TAG" >> $GITHUB_OUTPUT
85113
86114 - name : 🏷️ Create GitHub tag for the new version
87115 if : steps.skip_tag.outputs.skip == 'false'
88116 run : |
89117 git config user.name "clouddrove-ci"
90118 git config user.email "84795582+clouddrove-ci@users.noreply.github.com"
91- git tag ${{ steps.calc_version.outputs.new_version }}
92- git push origin ${{ steps.calc_version.outputs.new_version }}
93-
94- - name : 📝 Generate Changelog
95- if : steps.skip_tag.outputs.skip == 'false'
96- id : changelog
97- uses : requarks/changelog-action@v1
98- with :
99- token : ${{ secrets.GITHUB }}
100- tag : ${{ steps.calc_version.outputs.new_version }}
101- includeInvalidCommits : false
102- writeToFile : true
103- changelogFilePath : CHANGELOG.md
104- includeRefIssues : true
105- useGitmojis : true
106- reverseOrder : false
119+ git tag ${{ steps.calc_version.outputs.final_tag }}
120+ git push origin ${{ steps.calc_version.outputs.final_tag }}
107121
108- - name : 🚀 Create Release
109- if : steps.skip_tag.outputs.skip == 'false'
110- uses : ncipollo/release-action@v1
111- with :
112- token : ${{ secrets.GITHUB }}
113- tag : ${{ steps.calc_version.outputs.new_version }}
114- name : ${{ steps.calc_version.outputs.new_version }}
115- allowUpdates : true
116- draft : false
117- makeLatest : true
118- body : |
119- ${{ steps.changelog.outputs.changes }}
120-
121- **Release Type:** ${{ steps.calc_version.outputs.version_type }}
122-
123- ${{ steps.calc_version.outputs.version_type == 'major' && '⚠️ **BREAKING CHANGES:** This is a major release with breaking changes. Please review the breaking changes section in [CHANGELOG.md](https://github.com/${{ github.repository }}/blob/${{ steps.calc_version.outputs.new_version }}/CHANGELOG.md) before upgrading.' || '' }}
124-
125- [Compare changes](https://github.com/${{ github.repository }}/compare/${{ steps.get_latest_tag.outputs.latest_tag }}...${{ steps.calc_version.outputs.new_version }})
126-
127- - name : 💾 Commit CHANGELOG.md
128- if : steps.skip_tag.outputs.skip == 'false'
129- uses : stefanzweifel/git-auto-commit-action@v7
130- with :
131- branch : ${{ inputs.target_branch }}
132- commit_user_name : clouddrove-ci
133- commit_user_email : 84795582+clouddrove-ci@users.noreply.github.com
134- commit_author : " CloudDrove CI <84795582+clouddrove-ci@users.noreply.github.com>"
135- commit_message : ' docs: update CHANGELOG.md for ${{ steps.calc_version.outputs.new_version }}'
136- file_pattern : CHANGELOG.md
137-
138- - name : 📋 Action Summary
122+ - name : 📋 Tag Creation Summary
139123 run : |
140124 if [[ "${{ steps.skip_tag.outputs.skip }}" == "true" ]]; then
141- echo "🚫 Release skipped: ${{ steps.skip_tag.outputs.reason }}"
125+ echo "🚫 Tag creation skipped: ${{ steps.skip_tag.outputs.reason }}"
142126 else
143- echo "✅ Released ${{ steps.calc_version.outputs.new_version }} successfully."
127+ echo "✅ Tag ${{ steps.calc_version.outputs.final_tag }} created successfully."
144128 echo "🏷️ Version type: ${{ steps.calc_version.outputs.version_type }}"
145129 fi
146- ...
130+
131+ # Job 2: Call CHANGELOG workflow for release creation
132+ changelog-workflow :
133+ needs : create-tag
134+ if : ${{ needs.create-tag.outputs.skip == 'false' && inputs.create_changelog == true }}
135+ uses : ./.github/workflows/release-changelog.yml
136+ with :
137+ branch : ${{ inputs.target_branch }}
138+ tag_format : ${{ inputs.tag_format }}
139+ release_tag : ${{ needs.create-tag.outputs.final_tag }}
140+ version_type : ${{ needs.create-tag.outputs.version_type }}
141+ latest_tag : ${{ needs.create-tag.outputs.latest_tag }}
142+ secrets :
143+ GITHUB : ${{ secrets.GITHUB }}
0 commit comments