From 4c87eb78c6171bbb0dc0b71f3b44cb6949f2818c Mon Sep 17 00:00:00 2001 From: shibatanaoto Date: Sun, 12 Jan 2025 17:03:57 +0900 Subject: [PATCH 1/3] update release-drafter --- .github/workflows/release-drafter.yml | 52 +++++++++++++++++++++++++-- 1 file changed, 49 insertions(+), 3 deletions(-) diff --git a/.github/workflows/release-drafter.yml b/.github/workflows/release-drafter.yml index f1b142a..e9e7a76 100644 --- a/.github/workflows/release-drafter.yml +++ b/.github/workflows/release-drafter.yml @@ -1,15 +1,61 @@ name: Release Drafter + on: - push: - branches: develop + pull_request: + types: [opened, reopened, synchronize, closed] + branches: + - develop + - release/* jobs: - update_release_draft: + draft_release_notes: + if: > + (github.event.pull_request.base.ref == 'develop' && + !startsWith(github.event.pull_request.head.ref, 'release/') && + github.event.pull_request.head.ref != 'main') || + startsWith(github.event.pull_request.base.ref, 'release/') runs-on: ubuntu-latest steps: - name: Checkout repository uses: actions/checkout@v3 + + - name: Get current version from tags + id: get_current_version + run: | + # Get the latest tag (assuming tags follow semantic versioning) + CURRENT_VERSION=$(git describe --tags --abbrev=0 2>/dev/null || echo "v0.0.0") + echo "CURRENT_VERSION=${CURRENT_VERSION}" >> $GITHUB_ENV + + - name: Determine next version + id: determine_next_version + run: | + if [[ "${{ github.event.pull_request.base.ref }}" == "develop" ]]; then + # Increment the minor version + IFS='.' read -r -a parts <<< "${CURRENT_VERSION#v}" + MAJOR=${parts[0]} + MINOR=${parts[1]} + PATCH=${parts[2]} + NEXT_VERSION="v${MAJOR}.$((MINOR + 1)).0" + elif [[ "${{ github.event.pull_request.base.ref }}" == release/* ]]; then + # Use the release branch version + NEXT_VERSION="${{ github.event.pull_request.base.ref##release/ }}" + fi + echo "NEXT_VERSION=${NEXT_VERSION}" >> $GITHUB_ENV + echo "Next version: ${NEXT_VERSION}" + - name: Update release draft uses: release-drafter/release-drafter@v5 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + version: ${{ env.NEXT_VERSION }} + config-name: ${{ github.event.pull_request.base.ref == 'develop' && 'develop' || 'release' }} + + skip_on_merge_to_develop: + if: github.event.pull_request.base.ref == 'develop' && + (startsWith(github.event.pull_request.head.ref, 'release/') || + github.event.pull_request.head.ref == 'main') + runs-on: ubuntu-latest + steps: + - name: Skip updating release draft for merge into develop + run: echo "No action taken for merge from release/* or main into develop." From de41aeb11e6cd51328ecd159c3df3702a8ba055d Mon Sep 17 00:00:00 2001 From: shibatanaoto Date: Sun, 12 Jan 2025 17:14:52 +0900 Subject: [PATCH 2/3] update branch --- .github/workflows/release-drafter.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/release-drafter.yml b/.github/workflows/release-drafter.yml index e9e7a76..abefe63 100644 --- a/.github/workflows/release-drafter.yml +++ b/.github/workflows/release-drafter.yml @@ -38,11 +38,12 @@ jobs: NEXT_VERSION="v${MAJOR}.$((MINOR + 1)).0" elif [[ "${{ github.event.pull_request.base.ref }}" == release/* ]]; then # Use the release branch version - NEXT_VERSION="${{ github.event.pull_request.base.ref##release/ }}" + base_ref="${{ github.event.pull_request.base.ref }}" + NEXT_VERSION="${base_ref#release/}" fi echo "NEXT_VERSION=${NEXT_VERSION}" >> $GITHUB_ENV echo "Next version: ${NEXT_VERSION}" - + - name: Update release draft - name: Update release draft uses: release-drafter/release-drafter@v5 env: From b642642b1dd9b7004991d3f455eb8fcb4bdd565e Mon Sep 17 00:00:00 2001 From: shibatanaoto Date: Sun, 12 Jan 2025 19:22:58 +0900 Subject: [PATCH 3/3] fix release-drafter config & make release/* available --- .github/release-drafter.yml | 6 +++--- .github/workflows/release-drafter.yml | 30 +++++++++++++-------------- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/.github/release-drafter.yml b/.github/release-drafter.yml index 66d5f8a..90a5253 100644 --- a/.github/release-drafter.yml +++ b/.github/release-drafter.yml @@ -1,5 +1,5 @@ -name-template: 'v$NEXT_PATCH_VERSION' -tag-template: 'v$NEXT_PATCH_VERSION' +name-template: 'v$RESOLVED_VERSION' +tag-template: 'v$RESOLVED_VERSION' categories: - title: '🚀 New Features' labels: @@ -20,4 +20,4 @@ template: | $CHANGES - --- \ No newline at end of file + --- diff --git a/.github/workflows/release-drafter.yml b/.github/workflows/release-drafter.yml index abefe63..f7e7ff0 100644 --- a/.github/workflows/release-drafter.yml +++ b/.github/workflows/release-drafter.yml @@ -2,18 +2,21 @@ name: Release Drafter on: pull_request: - types: [opened, reopened, synchronize, closed] + types: + - closed branches: - develop - release/* jobs: draft_release_notes: + # develop branch or minor release branch if: > (github.event.pull_request.base.ref == 'develop' && !startsWith(github.event.pull_request.head.ref, 'release/') && github.event.pull_request.head.ref != 'main') || - startsWith(github.event.pull_request.base.ref, 'release/') + (startsWith(github.event.pull_request.base.ref, 'release/') && + endsWith(github.event.pull_request.base.ref, '0')) runs-on: ubuntu-latest steps: - name: Checkout repository @@ -22,8 +25,14 @@ jobs: - name: Get current version from tags id: get_current_version run: | - # Get the latest tag (assuming tags follow semantic versioning) - CURRENT_VERSION=$(git describe --tags --abbrev=0 2>/dev/null || echo "v0.0.0") + # fetch all tags + git fetch --tags + + # Find the latest tag using semantic versioning + CURRENT_VERSION=$(git tag -l --sort=-v:refname | head -n 1) + if [ -z "$CURRENT_VERSION" ]; then + CURRENT_VERSION="v0.0.0" # Default if no tags exist + fi echo "CURRENT_VERSION=${CURRENT_VERSION}" >> $GITHUB_ENV - name: Determine next version @@ -43,20 +52,11 @@ jobs: fi echo "NEXT_VERSION=${NEXT_VERSION}" >> $GITHUB_ENV echo "Next version: ${NEXT_VERSION}" - - name: Update release draft - name: Update release draft uses: release-drafter/release-drafter@v5 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: + tag: ${{ env.NEXT_VERSION }} + name: ${{ env.NEXT_VERSION }} version: ${{ env.NEXT_VERSION }} - config-name: ${{ github.event.pull_request.base.ref == 'develop' && 'develop' || 'release' }} - - skip_on_merge_to_develop: - if: github.event.pull_request.base.ref == 'develop' && - (startsWith(github.event.pull_request.head.ref, 'release/') || - github.event.pull_request.head.ref == 'main') - runs-on: ubuntu-latest - steps: - - name: Skip updating release draft for merge into develop - run: echo "No action taken for merge from release/* or main into develop."