Skip to content

Commit dd43b99

Browse files
ryanaidilpclaude
andcommitted
feat(workflows): enhance changelog and notification workflows
- Update check-pubdev-and-notify to trigger after publish success instead of every 30min - Add 2-minute wait for pub.dev processing before checking - Update generate-changelog to trigger on release branch pushes - Add duplicate version detection to prevent redundant changelog entries - Add file copying from root to packages/stadata_flutter_sdk (CHANGELOG.md, README.md) - Configure PR creation to target release branches properly - Improve workflow summaries and error handling 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
1 parent 29f87d5 commit dd43b99

File tree

2 files changed

+89
-28
lines changed

2 files changed

+89
-28
lines changed

.github/workflows/check-pubdev-and-notify.yml

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
name: Check pub.dev and Notify Discord
22

33
on:
4-
schedule:
5-
# Check every 30 minutes
6-
- cron: "*/30 * * * *"
4+
workflow_run:
5+
workflows: ["Publish to pub.dev"]
6+
types:
7+
- completed
78
workflow_dispatch:
89
inputs:
910
force_check:
@@ -15,10 +16,18 @@ on:
1516
jobs:
1617
check-and-notify:
1718
runs-on: ubuntu-latest
19+
# Only run if the publish workflow succeeded or if manually triggered
20+
if: ${{ github.event.workflow_run.conclusion == 'success' || github.event_name == 'workflow_dispatch' }}
1821
steps:
1922
- name: Checkout code
2023
uses: actions/checkout@v4
2124

25+
- name: Wait for pub.dev processing
26+
if: github.event_name == 'workflow_run'
27+
run: |
28+
echo "Waiting 2 minutes for pub.dev to process the publication..."
29+
sleep 120
30+
2231
- name: Setup Python
2332
uses: actions/setup-python@v5
2433
with:

.github/workflows/generate-changelog.yml

Lines changed: 77 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ name: Generate Changelog
22

33
on:
44
push:
5-
tags:
6-
- "[0-9]+.[0-9]+.[0-9]+" # for tags like: '1.2.3'
5+
branches:
6+
- "release/**"
77
workflow_dispatch:
88
inputs:
99
version:
@@ -51,39 +51,60 @@ jobs:
5151
- name: Determine version and from_tag
5252
id: version_info
5353
run: |
54-
if [ "${{ github.event_name }}" = "push" ]; then
55-
# Extract version from tag
56-
VERSION="${{ github.ref_name }}"
54+
if [[ "${{ github.ref_name }}" == release/* ]]; then
55+
# Extract version from release branch name (e.g., release/1.2.3 -> 1.2.3)
56+
BRANCH_NAME="${{ github.ref_name }}"
57+
VERSION=$(echo "$BRANCH_NAME" | sed 's/release\///')
5758
echo "version=$VERSION" >> $GITHUB_OUTPUT
5859
5960
# Get previous tag for from_tag
60-
PREVIOUS_TAG=$(git tag --sort=-version:refname | grep -v "^$VERSION$" | head -1)
61+
PREVIOUS_TAG=$(git tag --sort=-version:refname | head -1)
6162
echo "from_tag=$PREVIOUS_TAG" >> $GITHUB_OUTPUT
6263
else
6364
# Use manual inputs
6465
echo "version=${{ inputs.version }}" >> $GITHUB_OUTPUT
6566
echo "from_tag=${{ inputs.from_tag }}" >> $GITHUB_OUTPUT
6667
fi
6768
69+
- name: Check if version already exists in changelog
70+
id: check_version
71+
run: |
72+
VERSION="${{ steps.version_info.outputs.version }}"
73+
74+
echo "Checking if version $VERSION already exists in CHANGELOG.md..."
75+
76+
# Check for various version formats in changelog
77+
if grep -q "^## $VERSION" CHANGELOG.md || \
78+
grep -q "^## \[$VERSION\]" CHANGELOG.md || \
79+
grep -q "^## v$VERSION" CHANGELOG.md || \
80+
grep -q "^## Version $VERSION" CHANGELOG.md; then
81+
echo "version_exists=true" >> $GITHUB_OUTPUT
82+
echo "⚠️ Version $VERSION already exists in CHANGELOG.md - skipping generation"
83+
else
84+
echo "version_exists=false" >> $GITHUB_OUTPUT
85+
echo "✅ Version $VERSION not found in CHANGELOG.md - proceeding with generation"
86+
fi
87+
6888
- name: Generate changelog
6989
id: generate
90+
if: steps.check_version.outputs.version_exists == 'false'
7091
run: |
7192
VERSION="${{ steps.version_info.outputs.version }}"
7293
FROM_TAG="${{ steps.version_info.outputs.from_tag }}"
7394
TYPES="${{ inputs.include_types || 'feat,fix,docs,style,refactor,perf,test,chore,ci,build' }}"
74-
95+
7596
echo "Generating changelog for version: $VERSION"
7697
echo "From tag: $FROM_TAG"
7798
echo "Include types: $TYPES"
78-
99+
79100
# Generate new changelog entry
80101
python .github/scripts/generate_changelog.py \
81102
--version "$VERSION" \
82103
${FROM_TAG:+--from-tag "$FROM_TAG"} \
83104
--types "$TYPES" \
84105
--include-author \
85106
--output CHANGELOG_NEW.md
86-
107+
87108
# Check if changelog was generated
88109
if [ -f CHANGELOG_NEW.md ]; then
89110
echo "changelog_generated=true" >> $GITHUB_OUTPUT
@@ -94,12 +115,18 @@ jobs:
94115
echo "No changelog generated"
95116
fi
96117
118+
- name: Skip changelog generation
119+
if: steps.check_version.outputs.version_exists == 'true'
120+
run: |
121+
echo "changelog_generated=false" >> $GITHUB_OUTPUT
122+
echo "⚠️ Skipping changelog generation - version ${{ steps.version_info.outputs.version }} already exists"
123+
97124
- name: Update main changelog
98125
if: steps.generate.outputs.changelog_generated == 'true'
99126
run: |
100127
# Create backup of existing changelog
101128
cp CHANGELOG.md CHANGELOG_BACKUP.md
102-
129+
103130
# Combine new changelog with existing one
104131
{
105132
echo "# Change Log"
@@ -109,46 +136,66 @@ jobs:
109136
# Skip the header of the existing changelog and append the rest
110137
tail -n +3 CHANGELOG.md
111138
} > CHANGELOG_TEMP.md
112-
139+
113140
# Replace the original changelog
114141
mv CHANGELOG_TEMP.md CHANGELOG.md
115-
142+
116143
# Clean up
117144
rm CHANGELOG_NEW.md
118-
145+
119146
echo "Updated CHANGELOG.md successfully"
120147
148+
- name: Copy files to package directory
149+
if: steps.generate.outputs.changelog_generated == 'true'
150+
run: |
151+
# Copy CHANGELOG.md to package directory
152+
cp CHANGELOG.md packages/stadata_flutter_sdk/CHANGELOG.md
153+
echo "Copied CHANGELOG.md to packages/stadata_flutter_sdk/"
154+
155+
# Copy README.md to package directory
156+
cp README.md packages/stadata_flutter_sdk/README.md
157+
echo "Copied README.md to packages/stadata_flutter_sdk/"
158+
121159
- name: Create Pull Request
122-
if: steps.generate.outputs.changelog_generated == 'true' && (inputs.create_pr == true || github.event_name == 'push')
160+
if: steps.generate.outputs.changelog_generated == 'true' && (inputs.create_pr == true || startsWith(github.ref_name, 'release/'))
123161
uses: peter-evans/create-pull-request@v5
124162
with:
125163
token: ${{ secrets.GITHUB_TOKEN }}
126164
commit-message: "docs(changelog): update for version ${{ steps.version_info.outputs.version }}"
127165
title: "📝 Update changelog for version ${{ steps.version_info.outputs.version }}"
128166
body: |
129167
## 📝 Changelog Update
130-
168+
131169
This PR updates the changelog for version `${{ steps.version_info.outputs.version }}`.
132-
170+
133171
### Changes included:
134172
- Generated from commits since `${{ steps.version_info.outputs.from_tag }}`
135173
- Includes commit types: `${{ inputs.include_types || 'feat,fix,docs,style,refactor,perf,test,chore,ci,build' }}`
136-
174+
- Updated CHANGELOG.md in root directory
175+
- Copied CHANGELOG.md to packages/stadata_flutter_sdk/
176+
- Copied README.md to packages/stadata_flutter_sdk/
177+
178+
### Files updated:
179+
- `CHANGELOG.md` - Main changelog with new version entry
180+
- `packages/stadata_flutter_sdk/CHANGELOG.md` - Package changelog sync
181+
- `packages/stadata_flutter_sdk/README.md` - Package README sync
182+
137183
### Auto-generated content:
138184
The changelog content was automatically generated from git commits using conventional commit format.
139-
185+
140186
🤖 This PR was created automatically by the changelog generation workflow.
141187
branch: changelog/v${{ steps.version_info.outputs.version }}
188+
base: ${{ github.ref_name }}
142189
delete-branch: true
143190
labels: |
144191
documentation
145192
changelog
146193
automated
147194
148195
- name: Commit changes directly
149-
if: steps.generate.outputs.changelog_generated == 'true' && inputs.create_pr != true && github.event_name != 'push'
196+
if: steps.generate.outputs.changelog_generated == 'true' && inputs.create_pr != true && !startsWith(github.ref_name, 'release/')
150197
run: |
151-
git add CHANGELOG.md
198+
git add CHANGELOG.md packages/stadata_flutter_sdk/CHANGELOG.md packages/stadata_flutter_sdk/README.md
152199
git commit -m "docs(changelog): update for version ${{ steps.version_info.outputs.version }}"
153200
git push origin ${{ github.ref_name }}
154201
@@ -160,6 +207,8 @@ jobs:
160207
path: |
161208
CHANGELOG.md
162209
CHANGELOG_BACKUP.md
210+
packages/stadata_flutter_sdk/CHANGELOG.md
211+
packages/stadata_flutter_sdk/README.md
163212
retention-days: 30
164213

165214
- name: Summary
@@ -170,12 +219,15 @@ jobs:
170219
echo "- **Version**: ${{ steps.version_info.outputs.version }}" >> $GITHUB_STEP_SUMMARY
171220
echo "- **From Tag**: ${{ steps.version_info.outputs.from_tag }}" >> $GITHUB_STEP_SUMMARY
172221
echo "- **Types**: ${{ inputs.include_types || 'feat,fix,docs,style,refactor,perf,test,chore,ci,build' }}" >> $GITHUB_STEP_SUMMARY
173-
echo "- **Generated**: ${{ steps.generate.outputs.changelog_generated }}" >> $GITHUB_STEP_SUMMARY
174-
echo "- **Create PR**: ${{ inputs.create_pr || (github.event_name == 'push') }}" >> $GITHUB_STEP_SUMMARY
222+
echo "- **Version Exists**: ${{ steps.check_version.outputs.version_exists || 'N/A' }}" >> $GITHUB_STEP_SUMMARY
223+
echo "- **Generated**: ${{ steps.generate.outputs.changelog_generated || 'false' }}" >> $GITHUB_STEP_SUMMARY
224+
echo "- **Create PR**: ${{ inputs.create_pr || startsWith(github.ref_name, 'release/') }}" >> $GITHUB_STEP_SUMMARY
175225
echo "" >> $GITHUB_STEP_SUMMARY
176-
177-
if [ "${{ steps.generate.outputs.changelog_generated }}" = "true" ]; then
226+
227+
if [ "${{ steps.check_version.outputs.version_exists }}" = "true" ]; then
228+
echo "⚠️ Changelog generation skipped - version ${{ steps.version_info.outputs.version }} already exists in CHANGELOG.md" >> $GITHUB_STEP_SUMMARY
229+
elif [ "${{ steps.generate.outputs.changelog_generated }}" = "true" ]; then
178230
echo "✅ Changelog generated successfully!" >> $GITHUB_STEP_SUMMARY
179231
else
180232
echo "❌ No changelog generated" >> $GITHUB_STEP_SUMMARY
181-
fi
233+
fi

0 commit comments

Comments
 (0)