Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
65 changes: 43 additions & 22 deletions .github/workflows/release-changelog.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,23 @@ on:
branch:
required: true
type: string
description: "Branch to update CHANGELOG from"
tag_format:
required: true
type: string
description: "Repository tag format (e.g., vX.Y.Z or X.Y.Z) - defines how tags should look"
description: "Repository tag format (e.g., vX.Y.Z or X.Y.Z)"
release_tag:
required: true
type: string
description: "Actual release tag to validate"

outputs:
valid:
description: "Is release tag valid for this repository"
value: ${{ jobs.tag-validation.outputs.valid }}
description: "Actual release tag to validate and use"
version_type:
required: true
type: string
description: "Type of release (major/minor/patch)"
latest_tag:
required: true
type: string
description: "Previous tag for comparison"

secrets:
GITHUB:
Expand Down Expand Up @@ -54,7 +58,7 @@ jobs:
else
echo "valid=false" >> $GITHUB_OUTPUT
echo "❌ Repository uses v-prefixed tags (vX.Y.Z) but release tag is: $RELEASE_TAG"
echo "⏭️ Skipping changelog generation"
exit 1
fi
else
# Repository uses plain format (X.Y.Z)
Expand All @@ -65,7 +69,7 @@ jobs:
else
echo "valid=false" >> $GITHUB_OUTPUT
echo "❌ Repository uses plain tags (X.Y.Z) but release tag is: $RELEASE_TAG"
echo "⏭️ Skipping changelog generation"
exit 1
fi
fi

Expand All @@ -79,34 +83,51 @@ jobs:
uses: actions/checkout@v6
with:
token: ${{ secrets.GITHUB }}
ref: ${{ inputs.release_tag }}

- name: πŸ“ Update CHANGELOG
- name: πŸ“ Generate Changelog
id: changelog
uses: requarks/changelog-action@v1
with:
token: ${{ secrets.GITHUB }}
excludeTypes: ""
tag: ${{ inputs.release_tag }}
includeInvalidCommits: false
tag: ${{ inputs.tag != '' && inputs.tag || github.ref_name }}
writeToFile: true
changelogFilePath: CHANGELOG.md
includeRefIssues: true
useGitmojis: true
reverseOrder: false

- name: πŸš€ Create Release
uses: ncipollo/release-action@v1.16.0
with:
token: ${{ secrets.GITHUB }}
tag: ${{ inputs.release_tag }}
name: ${{ inputs.release_tag }}
allowUpdates: true
draft: false
makeLatest: true
name: ${{ inputs.tag != '' && inputs.tag || github.ref_name }}
tag: ${{ inputs.tag != '' && inputs.tag || github.ref_name }}
body: ${{ steps.changelog.outputs.changes }}
token: ${{ secrets.GITHUB }}
body: |
${{ steps.changelog.outputs.changes }}

**Release Type:** ${{ inputs.version_type }}

