From 4b1f5590694c3400b3115d43804a34c1b1735121 Mon Sep 17 00:00:00 2001 From: Fajrian Aidil Pratama Date: Mon, 8 Sep 2025 23:28:49 +0700 Subject: [PATCH 1/8] fix: correct changelog script arguments in create-release workflow - Remove invalid --output flag from changelog generation - Fix invalid context access in workflow summary - Ensure deployment workflow triggers properly on tag creation --- .github/workflows/create-release.yml | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/.github/workflows/create-release.yml b/.github/workflows/create-release.yml index f25e944..287166d 100644 --- a/.github/workflows/create-release.yml +++ b/.github/workflows/create-release.yml @@ -90,11 +90,14 @@ jobs: # Generate changelog using the Ruby script ruby scripts/generate_changelog.rb \ --version "$VERSION" \ - --output "RELEASE_CHANGELOG.md" + --force - if [ -f "RELEASE_CHANGELOG.md" ]; then + if [ -f "CHANGELOG.md" ]; then echo "✅ Changelog generated successfully" + # Extract just the latest version section for the release notes + sed -n "/## \[v$VERSION\]/,/## \[/p" CHANGELOG.md | head -n -1 > RELEASE_CHANGELOG.md + # Save changelog content for release body (limit to reasonable size) echo "changelog<> $GITHUB_OUTPUT head -c 4000 RELEASE_CHANGELOG.md >> $GITHUB_OUTPUT @@ -203,8 +206,8 @@ jobs: echo "⚠️ **Status:** Skipped - tag already exists" >> $GITHUB_STEP_SUMMARY else echo "✅ **Status:** Release created successfully" >> $GITHUB_STEP_SUMMARY - if [ -n "${{ steps.create-release.outputs.release_url || '' }}" ]; then - echo "🔗 **Release URL:** ${{ steps.create-release.outputs.release_url }}" >> $GITHUB_STEP_SUMMARY + if [ -n "${{ steps.changelog.outputs.release_url || '' }}" ]; then + echo "🔗 **Release URL:** ${{ steps.changelog.outputs.release_url }}" >> $GITHUB_STEP_SUMMARY fi fi From 2a30f0616209cff3d1961b54fbc70fa0333e09db Mon Sep 17 00:00:00 2001 From: Fajrian Aidil Pratama Date: Mon, 8 Sep 2025 23:33:10 +0700 Subject: [PATCH 2/8] remove: duplicate create-release.yml workflow - Remove create-release.yml to prevent conflicts with release-automation.yml - Both workflows triggered on same events and created duplicate tags - release-automation.yml provides comprehensive GitFlow workflow - deploy.yml already handles GitHub release creation after deployment --- .github/workflows/create-release.yml | 218 --------------------------- 1 file changed, 218 deletions(-) delete mode 100644 .github/workflows/create-release.yml diff --git a/.github/workflows/create-release.yml b/.github/workflows/create-release.yml deleted file mode 100644 index 287166d..0000000 --- a/.github/workflows/create-release.yml +++ /dev/null @@ -1,218 +0,0 @@ -name: Create Release and Tag - -on: - pull_request: - types: [closed] - branches: - - main - -jobs: - create-release: - # Only run if PR was merged (not just closed) and came from release/* or hotfix/* branch - if: | - github.event.pull_request.merged == true && - (startsWith(github.event.pull_request.head.ref, 'release/') || - startsWith(github.event.pull_request.head.ref, 'hotfix/')) - - runs-on: ubuntu-latest - - permissions: - contents: write - pull-requests: read - - steps: - - name: Checkout repository - uses: actions/checkout@v4 - with: - fetch-depth: 0 # Need full history for changelog generation - token: ${{ secrets.GITHUB_TOKEN }} - - - name: Setup Ruby - uses: ruby/setup-ruby@v1 - with: - ruby-version: "3.2" - - - name: Configure Git - run: | - git config user.name "github-actions[bot]" - git config user.email "github-actions[bot]@users.noreply.github.com" - - - name: Extract version from branch name - id: version - run: | - BRANCH_NAME="${{ github.event.pull_request.head.ref }}" - echo "branch_name=$BRANCH_NAME" >> $GITHUB_OUTPUT - - if [[ $BRANCH_NAME == release/v* ]]; then - VERSION=$(echo $BRANCH_NAME | sed 's/release\/v//') - TYPE="release" - IS_PRERELEASE="false" - elif [[ $BRANCH_NAME == hotfix/v* ]]; then - VERSION=$(echo $BRANCH_NAME | sed 's/hotfix\/v//') - TYPE="hotfix" - IS_PRERELEASE="false" - fi - - # Validate version format - if [[ ! "$VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then - echo "❌ Invalid version format: $VERSION" - echo "Version must be in format x.y.z" - exit 1 - fi - - echo "version=$VERSION" >> $GITHUB_OUTPUT - echo "type=$TYPE" >> $GITHUB_OUTPUT - echo "tag_name=v$VERSION" >> $GITHUB_OUTPUT - echo "is_prerelease=$IS_PRERELEASE" >> $GITHUB_OUTPUT - - echo "✅ Extracted version: $VERSION ($TYPE)" - - - name: Check if tag already exists - id: check_tag - run: | - TAG_NAME="v${{ steps.version.outputs.version }}" - - if git rev-parse "$TAG_NAME" >/dev/null 2>&1; then - echo "exists=true" >> $GITHUB_OUTPUT - echo "⚠️ Tag $TAG_NAME already exists" - else - echo "exists=false" >> $GITHUB_OUTPUT - echo "✅ Tag $TAG_NAME does not exist, ready to create" - fi - - - name: Generate changelog for release - id: changelog - run: | - VERSION="${{ steps.version.outputs.version }}" - - echo "Generating changelog for version $VERSION..." - - # Generate changelog using the Ruby script - ruby scripts/generate_changelog.rb \ - --version "$VERSION" \ - --force - - if [ -f "CHANGELOG.md" ]; then - echo "✅ Changelog generated successfully" - - # Extract just the latest version section for the release notes - sed -n "/## \[v$VERSION\]/,/## \[/p" CHANGELOG.md | head -n -1 > RELEASE_CHANGELOG.md - - # Save changelog content for release body (limit to reasonable size) - echo "changelog<> $GITHUB_OUTPUT - head -c 4000 RELEASE_CHANGELOG.md >> $GITHUB_OUTPUT - echo "EOF" >> $GITHUB_OUTPUT - else - echo "❌ Failed to generate changelog" - exit 1 - fi - - - name: Create Git tag - if: steps.check_tag.outputs.exists == 'false' - run: | - TAG_NAME="${{ steps.version.outputs.tag_name }}" - VERSION="${{ steps.version.outputs.version }}" - TYPE="${{ steps.version.outputs.type }}" - - # Create annotated tag - if [ "$TYPE" = "release" ]; then - TAG_MESSAGE="Release v$VERSION" - else - TAG_MESSAGE="Hotfix v$VERSION" - fi - - git tag -a "$TAG_NAME" -m "$TAG_MESSAGE" - git push origin "$TAG_NAME" - - echo "✅ Created and pushed tag: $TAG_NAME" - - - name: Create GitHub Release - if: steps.check_tag.outputs.exists == 'false' - env: - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: | - TAG_NAME="${{ steps.version.outputs.tag_name }}" - VERSION="${{ steps.version.outputs.version }}" - TYPE="${{ steps.version.outputs.type }}" - IS_PRERELEASE="${{ steps.version.outputs.is_prerelease }}" - - # Set release title and flags - if [ "$TYPE" = "release" ]; then - RELEASE_TITLE="🚀 Release v$VERSION" - RELEASE_FLAGS="" - else - RELEASE_TITLE="🔥 Hotfix v$VERSION" - RELEASE_FLAGS="" - fi - - # Add prerelease flag if needed - if [ "$IS_PRERELEASE" = "true" ]; then - RELEASE_FLAGS="$RELEASE_FLAGS --prerelease" - fi - - # Create the GitHub release - cat > release_body.md << 'RELEASE_EOF' - ${{ steps.changelog.outputs.changelog }} - - --- - - ## 📦 Installation - - ### Docker - ```bash - docker pull ghcr.io/banua-coder/pico-api-docs:v${{ steps.version.outputs.version }} - ``` - - ### Manual Download - Download the latest build artifacts from this release. - - ## 🔗 Related Links - - - **API Documentation**: https://pico-api-docs.banuacoder.com - - **Source Code**: https://github.com/banua-coder/pico-api-docs - - **Issues**: https://github.com/banua-coder/pico-api-docs/issues - - ## 📋 Changelog - - For detailed changes, see [CHANGELOG.md](https://github.com/banua-coder/pico-api-docs/blob/main/CHANGELOG.md) - RELEASE_EOF - - # Create the release - gh release create "$TAG_NAME" \ - --title "$RELEASE_TITLE" \ - --notes-file release_body.md \ - --target main \ - $RELEASE_FLAGS - - echo "✅ GitHub release created: $TAG_NAME" - - # Get release URL for summary - RELEASE_URL=$(gh release view "$TAG_NAME" --json url -q '.url') - echo "release_url=$RELEASE_URL" >> $GITHUB_OUTPUT - - - name: Summary - if: always() - run: | - echo "## Release Creation Summary" >> $GITHUB_STEP_SUMMARY - echo "" >> $GITHUB_STEP_SUMMARY - echo "- **Source PR:** #${{ github.event.pull_request.number }}" >> $GITHUB_STEP_SUMMARY - echo "- **Source Branch:** \`${{ github.event.pull_request.head.ref }}\`" >> $GITHUB_STEP_SUMMARY - echo "- **Version:** v${{ steps.version.outputs.version }}" >> $GITHUB_STEP_SUMMARY - echo "- **Type:** ${{ steps.version.outputs.type }}" >> $GITHUB_STEP_SUMMARY - echo "- **Tag:** \`${{ steps.version.outputs.tag_name }}\`" >> $GITHUB_STEP_SUMMARY - echo "" >> $GITHUB_STEP_SUMMARY - - if [ "${{ steps.check_tag.outputs.exists }}" == "true" ]; then - echo "⚠️ **Status:** Skipped - tag already exists" >> $GITHUB_STEP_SUMMARY - else - echo "✅ **Status:** Release created successfully" >> $GITHUB_STEP_SUMMARY - if [ -n "${{ steps.changelog.outputs.release_url || '' }}" ]; then - echo "🔗 **Release URL:** ${{ steps.changelog.outputs.release_url }}" >> $GITHUB_STEP_SUMMARY - fi - fi - - echo "" >> $GITHUB_STEP_SUMMARY - echo "### Next Steps" >> $GITHUB_STEP_SUMMARY - echo "1. ✅ Tag and release created" >> $GITHUB_STEP_SUMMARY - echo "2. 🔄 Backmerge to develop will run automatically" >> $GITHUB_STEP_SUMMARY - echo "3. 🚀 Deployment pipeline will trigger automatically" >> $GITHUB_STEP_SUMMARY From ebdc3b8d3ace6592d91ae4bffc0242ed2500f0f2 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Mon, 8 Sep 2025 16:31:31 +0000 Subject: [PATCH 3/8] chore: prepare v1.1.1 hotfix - Update version to 1.1.1 in package.json - Generate release changelog This commit prepares the hotfix/v1.1.1 branch for hotfix. --- CHANGELOG.md | 7 +++++++ package.json | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6401d2c..9280c43 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,10 @@ +## [v1.1.1] - 2025-09-08 + +### Fixed + +- Correct changelog script arguments in create-release workflow (4b1f559) + + ## [v1.1.0] - 2025-09-08 ### Added diff --git a/package.json b/package.json index 3040cf3..8c3f853 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "pico-api-docs", - "version": "1.1.0", + "version": "1.1.1", "description": "PICO SulTeng API Documentation - COVID-19 Sulawesi Tengah Data API", "main": "index.js", "scripts": { From 3901d7a24b7edb17218da763ae26d0c582d7a559 Mon Sep 17 00:00:00 2001 From: Fajrian Aidil Pratama Date: Mon, 8 Sep 2025 23:36:50 +0700 Subject: [PATCH 4/8] docs(CHANGELOG): re-generate changelog --- CHANGELOG.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9280c43..885c2c8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,13 @@ - Correct changelog script arguments in create-release workflow (4b1f559) +### Maintenance + +- Prepare v1.1.1 hotfix (ebdc3b8) + +### Other + +- Duplicate create-release.yml workflow (2a30f06) ## [v1.1.0] - 2025-09-08 From 4419f0dfb90f15220d66a19b81593d104a854f2c Mon Sep 17 00:00:00 2001 From: Fajrian Aidil Pratama Date: Mon, 8 Sep 2025 23:40:18 +0700 Subject: [PATCH 5/8] ci(workflow): fix workflow --- .github/workflows/backmerge-to-develop.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/backmerge-to-develop.yml b/.github/workflows/backmerge-to-develop.yml index 11df6d1..41ae1bc 100644 --- a/.github/workflows/backmerge-to-develop.yml +++ b/.github/workflows/backmerge-to-develop.yml @@ -109,7 +109,7 @@ jobs: --- *This PR was automatically created by GitHub Actions workflow.* - PREOF +PREOF # Create PR with review requirements # Uncomment --draft if you want PRs to be created as draft @@ -169,7 +169,7 @@ jobs: --- *This PR was automatically created by GitHub Actions workflow. Manual conflict resolution is required.* - CONFLICT_EOF +CONFLICT_EOF gh pr create \ --base develop \ From fe0bc6dde8f8fb107493f07a975e1bb1f48f1b80 Mon Sep 17 00:00:00 2001 From: Fajrian Aidil Pratama Date: Mon, 8 Sep 2025 23:42:07 +0700 Subject: [PATCH 6/8] ci(workflow): fix again --- .github/workflows/backmerge-to-develop.yml | 26 +++++++++++----------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/.github/workflows/backmerge-to-develop.yml b/.github/workflows/backmerge-to-develop.yml index 41ae1bc..7983f7f 100644 --- a/.github/workflows/backmerge-to-develop.yml +++ b/.github/workflows/backmerge-to-develop.yml @@ -86,10 +86,10 @@ jobs: # Create PR using GitHub CLI PR_TITLE="chore: backmerge v${{ steps.version.outputs.version }} to develop" - cat > pr_body.md << 'PREOF' + cat > pr_body.md << EOF ## Automated Backmerge - This PR automatically backmerges changes from `main` to `develop` branch. + This PR automatically backmerges changes from \`main\` to \`develop\` branch. ### Source - **Original PR:** #${{ github.event.pull_request.number }} @@ -98,7 +98,7 @@ jobs: - **Merged at:** ${{ github.event.pull_request.merged_at }} ### Branch Information - - **Source branch:** `${{ github.event.pull_request.head.ref }}` + - **Source branch:** \`${{ github.event.pull_request.head.ref }}\` - **Type:** ${{ github.event.pull_request.head.ref }} ### Actions Required @@ -109,7 +109,7 @@ jobs: --- *This PR was automatically created by GitHub Actions workflow.* -PREOF + EOF # Create PR with review requirements # Uncomment --draft if you want PRs to be created as draft @@ -136,10 +136,10 @@ PREOF # Create PR with conflict warning PR_TITLE="chore: backmerge v${{ steps.version.outputs.version }} to develop (conflicts)" - cat > pr_conflict_body.md << 'CONFLICT_EOF' + cat > pr_conflict_body.md << EOF ## ⚠️ Automated Backmerge with Conflicts - This PR attempts to backmerge changes from `main` to `develop` branch, but **conflicts were detected**. + This PR attempts to backmerge changes from \`main\` to \`develop\` branch, but **conflicts were detected**. ### Source - **Original PR:** #${{ github.event.pull_request.number }} @@ -148,28 +148,28 @@ PREOF - **Merged at:** ${{ github.event.pull_request.merged_at }} ### Branch Information - - **Source branch:** `${{ github.event.pull_request.head.ref }}` + - **Source branch:** \`${{ github.event.pull_request.head.ref }}\` - **Type:** ${{ github.event.pull_request.head.ref }} ### ⚠️ Manual Actions Required 1. Checkout the branch locally - 2. Merge `main` and resolve conflicts manually + 2. Merge \`main\` and resolve conflicts manually 3. Push the resolved changes 4. Request review and merge this PR - ```bash + \`\`\`bash git fetch origin - git checkout -b ${BACKMERGE_BRANCH} origin/${BACKMERGE_BRANCH} + git checkout -b \${BACKMERGE_BRANCH} origin/\${BACKMERGE_BRANCH} git merge origin/main # Resolve conflicts in your editor git add . git commit - git push origin ${BACKMERGE_BRANCH} - ``` + git push origin \${BACKMERGE_BRANCH} + \`\`\` --- *This PR was automatically created by GitHub Actions workflow. Manual conflict resolution is required.* -CONFLICT_EOF + EOF gh pr create \ --base develop \ From f2cfa9288aa8117ebe307bb1468643936e8a13b5 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Mon, 8 Sep 2025 15:32:58 +0000 Subject: [PATCH 7/8] chore: bump version to v1.2.0 for next development cycle Following release branch creation for v1.1.0, updating develop branch to target the next minor version v1.2.0. Changes: - Update package.json version to 1.2.0 - Prepare for next development cycle This maintains the Git Flow pattern where develop always contains the next planned version. --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 8c3f853..92b8de3 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "pico-api-docs", - "version": "1.1.1", + "version": "1.2.0", "description": "PICO SulTeng API Documentation - COVID-19 Sulawesi Tengah Data API", "main": "index.js", "scripts": { From bf8c2f6d100de9620e45d84f7a396569d017aaeb Mon Sep 17 00:00:00 2001 From: Fajrian Aidil Pratama Date: Mon, 8 Sep 2025 23:47:51 +0700 Subject: [PATCH 8/8] ci(workflow): fix release automation workflow --- .github/workflows/release-automation.yml | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/.github/workflows/release-automation.yml b/.github/workflows/release-automation.yml index de92612..bbba816 100644 --- a/.github/workflows/release-automation.yml +++ b/.github/workflows/release-automation.yml @@ -149,6 +149,22 @@ jobs: echo "✅ Tag $VERSION created and pushed successfully" + - name: Trigger deployment workflow + if: steps.check_tag.outputs.tag_exists == 'false' + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + VERSION="${{ steps.version.outputs.version }}" + + echo "🚀 Manually triggering deployment workflow for tag $VERSION..." + + # Trigger the deploy workflow by creating a repository dispatch event + # Since we can't directly trigger tag-based workflows, we'll use workflow_dispatch + # But first, let's try using the GitHub CLI to trigger it + gh workflow run deploy.yml --ref "$VERSION" || echo "⚠️ Could not trigger via workflow dispatch, deployment should trigger automatically" + + echo "✅ Deployment trigger attempted" + # STEP 2: CREATE BACK-MERGE TO DEVELOP - name: Generate unique back-merge branch name id: branch_name