From 90dc04145feab7158bda426a3b6d1383a9c1baa0 Mon Sep 17 00:00:00 2001 From: Madhu Chavva Date: Thu, 17 Oct 2024 16:13:02 -0700 Subject: [PATCH 01/29] Test Change --- .../com/example/demo/services/AcmeDonutsFeatureService.java | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/jvm-spring-web/src/main/java/com/example/demo/services/AcmeDonutsFeatureService.java b/jvm-spring-web/src/main/java/com/example/demo/services/AcmeDonutsFeatureService.java index e13b0e7..d9b0a66 100644 --- a/jvm-spring-web/src/main/java/com/example/demo/services/AcmeDonutsFeatureService.java +++ b/jvm-spring-web/src/main/java/com/example/demo/services/AcmeDonutsFeatureService.java @@ -35,7 +35,7 @@ public void onRefresh(String featuresJson) { } void handleError(FeatureFetchException e) { - e.printStackTrace(); + //e.printStackTrace(); switch (e.getErrorCode()) { case NO_RESPONSE_ERROR -> { @@ -46,9 +46,7 @@ void handleError(FeatureFetchException e) { // SSE is not applicable for this service but this was added here for completion. } - case CONFIGURATION_ERROR, UNKNOWN -> { - throw new RuntimeException(e); - } + case CONFIGURATION_ERROR, UNKNOWN -> throw new RuntimeException(e); } } } From 5cd499b5e64e7e39252d54621c381d38e67505a7 Mon Sep 17 00:00:00 2001 From: Madhu Chavva Date: Fri, 18 Oct 2024 14:36:39 -0700 Subject: [PATCH 02/29] add semantic versioning for builds --- .github/workflows/semVer_ci.yml | 46 +++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 .github/workflows/semVer_ci.yml diff --git a/.github/workflows/semVer_ci.yml b/.github/workflows/semVer_ci.yml new file mode 100644 index 0000000..304a547 --- /dev/null +++ b/.github/workflows/semVer_ci.yml @@ -0,0 +1,46 @@ +name: Semantic Versioning and Build + +on: + push: + branches: + - main + - 'release/*' + pull_request: + branches: + - main + +jobs: + versioning: + runs-on: ubuntu-latest + + steps: + - name: Checkout Repository + uses: actions/checkout@v3 + + - name: Set up JDK + uses: actions/setup-java@v3 + with: + distribution: 'temurin' + java-version: '17' + + - name: Determine Next Version + id: determine_version + run: | + echo "Current Version: $(./gradlew -q version)" + # Extracting version type (major/minor/patch) from commit message or PR title + if [[ "$GITHUB_REF" == refs/heads/release/* ]]; then + VERSION_TYPE="minor" + elif [[ "$GITHUB_REF" == refs/heads/main ]]; then + VERSION_TYPE="patch" + fi + # Bumping version accordingly + NEW_VERSION=$(./gradlew incrementVersion -Ptype=$VERSION_TYPE -q) + echo "::set-output name=new_version::$NEW_VERSION" + + - name: Commit Version Change + if: ${{ github.ref == 'refs/heads/main' }} + run: | + git config user.name "GitHub Actions" + git config user.email "actions@github.com" + git commit -am "Bump version to ${{ steps.determine_version.outputs.new_version }}" + git push origin main From 471662e50f94ac83d6be42f0949763870950fda3 Mon Sep 17 00:00:00 2001 From: Madhu Chavva Date: Fri, 18 Oct 2024 14:38:54 -0700 Subject: [PATCH 03/29] add feat branches for testing --- .github/workflows/semVer_ci.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/semVer_ci.yml b/.github/workflows/semVer_ci.yml index 304a547..5416ce1 100644 --- a/.github/workflows/semVer_ci.yml +++ b/.github/workflows/semVer_ci.yml @@ -4,6 +4,7 @@ on: push: branches: - main + - feat/auto-release - 'release/*' pull_request: branches: From e06af387b7313d9e6a686451a2cf19ff096accf5 Mon Sep 17 00:00:00 2001 From: Madhu Chavva Date: Fri, 18 Oct 2024 14:42:18 -0700 Subject: [PATCH 04/29] add working directory --- .github/workflows/semVer_ci.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/semVer_ci.yml b/.github/workflows/semVer_ci.yml index 5416ce1..fcebf99 100644 --- a/.github/workflows/semVer_ci.yml +++ b/.github/workflows/semVer_ci.yml @@ -17,12 +17,15 @@ jobs: steps: - name: Checkout Repository uses: actions/checkout@v3 + with: + working-directory: ./jvm-spring-web - name: Set up JDK uses: actions/setup-java@v3 with: distribution: 'temurin' java-version: '17' + working-directory: ./jvm-spring-web - name: Determine Next Version id: determine_version @@ -37,6 +40,7 @@ jobs: # Bumping version accordingly NEW_VERSION=$(./gradlew incrementVersion -Ptype=$VERSION_TYPE -q) echo "::set-output name=new_version::$NEW_VERSION" + working-directory: ./jvm-spring-web - name: Commit Version Change if: ${{ github.ref == 'refs/heads/main' }} @@ -45,3 +49,4 @@ jobs: git config user.email "actions@github.com" git commit -am "Bump version to ${{ steps.determine_version.outputs.new_version }}" git push origin main + working-directory: ./jvm-spring-web From c459b0f10969a8ddfb2b2539035ff63f2ec56560 Mon Sep 17 00:00:00 2001 From: Madhu Chavva Date: Fri, 18 Oct 2024 14:58:46 -0700 Subject: [PATCH 05/29] add version properties --- jvm-spring-web/version.properties | 1 + 1 file changed, 1 insertion(+) create mode 100644 jvm-spring-web/version.properties diff --git a/jvm-spring-web/version.properties b/jvm-spring-web/version.properties new file mode 100644 index 0000000..8a9ecc2 --- /dev/null +++ b/jvm-spring-web/version.properties @@ -0,0 +1 @@ +0.0.1 \ No newline at end of file From 3cd513731d77c2f95e3f75d640d861611474b17c Mon Sep 17 00:00:00 2001 From: Madhu Chavva Date: Fri, 18 Oct 2024 15:20:51 -0700 Subject: [PATCH 06/29] use txt for version --- jvm-spring-web/{version.properties => version.txt} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename jvm-spring-web/{version.properties => version.txt} (100%) diff --git a/jvm-spring-web/version.properties b/jvm-spring-web/version.txt similarity index 100% rename from jvm-spring-web/version.properties rename to jvm-spring-web/version.txt From 1ee5b3d7a051ba3c2cef8836b5e02f0ebab79d55 Mon Sep 17 00:00:00 2001 From: Madhu Chavva Date: Fri, 18 Oct 2024 15:21:05 -0700 Subject: [PATCH 07/29] add versioning tasks --- jvm-spring-web/versioning.gradle | 52 ++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 jvm-spring-web/versioning.gradle diff --git a/jvm-spring-web/versioning.gradle b/jvm-spring-web/versioning.gradle new file mode 100644 index 0000000..f5f69df --- /dev/null +++ b/jvm-spring-web/versioning.gradle @@ -0,0 +1,52 @@ +// versioning.gradle + +def versionFile = file('version.txt') + +// Function to read version from file +def readVersion() { + if (versionFile.exists()) { + return versionFile.text.trim() + } else { + return '0.1.0' // Default version if file does not exist + } +} + +// Function to write version to file +def writeVersion(newVersion) { + versionFile.text = newVersion +} + + + +// Task to print the current version +task printVersion { + doLast { + println version + } +} + +// Task to bump the version +task bumpVersion { + doLast { + def currentVersion = version.split('\\.') + def versionType = project.hasProperty('type') ? project.property('type') : 'patch' + + if (versionType == 'major') { + currentVersion[0] = (currentVersion[0].toInteger() + 1).toString() + currentVersion[1] = '0' + currentVersion[2] = '0' + } else if (versionType == 'minor') { + currentVersion[1] = (currentVersion[1].toInteger() + 1).toString() + currentVersion[2] = '0' + } else if (versionType == 'patch') { + currentVersion[2] = (currentVersion[2].toInteger() + 1).toString() + } else { + throw new GradleException("Unknown version type: $versionType. Use 'major', 'minor', or 'patch'.") + } + + def newVersion = currentVersion.join('.') + writeVersion(newVersion) + println "Version bumped to $newVersion" + } +} + From 492c6f1a3ee4061b9205db41364ecf7391ee8b69 Mon Sep 17 00:00:00 2001 From: Madhu Chavva Date: Fri, 18 Oct 2024 15:22:00 -0700 Subject: [PATCH 08/29] apply versioning tasks --- jvm-spring-web/build.gradle | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/jvm-spring-web/build.gradle b/jvm-spring-web/build.gradle index ff8f487..d3bb811 100644 --- a/jvm-spring-web/build.gradle +++ b/jvm-spring-web/build.gradle @@ -1,3 +1,5 @@ +apply from: 'versioning.gradle' + plugins { id 'org.springframework.boot' version '2.7.4' id 'io.spring.dependency-management' version '1.0.14.RELEASE' @@ -5,7 +7,9 @@ plugins { } group = 'com.example' -version = '0.0.1-SNAPSHOT' +//version = '0.0.1-SNAPSHOT' +// Set the project version +version = readVersion() sourceCompatibility = '17' repositories { From 18d1069165b4e1bbb7e2e23e622db5c3d44e1537 Mon Sep 17 00:00:00 2001 From: Madhu Chavva Date: Fri, 18 Oct 2024 15:23:41 -0700 Subject: [PATCH 09/29] fix build.gradle --- jvm-spring-web/build.gradle | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/jvm-spring-web/build.gradle b/jvm-spring-web/build.gradle index d3bb811..bfb22de 100644 --- a/jvm-spring-web/build.gradle +++ b/jvm-spring-web/build.gradle @@ -1,11 +1,11 @@ -apply from: 'versioning.gradle' - plugins { id 'org.springframework.boot' version '2.7.4' id 'io.spring.dependency-management' version '1.0.14.RELEASE' id 'java' } +apply from: 'versioning.gradle' + group = 'com.example' //version = '0.0.1-SNAPSHOT' // Set the project version From 1193e4ef7983c2f8fcf97c39e2de94ff79f09cfc Mon Sep 17 00:00:00 2001 From: Madhu Chavva Date: Fri, 18 Oct 2024 15:37:14 -0700 Subject: [PATCH 10/29] externalize readVersion function --- jvm-spring-web/versioning.gradle | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/jvm-spring-web/versioning.gradle b/jvm-spring-web/versioning.gradle index f5f69df..5e42442 100644 --- a/jvm-spring-web/versioning.gradle +++ b/jvm-spring-web/versioning.gradle @@ -3,7 +3,8 @@ def versionFile = file('version.txt') // Function to read version from file -def readVersion() { +ext.readVersion = { + //def versionFile = file('version.txt') if (versionFile.exists()) { return versionFile.text.trim() } else { @@ -16,7 +17,7 @@ def writeVersion(newVersion) { versionFile.text = newVersion } - +version = readVersion() // Task to print the current version task printVersion { From fb226777542060d821a0ada69ee351102f890142 Mon Sep 17 00:00:00 2001 From: Madhu Chavva Date: Fri, 18 Oct 2024 15:44:48 -0700 Subject: [PATCH 11/29] use bumpVersion task --- .github/workflows/semVer_ci.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/semVer_ci.yml b/.github/workflows/semVer_ci.yml index fcebf99..57bef47 100644 --- a/.github/workflows/semVer_ci.yml +++ b/.github/workflows/semVer_ci.yml @@ -30,15 +30,15 @@ jobs: - name: Determine Next Version id: determine_version run: | - echo "Current Version: $(./gradlew -q version)" # Extracting version type (major/minor/patch) from commit message or PR title if [[ "$GITHUB_REF" == refs/heads/release/* ]]; then VERSION_TYPE="minor" elif [[ "$GITHUB_REF" == refs/heads/main ]]; then VERSION_TYPE="patch" fi - # Bumping version accordingly - NEW_VERSION=$(./gradlew incrementVersion -Ptype=$VERSION_TYPE -q) + # Bumping version accordingly using a custom script or Gradle task + NEW_VERSION=$(./gradlew -q printVersion) + ./gradlew bumpVersion -Ptype=$VERSION_TYPE echo "::set-output name=new_version::$NEW_VERSION" working-directory: ./jvm-spring-web From 40fa69869849d563f94fcf0ab111e1571536faab Mon Sep 17 00:00:00 2001 From: Madhu Chavva Date: Fri, 18 Oct 2024 19:07:47 -0700 Subject: [PATCH 12/29] fix major version and generate summary --- .github/workflows/semVer_ci.yml | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/.github/workflows/semVer_ci.yml b/.github/workflows/semVer_ci.yml index 57bef47..397f7b5 100644 --- a/.github/workflows/semVer_ci.yml +++ b/.github/workflows/semVer_ci.yml @@ -33,9 +33,19 @@ jobs: # Extracting version type (major/minor/patch) from commit message or PR title if [[ "$GITHUB_REF" == refs/heads/release/* ]]; then VERSION_TYPE="minor" - elif [[ "$GITHUB_REF" == refs/heads/main ]]; then + # elif [[ "$GITHUB_REF" == refs/heads/main ]]; then + # VERSION_TYPE="patch" + else VERSION_TYPE="patch" fi + + # Determine if a major version bump is needed (using a ceiling of 100 for minor version) + CURRENT_VERSION=$(./gradlew -q printVersion) + MINOR_VERSION=$(echo $CURRENT_VERSION | awk -F. '{print $2}') + if [[ "$MINOR_VERSION" -ge 100 ]]; then + VERSION_TYPE="major" + fi + # Bumping version accordingly using a custom script or Gradle task NEW_VERSION=$(./gradlew -q printVersion) ./gradlew bumpVersion -Ptype=$VERSION_TYPE @@ -50,3 +60,22 @@ jobs: git commit -am "Bump version to ${{ steps.determine_version.outputs.new_version }}" git push origin main working-directory: ./jvm-spring-web + + - name: Generate Summary of Changes + id: generate_summary + run: | + SUMMARY_FILE="change_summary.md" + git log -1 --pretty=format:"%h - %s (%an)" >> $SUMMARY_FILE + echo "Summary of changes updated in $SUMMARY_FILE" + cat $SUMMARY_FILE + working-directory: ./jvm-spring-web + + - name: Create Release Notes for Major Version + if: ${{ steps.determine_version.outputs.new_version }} =~ '^\d+\.0\.0$' + run: | + RELEASE_NOTES_FILE="release_notes.md" + RELEASE_NOTES="# Release Notes for version ${{ steps.determine_version.outputs.new_version }}\n\n$(cat change_summary.md)" + echo -e "$RELEASE_NOTES" > $RELEASE_NOTES_FILE + echo "Release notes created in $RELEASE_NOTES_FILE" + cat $RELEASE_NOTES_FILE + working-directory: ./jvm-spring-web From 23dec1595efdba3ef12f18714bf8d9cbd7b05a84 Mon Sep 17 00:00:00 2001 From: Madhu Chavva Date: Fri, 18 Oct 2024 19:13:25 -0700 Subject: [PATCH 13/29] fix versionFile scope --- jvm-spring-web/versioning.gradle | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/jvm-spring-web/versioning.gradle b/jvm-spring-web/versioning.gradle index 5e42442..e8c797f 100644 --- a/jvm-spring-web/versioning.gradle +++ b/jvm-spring-web/versioning.gradle @@ -1,10 +1,8 @@ // versioning.gradle -def versionFile = file('version.txt') - // Function to read version from file ext.readVersion = { - //def versionFile = file('version.txt') + def versionFile = file('version.txt') if (versionFile.exists()) { return versionFile.text.trim() } else { @@ -14,6 +12,7 @@ ext.readVersion = { // Function to write version to file def writeVersion(newVersion) { + def versionFile = file('version.txt') versionFile.text = newVersion } From fa849ef32a287f96146376164ec4e342c0afd869 Mon Sep 17 00:00:00 2001 From: Madhu Chavva Date: Thu, 24 Oct 2024 10:57:44 -0700 Subject: [PATCH 14/29] use release action and commit changes --- .github/workflows/semVer_ci.yml | 63 +++++++++++++++++++-------------- 1 file changed, 36 insertions(+), 27 deletions(-) diff --git a/.github/workflows/semVer_ci.yml b/.github/workflows/semVer_ci.yml index 397f7b5..b03ce4c 100644 --- a/.github/workflows/semVer_ci.yml +++ b/.github/workflows/semVer_ci.yml @@ -1,5 +1,8 @@ name: Semantic Versioning and Build +env: + WORKING_DIR: ./jvm-spring-web + on: push: branches: @@ -18,25 +21,28 @@ jobs: - name: Checkout Repository uses: actions/checkout@v3 with: - working-directory: ./jvm-spring-web + working-directory: ${{ env.WORKING_DIR }} + + - name: Configure Git + run: | + git config user.name "GitHub Actions" + git config user.email "actions@github.com" + working-directory: ${{ env.WORKING_DIR }} - name: Set up JDK uses: actions/setup-java@v3 with: distribution: 'temurin' java-version: '17' - working-directory: ./jvm-spring-web + working-directory: ${{ env.WORKING_DIR }} - name: Determine Next Version id: determine_version run: | # Extracting version type (major/minor/patch) from commit message or PR title + VERSION_TYPE="patch" if [[ "$GITHUB_REF" == refs/heads/release/* ]]; then VERSION_TYPE="minor" - # elif [[ "$GITHUB_REF" == refs/heads/main ]]; then - # VERSION_TYPE="patch" - else - VERSION_TYPE="patch" fi # Determine if a major version bump is needed (using a ceiling of 100 for minor version) @@ -50,32 +56,35 @@ jobs: NEW_VERSION=$(./gradlew -q printVersion) ./gradlew bumpVersion -Ptype=$VERSION_TYPE echo "::set-output name=new_version::$NEW_VERSION" - working-directory: ./jvm-spring-web + working-directory: ${{ env.WORKING_DIR }} - - name: Commit Version Change - if: ${{ github.ref == 'refs/heads/main' }} - run: | - git config user.name "GitHub Actions" - git config user.email "actions@github.com" - git commit -am "Bump version to ${{ steps.determine_version.outputs.new_version }}" - git push origin main - working-directory: ./jvm-spring-web - - - name: Generate Summary of Changes - id: generate_summary + - name: Generate and Commit Summary of Changes + if: ${{ github.ref == 'refs/heads/main' || github.ref == 'refs/heads/feat/auto-release'}} run: | SUMMARY_FILE="change_summary.md" git log -1 --pretty=format:"%h - %s (%an)" >> $SUMMARY_FILE echo "Summary of changes updated in $SUMMARY_FILE" cat $SUMMARY_FILE - working-directory: ./jvm-spring-web + git add $SUMMARY_FILE + git commit -m "Update change summary for version ${{ steps.determine_version.outputs.new_version }}" + git push origin HEAD + working-directory: ${{ env.WORKING_DIR }} - - name: Create Release Notes for Major Version - if: ${{ steps.determine_version.outputs.new_version }} =~ '^\d+\.0\.0$' + - name: Commit Version Changes for Feature Branches + if: ${{ github.ref != 'refs/heads/main' && github.ref != 'refs/heads/release/*' }} run: | - RELEASE_NOTES_FILE="release_notes.md" - RELEASE_NOTES="# Release Notes for version ${{ steps.determine_version.outputs.new_version }}\n\n$(cat change_summary.md)" - echo -e "$RELEASE_NOTES" > $RELEASE_NOTES_FILE - echo "Release notes created in $RELEASE_NOTES_FILE" - cat $RELEASE_NOTES_FILE - working-directory: ./jvm-spring-web + git add version.txt + git commit -m "Bump version to ${{ steps.determine_version.outputs.new_version }}" + git push origin HEAD + working-directory: ${{ env.WORKING_DIR }} + + - name: Create GitHub Release for Major Version + if: ${{ github.ref == 'refs/heads/release/*'}} + uses: softprops/action-gh-release@v1 + with: + tag_name: ${{ steps.determine_version.outputs.new_version }} + name: Release ${{ steps.determine_version.outputs.new_version }} + body: | + $(cat change_summary.md) + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} From 5e41e38d815c513544bec5d1cd56eb2999148d52 Mon Sep 17 00:00:00 2001 From: GitHub Actions Date: Thu, 24 Oct 2024 17:58:17 +0000 Subject: [PATCH 15/29] Update change summary for version 0.0.1 --- jvm-spring-web/change_summary.md | 1 + 1 file changed, 1 insertion(+) create mode 100644 jvm-spring-web/change_summary.md diff --git a/jvm-spring-web/change_summary.md b/jvm-spring-web/change_summary.md new file mode 100644 index 0000000..3deb4a2 --- /dev/null +++ b/jvm-spring-web/change_summary.md @@ -0,0 +1 @@ +fa849ef - use release action and commit changes (Madhu Chavva) \ No newline at end of file From 85e037384c712ce4c0cb9136f0a9c63a1cdcd113 Mon Sep 17 00:00:00 2001 From: GitHub Actions Date: Thu, 24 Oct 2024 17:58:17 +0000 Subject: [PATCH 16/29] Bump version to 0.0.1 --- jvm-spring-web/version.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jvm-spring-web/version.txt b/jvm-spring-web/version.txt index 8a9ecc2..7bcd0e3 100644 --- a/jvm-spring-web/version.txt +++ b/jvm-spring-web/version.txt @@ -1 +1 @@ -0.0.1 \ No newline at end of file +0.0.2 \ No newline at end of file From f2a77b8a92fdd2c3e44cdb60d000c6f81e6988c3 Mon Sep 17 00:00:00 2001 From: Madhu Chavva Date: Thu, 24 Oct 2024 12:27:24 -0700 Subject: [PATCH 17/29] commit version for all branches --- .github/workflows/semVer_ci.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/semVer_ci.yml b/.github/workflows/semVer_ci.yml index b03ce4c..f6f3d87 100644 --- a/.github/workflows/semVer_ci.yml +++ b/.github/workflows/semVer_ci.yml @@ -59,7 +59,8 @@ jobs: working-directory: ${{ env.WORKING_DIR }} - name: Generate and Commit Summary of Changes - if: ${{ github.ref == 'refs/heads/main' || github.ref == 'refs/heads/feat/auto-release'}} + # Is this task, even necessary? + if: ${{ github.ref == 'refs/heads/feat/auto-release'}} run: | SUMMARY_FILE="change_summary.md" git log -1 --pretty=format:"%h - %s (%an)" >> $SUMMARY_FILE @@ -71,14 +72,13 @@ jobs: working-directory: ${{ env.WORKING_DIR }} - name: Commit Version Changes for Feature Branches - if: ${{ github.ref != 'refs/heads/main' && github.ref != 'refs/heads/release/*' }} run: | git add version.txt git commit -m "Bump version to ${{ steps.determine_version.outputs.new_version }}" git push origin HEAD working-directory: ${{ env.WORKING_DIR }} - - name: Create GitHub Release for Major Version + - name: Create GitHub Release for Release Branches if: ${{ github.ref == 'refs/heads/release/*'}} uses: softprops/action-gh-release@v1 with: From a6714cdf95cba29dd53f792a23901a6bf3b36130 Mon Sep 17 00:00:00 2001 From: Madhu Chavva Date: Thu, 24 Oct 2024 12:27:54 -0700 Subject: [PATCH 18/29] add release workflow --- .github/workflows/release.yml | 82 +++++++++++++++++++++++++++++++++++ 1 file changed, 82 insertions(+) create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..7bc2b16 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,82 @@ +name: Automate Release Creation + +env: + WORKING_DIR: ./jvm-spring-web + +on: + workflow_dispatch: + inputs: + version_type: + description: 'Type of version bump (major/minor/patch)' + required: false + +jobs: + determine_next_version: + runs-on: ubuntu-latest + + steps: + - name: Checkout Repository + uses: actions/checkout@v3 + with: + ref: main + + - name: Set up JDK + uses: actions/setup-java@v3 + with: + distribution: 'temurin' + java-version: '17' + + - name: Determine Next Version + id: determine_version + run: | + # Use the provided version type input for the bump, default to 'patch' if not provided + VERSION_TYPE="${{ github.event.inputs.version_type || 'patch' }}" + + # Determine the next version + CURRENT_VERSION=$(./gradlew -q printVersion) + ./gradlew bumpVersion -Ptype=$VERSION_TYPE + NEW_VERSION=$(./gradlew -q printVersion) + echo "::set-output name=new_version::$NEW_VERSION" + working-directory: ${{ env.WORKING_DIR }} + + create_release_branch: + runs-on: ubuntu-latest + needs: determine_next_version + + steps: + - name: Checkout Repository + uses: actions/checkout@v3 + with: + ref: main + + - name: Create and Push Release Branch + run: | + RELEASE_BRANCH="release/v${{ needs.determine_next_version.outputs.new_version }}" + git checkout -b $RELEASE_BRANCH + git push origin $RELEASE_BRANCH + + build_and_release: + runs-on: ubuntu-latest + needs: create_release_branch + + steps: + - name: Checkout Repository + uses: actions/checkout@v3 + with: + ref: ${{ needs.create_release_branch.outputs.RELEASE_BRANCH }} + + - name: Set up JDK + uses: actions/setup-java@v3 + with: + distribution: 'temurin' + java-version: '17' + + - name: Create GitHub Release + uses: softprops/action-gh-release@v1 + with: + tag_name: ${{ needs.determine_next_version.outputs.new_version }} + name: Release ${{ needs.determine_next_version.outputs.new_version }} + body: | + Automated release for version ${{ needs.determine_next_version.outputs.new_version }} + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} From 7af2b9aa042ad1ad3a8d6e6793d63e145d705501 Mon Sep 17 00:00:00 2001 From: GitHub Actions Date: Thu, 24 Oct 2024 19:39:15 +0000 Subject: [PATCH 19/29] Update change summary for version 0.0.2 --- jvm-spring-web/change_summary.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jvm-spring-web/change_summary.md b/jvm-spring-web/change_summary.md index 3deb4a2..af531d8 100644 --- a/jvm-spring-web/change_summary.md +++ b/jvm-spring-web/change_summary.md @@ -1 +1 @@ -fa849ef - use release action and commit changes (Madhu Chavva) \ No newline at end of file +fa849ef - use release action and commit changes (Madhu Chavva)a6714cd - add release workflow (Madhu Chavva) \ No newline at end of file From d9334aa34ef103b8544824caccb06dca3d003a02 Mon Sep 17 00:00:00 2001 From: GitHub Actions Date: Thu, 24 Oct 2024 19:39:16 +0000 Subject: [PATCH 20/29] Bump version to 0.0.2 --- jvm-spring-web/version.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jvm-spring-web/version.txt b/jvm-spring-web/version.txt index 7bcd0e3..6812f81 100644 --- a/jvm-spring-web/version.txt +++ b/jvm-spring-web/version.txt @@ -1 +1 @@ -0.0.2 \ No newline at end of file +0.0.3 \ No newline at end of file From 733cecc966067d62fe18bdd9beba754806d67ccf Mon Sep 17 00:00:00 2001 From: Madhu Chavva Date: Thu, 24 Oct 2024 12:49:50 -0700 Subject: [PATCH 21/29] read latest version for commit --- .github/workflows/semVer_ci.yml | 2 +- jvm-spring-web/versioning.gradle | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/semVer_ci.yml b/.github/workflows/semVer_ci.yml index f6f3d87..8071d49 100644 --- a/.github/workflows/semVer_ci.yml +++ b/.github/workflows/semVer_ci.yml @@ -53,8 +53,8 @@ jobs: fi # Bumping version accordingly using a custom script or Gradle task - NEW_VERSION=$(./gradlew -q printVersion) ./gradlew bumpVersion -Ptype=$VERSION_TYPE + NEW_VERSION=$(./gradlew -q printVersion) echo "::set-output name=new_version::$NEW_VERSION" working-directory: ${{ env.WORKING_DIR }} diff --git a/jvm-spring-web/versioning.gradle b/jvm-spring-web/versioning.gradle index e8c797f..ac196f6 100644 --- a/jvm-spring-web/versioning.gradle +++ b/jvm-spring-web/versioning.gradle @@ -46,7 +46,7 @@ task bumpVersion { def newVersion = currentVersion.join('.') writeVersion(newVersion) - println "Version bumped to $newVersion" + println "Version bumped to $newVersion from $version" } } From 9ec9580e5c36c033641c15ac6cbd004928f3ef58 Mon Sep 17 00:00:00 2001 From: GitHub Actions Date: Thu, 24 Oct 2024 19:50:29 +0000 Subject: [PATCH 22/29] Update change summary for version 0.0.4 --- jvm-spring-web/change_summary.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jvm-spring-web/change_summary.md b/jvm-spring-web/change_summary.md index af531d8..68b4db8 100644 --- a/jvm-spring-web/change_summary.md +++ b/jvm-spring-web/change_summary.md @@ -1 +1 @@ -fa849ef - use release action and commit changes (Madhu Chavva)a6714cd - add release workflow (Madhu Chavva) \ No newline at end of file +fa849ef - use release action and commit changes (Madhu Chavva)a6714cd - add release workflow (Madhu Chavva)733cecc - read latest version for commit (Madhu Chavva) \ No newline at end of file From f7298e1608983d825d2adef5ba985ca5bcda4a07 Mon Sep 17 00:00:00 2001 From: GitHub Actions Date: Thu, 24 Oct 2024 19:50:30 +0000 Subject: [PATCH 23/29] Bump version to 0.0.4 --- jvm-spring-web/version.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jvm-spring-web/version.txt b/jvm-spring-web/version.txt index 6812f81..05b19b1 100644 --- a/jvm-spring-web/version.txt +++ b/jvm-spring-web/version.txt @@ -1 +1 @@ -0.0.3 \ No newline at end of file +0.0.4 \ No newline at end of file From bdc92644feca08a6cfc0cb046392d5297f63f9ef Mon Sep 17 00:00:00 2001 From: Madhu Chavva Date: Thu, 24 Oct 2024 15:55:11 -0700 Subject: [PATCH 24/29] fix set_output warning --- .github/workflows/semVer_ci.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/semVer_ci.yml b/.github/workflows/semVer_ci.yml index 8071d49..01e190d 100644 --- a/.github/workflows/semVer_ci.yml +++ b/.github/workflows/semVer_ci.yml @@ -55,7 +55,7 @@ jobs: # Bumping version accordingly using a custom script or Gradle task ./gradlew bumpVersion -Ptype=$VERSION_TYPE NEW_VERSION=$(./gradlew -q printVersion) - echo "::set-output name=new_version::$NEW_VERSION" + echo "new_version=$NEW_VERSION" >> $GITHUB_ENV working-directory: ${{ env.WORKING_DIR }} - name: Generate and Commit Summary of Changes @@ -67,14 +67,14 @@ jobs: echo "Summary of changes updated in $SUMMARY_FILE" cat $SUMMARY_FILE git add $SUMMARY_FILE - git commit -m "Update change summary for version ${{ steps.determine_version.outputs.new_version }}" + git commit -m "Update change summary for version ${{ env.new_version }}" git push origin HEAD working-directory: ${{ env.WORKING_DIR }} - name: Commit Version Changes for Feature Branches run: | git add version.txt - git commit -m "Bump version to ${{ steps.determine_version.outputs.new_version }}" + git commit -m "Bump version to ${{ env.new_version }}" git push origin HEAD working-directory: ${{ env.WORKING_DIR }} @@ -82,8 +82,8 @@ jobs: if: ${{ github.ref == 'refs/heads/release/*'}} uses: softprops/action-gh-release@v1 with: - tag_name: ${{ steps.determine_version.outputs.new_version }} - name: Release ${{ steps.determine_version.outputs.new_version }} + tag_name: ${{ env.new_version }} + name: Release ${{ env.new_version }} body: | $(cat change_summary.md) env: From f756202e93d3ed896ea02d9143728e20f592c32b Mon Sep 17 00:00:00 2001 From: GitHub Actions Date: Thu, 24 Oct 2024 22:55:40 +0000 Subject: [PATCH 25/29] Update change summary for version 0.0.5 --- jvm-spring-web/change_summary.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jvm-spring-web/change_summary.md b/jvm-spring-web/change_summary.md index 68b4db8..b2b4f03 100644 --- a/jvm-spring-web/change_summary.md +++ b/jvm-spring-web/change_summary.md @@ -1 +1 @@ -fa849ef - use release action and commit changes (Madhu Chavva)a6714cd - add release workflow (Madhu Chavva)733cecc - read latest version for commit (Madhu Chavva) \ No newline at end of file +fa849ef - use release action and commit changes (Madhu Chavva)a6714cd - add release workflow (Madhu Chavva)733cecc - read latest version for commit (Madhu Chavva)bdc9264 - fix set_output warning (Madhu Chavva) \ No newline at end of file From 95a0b4518fd317addfdc1fb200df188135994e77 Mon Sep 17 00:00:00 2001 From: GitHub Actions Date: Thu, 24 Oct 2024 22:55:40 +0000 Subject: [PATCH 26/29] Bump version to 0.0.5 --- jvm-spring-web/version.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jvm-spring-web/version.txt b/jvm-spring-web/version.txt index 05b19b1..fa3de58 100644 --- a/jvm-spring-web/version.txt +++ b/jvm-spring-web/version.txt @@ -1 +1 @@ -0.0.4 \ No newline at end of file +0.0.5 \ No newline at end of file From 5c2120a3822976619141ee14fbf214e72816b18b Mon Sep 17 00:00:00 2001 From: Madhu Chavva Date: Thu, 24 Oct 2024 16:23:36 -0700 Subject: [PATCH 27/29] use minor version ceiling --- .github/workflows/release.yml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 7bc2b16..44b1e13 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -32,8 +32,14 @@ jobs: # Use the provided version type input for the bump, default to 'patch' if not provided VERSION_TYPE="${{ github.event.inputs.version_type || 'patch' }}" - # Determine the next version + # Determine if a major version bump is needed (using a ceiling of 100 for minor version) CURRENT_VERSION=$(./gradlew -q printVersion) + MINOR_VERSION=$(echo $CURRENT_VERSION | awk -F. '{print $2}') + if [[ "$MINOR_VERSION" -ge 100 ]]; then + VERSION_TYPE="major" + fi + + # Determine the next version ./gradlew bumpVersion -Ptype=$VERSION_TYPE NEW_VERSION=$(./gradlew -q printVersion) echo "::set-output name=new_version::$NEW_VERSION" From 140f3ec479bf7074a276ff3f31d2dcdf88e940e2 Mon Sep 17 00:00:00 2001 From: GitHub Actions Date: Thu, 24 Oct 2024 23:24:04 +0000 Subject: [PATCH 28/29] Update change summary for version 0.0.6 --- jvm-spring-web/change_summary.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jvm-spring-web/change_summary.md b/jvm-spring-web/change_summary.md index b2b4f03..80ab06b 100644 --- a/jvm-spring-web/change_summary.md +++ b/jvm-spring-web/change_summary.md @@ -1 +1 @@ -fa849ef - use release action and commit changes (Madhu Chavva)a6714cd - add release workflow (Madhu Chavva)733cecc - read latest version for commit (Madhu Chavva)bdc9264 - fix set_output warning (Madhu Chavva) \ No newline at end of file +fa849ef - use release action and commit changes (Madhu Chavva)a6714cd - add release workflow (Madhu Chavva)733cecc - read latest version for commit (Madhu Chavva)bdc9264 - fix set_output warning (Madhu Chavva)5c2120a - use minor version ceiling (Madhu Chavva) \ No newline at end of file From 78775d75adef89308df34166898cba1b3646b923 Mon Sep 17 00:00:00 2001 From: GitHub Actions Date: Thu, 24 Oct 2024 23:24:04 +0000 Subject: [PATCH 29/29] Bump version to 0.0.6 --- jvm-spring-web/version.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jvm-spring-web/version.txt b/jvm-spring-web/version.txt index fa3de58..99d85ec 100644 --- a/jvm-spring-web/version.txt +++ b/jvm-spring-web/version.txt @@ -1 +1 @@ -0.0.5 \ No newline at end of file +0.0.6 \ No newline at end of file