${{ inputs.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/${{ inputs.release_tag }}/CHANGELOG.md) before upgrading.' || '' }}

- name: βœ… Commit CHANGELOG.md
[Compare changes](https://github.com/${{ github.repository }}/compare/${{ inputs.latest_tag }}...${{ inputs.release_tag }})

- name: πŸ’Ύ Commit CHANGELOG.md
uses: stefanzweifel/git-auto-commit-action@v7
with:
branch: ${{ inputs.branch }}
commit_user_name: clouddrove-ci # defaults to "github-actions[bot]"
commit_user_email: 84795582+clouddrove-ci@users.noreply.github.com # defaults to "41898282+github-actions[bot]@users.noreply.github.com"
commit_author: CloudDrove CI <84795582+clouddrove-ci@users.noreply.github.com>
commit_message: 'docs: update CHANGELOG.md for ${{ github.ref_name }}'
commit_user_name: clouddrove-ci
commit_user_email: 84795582+clouddrove-ci@users.noreply.github.com
commit_author: "CloudDrove CI <84795582+clouddrove-ci@users.noreply.github.com>"
commit_message: 'docs: update CHANGELOG.md for ${{ inputs.release_tag }}'
file_pattern: CHANGELOG.md
...

- name: πŸ“‹ Release Summary
run: |
echo "βœ… Release ${{ inputs.release_tag }} created successfully."
echo "🏷️ Version type: ${{ inputs.version_type }}"
echo "πŸ“ Changelog has been updated and committed."
103 changes: 50 additions & 53 deletions .github/workflows/release-tag.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,32 @@ on:
required: true
type: string
default: master
tag_format:
required: false
type: string
default: "vX.Y.Z"
description: "Repository tag format (e.g., vX.Y.Z or X.Y.Z)"
create_changelog:
required: false
type: boolean
default: true
description: "Whether to create changelog and release (default: true)"
secrets:
GITHUB:
required: true
description: 'PAT of the user to run the jobs.'

jobs:
release:
# Job 1: Create Tag
create-tag:
runs-on: ubuntu-latest
if: ${{ github.event.pull_request.merged == true && github.event.pull_request.base.ref == inputs.target_branch }}
outputs:
skip: ${{ steps.skip_tag.outputs.skip }}
reason: ${{ steps.skip_tag.outputs.reason }}
final_tag: ${{ steps.calc_version.outputs.final_tag }}
version_type: ${{ steps.calc_version.outputs.version_type }}
latest_tag: ${{ steps.get_latest_tag.outputs.latest_tag }}

steps:
- name: πŸ“¦ Checkout Repository
Expand Down Expand Up @@ -66,7 +83,9 @@ jobs:
if: steps.skip_tag.outputs.skip == 'false'
run: |
BASE_VERSION="${{ steps.get_latest_tag.outputs.latest_tag }}"
IFS='.' read -r MAJOR MINOR PATCH <<< "$BASE_VERSION"
# Remove v prefix if present for version calculation
CLEAN_BASE_VERSION="${BASE_VERSION#v}"
IFS='.' read -r MAJOR MINOR PATCH <<< "$CLEAN_BASE_VERSION"
LABELS="${{ steps.pr_labels.outputs.labels }}"

if [[ "$LABELS" == *"major"* ]]; then
Expand All @@ -81,66 +100,44 @@ jobs:
fi

NEW_VERSION="$MAJOR.$MINOR.$PATCH"
echo "new_version=$NEW_VERSION" >> $GITHUB_OUTPUT

# Apply tag format (add v prefix if needed)
TAG_FORMAT="${{ inputs.tag_format }}"
if [[ "$TAG_FORMAT" == v* ]]; then
FINAL_TAG="v$NEW_VERSION"
else
FINAL_TAG="$NEW_VERSION"
fi

echo "final_tag=$FINAL_TAG" >> $GITHUB_OUTPUT

- name: 🏷️ Create GitHub tag for the new version
if: steps.skip_tag.outputs.skip == 'false'
run: |
git config user.name "clouddrove-ci"
git config user.email "84795582+clouddrove-ci@users.noreply.github.com"
git tag ${{ steps.calc_version.outputs.new_version }}
git push origin ${{ steps.calc_version.outputs.new_version }}

- name: πŸ“ Generate Changelog
if: steps.skip_tag.outputs.skip == 'false'
id: changelog
uses: requarks/changelog-action@v1
with:
token: ${{ secrets.GITHUB }}
tag: ${{ steps.calc_version.outputs.new_version }}
includeInvalidCommits: false
writeToFile: true
changelogFilePath: CHANGELOG.md
includeRefIssues: true
useGitmojis: true
reverseOrder: false
git tag ${{ steps.calc_version.outputs.final_tag }}
git push origin ${{ steps.calc_version.outputs.final_tag }}

- name: πŸš€ Create Release
if: steps.skip_tag.outputs.skip == 'false'
uses: ncipollo/release-action@v1
with:
token: ${{ secrets.GITHUB }}
tag: ${{ steps.calc_version.outputs.new_version }}
name: ${{ steps.calc_version.outputs.new_version }}
allowUpdates: true
draft: false
makeLatest: true
body: |
${{ steps.changelog.outputs.changes }}

**Release Type:** ${{ steps.calc_version.outputs.version_type }}

${{ 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.' || '' }}

[Compare changes](https://github.com/${{ github.repository }}/compare/${{ steps.get_latest_tag.outputs.latest_tag }}...${{ steps.calc_version.outputs.new_version }})

- name: πŸ’Ύ Commit CHANGELOG.md
if: steps.skip_tag.outputs.skip == 'false'
uses: stefanzweifel/git-auto-commit-action@v7
with:
branch: ${{ inputs.target_branch }}
commit_user_name: clouddrove-ci
commit_user_email: 84795582+clouddrove-ci@users.noreply.github.com
commit_author: "CloudDrove CI <84795582+clouddrove-ci@users.noreply.github.com>"
commit_message: 'docs: update CHANGELOG.md for ${{ steps.calc_version.outputs.new_version }}'
file_pattern: CHANGELOG.md

- name: πŸ“‹ Action Summary
- name: πŸ“‹ Tag Creation Summary
run: |
if [[ "${{ steps.skip_tag.outputs.skip }}" == "true" ]]; then
echo "🚫 Release skipped: ${{ steps.skip_tag.outputs.reason }}"
echo "🚫 Tag creation skipped: ${{ steps.skip_tag.outputs.reason }}"
else
echo "βœ… Released ${{ steps.calc_version.outputs.new_version }} successfully."
echo "βœ… Tag ${{ steps.calc_version.outputs.final_tag }} created successfully."
echo "🏷️ Version type: ${{ steps.calc_version.outputs.version_type }}"
fi
...

# Job 2: Call CHANGELOG workflow for release creation
changelog-workflow:
needs: create-tag
if: ${{ needs.create-tag.outputs.skip == 'false' && inputs.create_changelog == true }}
uses: ./.github/workflows/release-changelog.yml
with:
branch: ${{ inputs.target_branch }}
tag_format: ${{ inputs.tag_format }}
release_tag: ${{ needs.create-tag.outputs.final_tag }}
version_type: ${{ needs.create-tag.outputs.version_type }}
latest_tag: ${{ needs.create-tag.outputs.latest_tag }}
secrets:
GITHUB: ${{ secrets.GITHUB }}
Loading