Skip to content

Commit

Permalink
add release workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
madhuchavva committed Oct 24, 2024
1 parent f2a77b8 commit a6714cd
Showing 1 changed file with 82 additions and 0 deletions.
82 changes: 82 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -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 }}

0 comments on commit a6714cd

Please sign in to comment.