From 99d94b84ea3cae0283e5426c3b472a45cf7feec9 Mon Sep 17 00:00:00 2001 From: MarkG Date: Tue, 5 Nov 2024 15:10:44 +0700 Subject: [PATCH 1/6] [#557] Add Create Release Pull Request workflow --- .../configs/changelog-config.json | 32 ++++++ .../create_release_pull_request.yml | 98 +++++++++++++++++++ 2 files changed, 130 insertions(+) create mode 100644 .github/project_workflows/configs/changelog-config.json create mode 100644 .github/project_workflows/create_release_pull_request.yml diff --git a/.github/project_workflows/configs/changelog-config.json b/.github/project_workflows/configs/changelog-config.json new file mode 100644 index 00000000..179678d8 --- /dev/null +++ b/.github/project_workflows/configs/changelog-config.json @@ -0,0 +1,32 @@ +{ + "categories": [ + { + "title": "## โœจ Features", + "labels": [ + "type: feature" + ] + }, + { + "title": "## ๐Ÿ› Bug fixes", + "labels": [ + "type: bug" + ] + }, + { + "title": "## ๐Ÿงน Chores", + "labels": [ + "type: chore" + ] + }, + { + "title": "## Others", + "exclude_labels": [ + "type: feature", + "type: bug", + "type: chore", + "type: release" + ] + } + ], + "max_pull_requests": 200 + } diff --git a/.github/project_workflows/create_release_pull_request.yml b/.github/project_workflows/create_release_pull_request.yml new file mode 100644 index 00000000..6809ae01 --- /dev/null +++ b/.github/project_workflows/create_release_pull_request.yml @@ -0,0 +1,98 @@ +name: Create Release Pull Request + +on: + workflow_dispatch: + inputs: + nextVersion: + description: "Next version (eg. 1.0.0)" + required: true + type: string + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + create_release_pull_request: + name: Create Release Pull Request + runs-on: ubuntu-latest + timeout-minutes: 30 + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Find HEAD commit + id: head + run: echo "sha=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT + + - name: Build changelog on "main" + id: changelog + uses: mikepenz/release-changelog-builder-action@v4 + with: + configuration: ".github/workflows/configs/changelog-config.json" + # Listing PRs from the last tag to the HEAD commit + toTag: ${{ steps.head.outputs.sha }} + token: ${{ secrets.GITHUB_TOKEN }} + + - name: Prepare variables + run: | + filename=$(find . -maxdepth 1 -name "*.xcodeproj" -exec basename {} .xcodeproj \; | head -n 1) + release_version=$(sed -n 's/.*MARKETING_VERSION *= *\([^;]*\);.*/\1/p' "$filename.xcodeproj/project.pbxproj" | head -n 1 | sed 's/^[^=]*=\s*//' | tr -d ' ') + echo $release_version + echo "RELEASE_VERSION=$release_version" >> "$GITHUB_ENV" + echo "${{ steps.changelog.outputs.changelog }}" | sed 's/"/\\"/g' > escaped-changelog.txt + + - name: Create Release branch + uses: peterjgrainger/action-create-branch@v2.2.0 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + branch: release/${{ env.RELEASE_VERSION }} + + - name: Create pull request + run: gh pr create --draft -B main -H release/${{ env.RELEASE_VERSION }} -t 'Release - ${{ env.RELEASE_VERSION }}' -b "$(cat escaped-changelog.txt)" + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + create_bump_version_pull_request: + name: Create Bump Version Pull Request + runs-on: macos-latest + timeout-minutes: 30 + permissions: + contents: write + pull-requests: write + steps: + - name: Create Bump Version branch + uses: peterjgrainger/action-create-branch@v2.2.0 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + branch: chore/bump-version-to-${{ github.event.inputs.nextVersion }} + + - name: Checkout code + uses: actions/checkout@v4 + with: + ref: chore/bump-version-to-${{ github.event.inputs.nextVersion }} + + - name: Bump version + run: | + filename=$(find . -maxdepth 1 -name "*.xcodeproj" -exec basename {} .xcodeproj \; | head -n 1) + sed -i "" "s/MARKETING_VERSION = .*/MARKETING_VERSION = ${{ github.event.inputs.nextVersion }};/g" $filename.xcodeproj/project.pbxproj + + - name: Set up Git + run: | + git config --global user.name 'Github Actions' + git config --global user.email 'github-actions@users.noreply.github.com' + + - name: Commit changes + run: | + git add . + git commit -m "[Chore] Bump version to ${{ github.event.inputs.nextVersion }}" + git push origin HEAD + + - name: Create pull request + run: | + echo -e "## What happened ๐Ÿ‘€\n\nBump version to ${{ github.event.inputs.nextVersion }}" > body + export body=$(cat body) ; gh pr create --draft -B develop -H chore/bump-version-to-${{ github.event.inputs.nextVersion }} -t '[Chore] Bump version to ${{ github.event.inputs.nextVersion }}' -b "$body" + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} From 2eb67163fde706e7a72a33e5ac7991b0f4ab73a0 Mon Sep 17 00:00:00 2001 From: MarkG Date: Thu, 21 Nov 2024 10:27:50 +0700 Subject: [PATCH 2/6] [#557] Add Create Release Pull Request workflow --- .../Sources/iOSTemplateMaker/SetUpiOSProject.swift | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Scripts/Swift/iOSTemplateMaker/Sources/iOSTemplateMaker/SetUpiOSProject.swift b/Scripts/Swift/iOSTemplateMaker/Sources/iOSTemplateMaker/SetUpiOSProject.swift index 2504a54b..2767e4fa 100644 --- a/Scripts/Swift/iOSTemplateMaker/Sources/iOSTemplateMaker/SetUpiOSProject.swift +++ b/Scripts/Swift/iOSTemplateMaker/Sources/iOSTemplateMaker/SetUpiOSProject.swift @@ -90,7 +90,7 @@ class SetUpIOSProject { } if isCI { - minimumVersion = "14.0" + minimumVersion = "15.0" } if bundleIdProduction.isEmpty { @@ -123,7 +123,7 @@ class SetUpIOSProject { if minimumVersion.isEmpty { tryMoveDown() - let defaultVersion = "14.0" + let defaultVersion = "15.0" minimumVersion = ask( "Which is the iOS minimum version?", note: "Default: \(defaultVersion)", From 44efb989be5dc95cf280746b3beb1b931169eb6d Mon Sep 17 00:00:00 2001 From: MarkG Date: Tue, 17 Dec 2024 14:07:14 +0700 Subject: [PATCH 3/6] [#557] Add validation step --- .github/project_workflows/create_release_pull_request.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/project_workflows/create_release_pull_request.yml b/.github/project_workflows/create_release_pull_request.yml index 6809ae01..a1da9775 100644 --- a/.github/project_workflows/create_release_pull_request.yml +++ b/.github/project_workflows/create_release_pull_request.yml @@ -62,6 +62,12 @@ jobs: contents: write pull-requests: write steps: + - name: Validate Version Input + run: | + if ! [[ "${{ github.event.inputs.nextVersion }}" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then + echo "Error: nextVersion must follow semantic versioning (e.g., 1.2.3)" + exit 1 + fi - name: Create Bump Version branch uses: peterjgrainger/action-create-branch@v2.2.0 env: From 8bb37ad18f780b159f05bd2a203eb014ecd64969 Mon Sep 17 00:00:00 2001 From: MarkG Date: Fri, 27 Dec 2024 14:04:25 +0700 Subject: [PATCH 4/6] [#557] Change create release PR approach --- .../create_release_pull_request.yml | 30 ++++--------------- 1 file changed, 5 insertions(+), 25 deletions(-) diff --git a/.github/project_workflows/create_release_pull_request.yml b/.github/project_workflows/create_release_pull_request.yml index a1da9775..a7a1fe42 100644 --- a/.github/project_workflows/create_release_pull_request.yml +++ b/.github/project_workflows/create_release_pull_request.yml @@ -21,38 +21,18 @@ jobs: - name: Checkout code uses: actions/checkout@v4 - - name: Find HEAD commit - id: head - run: echo "sha=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT - - - name: Build changelog on "main" - id: changelog - uses: mikepenz/release-changelog-builder-action@v4 - with: - configuration: ".github/workflows/configs/changelog-config.json" - # Listing PRs from the last tag to the HEAD commit - toTag: ${{ steps.head.outputs.sha }} - token: ${{ secrets.GITHUB_TOKEN }} - - - name: Prepare variables + - name: Get release version run: | filename=$(find . -maxdepth 1 -name "*.xcodeproj" -exec basename {} .xcodeproj \; | head -n 1) release_version=$(sed -n 's/.*MARKETING_VERSION *= *\([^;]*\);.*/\1/p' "$filename.xcodeproj/project.pbxproj" | head -n 1 | sed 's/^[^=]*=\s*//' | tr -d ' ') echo $release_version echo "RELEASE_VERSION=$release_version" >> "$GITHUB_ENV" - echo "${{ steps.changelog.outputs.changelog }}" | sed 's/"/\\"/g' > escaped-changelog.txt - - name: Create Release branch - uses: peterjgrainger/action-create-branch@v2.2.0 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + - uses: nimblehq/github-actions-workflows/create_release_pull_request@0.1.10 with: - branch: release/${{ env.RELEASE_VERSION }} - - - name: Create pull request - run: gh pr create --draft -B main -H release/${{ env.RELEASE_VERSION }} -t 'Release - ${{ env.RELEASE_VERSION }}' -b "$(cat escaped-changelog.txt)" - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + release_version: ${{ env.RELEASE_VERSION }} + changelog_configuration: ".github/workflows/config/changelog-config.json" + assignee: bot-nimble create_bump_version_pull_request: name: Create Bump Version Pull Request From fd30a0e79aa18782173d9480ee5176474278403f Mon Sep 17 00:00:00 2001 From: MarkG Date: Fri, 3 Jan 2025 09:42:21 +0700 Subject: [PATCH 5/6] [#557] Upgrade minimum version --- .../Sources/iOSTemplateMaker/SetUpiOSProject.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Scripts/Swift/iOSTemplateMaker/Sources/iOSTemplateMaker/SetUpiOSProject.swift b/Scripts/Swift/iOSTemplateMaker/Sources/iOSTemplateMaker/SetUpiOSProject.swift index 2767e4fa..e594ee9d 100644 --- a/Scripts/Swift/iOSTemplateMaker/Sources/iOSTemplateMaker/SetUpiOSProject.swift +++ b/Scripts/Swift/iOSTemplateMaker/Sources/iOSTemplateMaker/SetUpiOSProject.swift @@ -123,7 +123,7 @@ class SetUpIOSProject { if minimumVersion.isEmpty { tryMoveDown() - let defaultVersion = "15.0" + let defaultVersion = "16.0" minimumVersion = ask( "Which is the iOS minimum version?", note: "Default: \(defaultVersion)", From 34f498bd35f9c87e06dbe5b77a5253b80a05d014 Mon Sep 17 00:00:00 2001 From: MarkG Date: Tue, 14 Jan 2025 09:48:31 +0700 Subject: [PATCH 6/6] [#557] Improve naming --- .../configs/changelog-config.json | 65 ++++++++++--------- ...release_pull_request_and_bump_version.yml} | 6 +- 2 files changed, 37 insertions(+), 34 deletions(-) rename .github/project_workflows/{create_release_pull_request.yml => create_release_pull_request_and_bump_version.yml} (94%) diff --git a/.github/project_workflows/configs/changelog-config.json b/.github/project_workflows/configs/changelog-config.json index 179678d8..a7ce571d 100644 --- a/.github/project_workflows/configs/changelog-config.json +++ b/.github/project_workflows/configs/changelog-config.json @@ -1,32 +1,35 @@ { - "categories": [ - { - "title": "## โœจ Features", - "labels": [ - "type: feature" - ] - }, - { - "title": "## ๐Ÿ› Bug fixes", - "labels": [ - "type: bug" - ] - }, - { - "title": "## ๐Ÿงน Chores", - "labels": [ - "type: chore" - ] - }, - { - "title": "## Others", - "exclude_labels": [ - "type: feature", - "type: bug", - "type: chore", - "type: release" - ] - } - ], - "max_pull_requests": 200 - } + "categories": [ + { + "title": "## โœจ Features", + "labels": [ + "type : feature" + ], + "empty_content": "N/A" + }, + { + "title": "## ๐Ÿ› Bug fixes", + "labels": [ + "type : bug" + ], + "empty_content": "N/A" + }, + { + "title": "## ๐Ÿงน Chores", + "labels": [ + "type : chore" + ], + "empty_content": "N/A" + }, + { + "title": "## Others", + "exclude_labels": [ + "type : feature", + "type : bug", + "type : chore", + "type : release" + ] + } + ], + "max_pull_requests": 200 +} \ No newline at end of file diff --git a/.github/project_workflows/create_release_pull_request.yml b/.github/project_workflows/create_release_pull_request_and_bump_version.yml similarity index 94% rename from .github/project_workflows/create_release_pull_request.yml rename to .github/project_workflows/create_release_pull_request_and_bump_version.yml index a7a1fe42..805d1c32 100644 --- a/.github/project_workflows/create_release_pull_request.yml +++ b/.github/project_workflows/create_release_pull_request_and_bump_version.yml @@ -1,4 +1,4 @@ -name: Create Release Pull Request +name: Create the Release pull request and Bump the next version on: workflow_dispatch: @@ -31,11 +31,11 @@ jobs: - uses: nimblehq/github-actions-workflows/create_release_pull_request@0.1.10 with: release_version: ${{ env.RELEASE_VERSION }} - changelog_configuration: ".github/workflows/config/changelog-config.json" + changelog_configuration: ".github/workflows/configs/changelog-config.json" assignee: bot-nimble create_bump_version_pull_request: - name: Create Bump Version Pull Request + name: Bump Version Pull Request runs-on: macos-latest timeout-minutes: 30 permissions: