From a6714cdf95cba29dd53f792a23901a6bf3b36130 Mon Sep 17 00:00:00 2001 From: Madhu Chavva Date: Thu, 24 Oct 2024 12:27:54 -0700 Subject: [PATCH] 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 }}