Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
90dc041
Test Change
madhuchavva Oct 17, 2024
5cd499b
add semantic versioning for builds
madhuchavva Oct 18, 2024
471662e
add feat branches for testing
madhuchavva Oct 18, 2024
e06af38
add working directory
madhuchavva Oct 18, 2024
c459b0f
add version properties
madhuchavva Oct 18, 2024
3cd5137
use txt for version
madhuchavva Oct 18, 2024
1ee5b3d
add versioning tasks
madhuchavva Oct 18, 2024
492c6f1
apply versioning tasks
madhuchavva Oct 18, 2024
18d1069
fix build.gradle
madhuchavva Oct 18, 2024
1193e4e
externalize readVersion function
madhuchavva Oct 18, 2024
fb22677
use bumpVersion task
madhuchavva Oct 18, 2024
40fa698
fix major version and generate summary
madhuchavva Oct 19, 2024
23dec15
fix versionFile scope
madhuchavva Oct 19, 2024
fa849ef
use release action and commit changes
madhuchavva Oct 24, 2024
5e41e38
Update change summary for version 0.0.1
actions-user Oct 24, 2024
85e0373
Bump version to 0.0.1
actions-user Oct 24, 2024
f2a77b8
commit version for all branches
madhuchavva Oct 24, 2024
a6714cd
add release workflow
madhuchavva Oct 24, 2024
7af2b9a
Update change summary for version 0.0.2
actions-user Oct 24, 2024
d9334aa
Bump version to 0.0.2
actions-user Oct 24, 2024
733cecc
read latest version for commit
madhuchavva Oct 24, 2024
9ec9580
Update change summary for version 0.0.4
actions-user Oct 24, 2024
f7298e1
Bump version to 0.0.4
actions-user Oct 24, 2024
bdc9264
fix set_output warning
madhuchavva Oct 24, 2024
f756202
Update change summary for version 0.0.5
actions-user Oct 24, 2024
95a0b45
Bump version to 0.0.5
actions-user Oct 24, 2024
5c2120a
use minor version ceiling
madhuchavva Oct 24, 2024
140f3ec
Update change summary for version 0.0.6
actions-user Oct 24, 2024
78775d7
Bump version to 0.0.6
actions-user Oct 24, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
88 changes: 88 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
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 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"
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 }}
90 changes: 90 additions & 0 deletions .github/workflows/semVer_ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
name: Semantic Versioning and Build

env:
WORKING_DIR: ./jvm-spring-web

on:
push:
branches:
- main
- feat/auto-release
- 'release/*'
pull_request:
branches:
- main

jobs:
versioning:
runs-on: ubuntu-latest

steps:
- name: Checkout Repository
uses: actions/checkout@v3
with:
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: ${{ 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"
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
./gradlew bumpVersion -Ptype=$VERSION_TYPE
NEW_VERSION=$(./gradlew -q printVersion)
echo "new_version=$NEW_VERSION" >> $GITHUB_ENV
working-directory: ${{ env.WORKING_DIR }}

- name: Generate and Commit Summary of Changes
# 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
echo "Summary of changes updated in $SUMMARY_FILE"
cat $SUMMARY_FILE
git add $SUMMARY_FILE
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 ${{ env.new_version }}"
git push origin HEAD
working-directory: ${{ env.WORKING_DIR }}

- name: Create GitHub Release for Release Branches
if: ${{ github.ref == 'refs/heads/release/*'}}
uses: softprops/action-gh-release@v1
with:
tag_name: ${{ env.new_version }}
name: Release ${{ env.new_version }}
body: |
$(cat change_summary.md)
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
6 changes: 5 additions & 1 deletion jvm-spring-web/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,12 @@ plugins {
id 'java'
}

apply from: 'versioning.gradle'

group = 'com.example'
version = '0.0.1-SNAPSHOT'
//version = '0.0.1-SNAPSHOT'
// Set the project version
version = readVersion()
sourceCompatibility = '17'

repositories {
Expand Down
1 change: 1 addition & 0 deletions jvm-spring-web/change_summary.md
Original file line number Diff line number Diff line change
@@ -0,0 +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)5c2120a - use minor version ceiling (Madhu Chavva)
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public void onRefresh(String featuresJson) {
}

void handleError(FeatureFetchException e) {
e.printStackTrace();
//e.printStackTrace();

switch (e.getErrorCode()) {
case NO_RESPONSE_ERROR -> {
Expand All @@ -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);
}
}
}
1 change: 1 addition & 0 deletions jvm-spring-web/version.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0.0.6
52 changes: 52 additions & 0 deletions jvm-spring-web/versioning.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
// versioning.gradle

// Function to read version from file
ext.readVersion = {
def versionFile = file('version.txt')
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) {
def versionFile = file('version.txt')
versionFile.text = newVersion
}

version = readVersion()

// 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 $version"
}
}