Skip to content

Commit

Permalink
chore: update release core actions (#513)
Browse files Browse the repository at this point in the history
  • Loading branch information
mohnoor94 authored Apr 15, 2024
1 parent fe0ce1a commit 7c2ca58
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 19 deletions.
15 changes: 8 additions & 7 deletions .github/workflows/core-release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,15 @@ on:
description: 'Upgrade Type. Choose none to skip upgrade'
type: choice
options:
- "major"
- "minor"
- "patch"
- "none"
- 'major'
- 'minor'
- 'patch'
- 'none'

jobs:
upgrade:
uses: ./.github/workflows/upgrade.yaml
uses: ./.github/workflows/core-upgrade.yaml
with:
upgrade_version: ${{ github.event.inputs.upgrade_type != 'none' }}
upgrade_type: ${{ github.event.inputs.upgrade_type }}
secrets:
GH_PERSONAL_ACCESS_TOKEN: ${{ secrets.GH_PERSONAL_ACCESS_TOKEN }}
Expand Down Expand Up @@ -79,12 +78,14 @@ jobs:
echo "Releasing to production"
exit 1 # Debugging
mvn deploy --settings $GITHUB_WORKSPACE/settings.xml -B -U -P release
echo ">> SonaType release URL: https://repo1.maven.org/maven2/com/expediagroup/sdk-core/"
else
VERSION=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)
SNAPSHOT_VERSION="${VERSION%-SNAPSHOT}-SNAPSHOT"
echo "Releasing as snapshot"
mvn versions:set -DnewVersion=$SNAPSHOT_VERSION
mvn deploy --settings $GITHUB_WORKSPACE/settings.xml -B -U -P release
echo ">> SonaType snapshots URL: https://oss.sonatype.org/content/repositories/snapshots/com/expediagroup/sdk-core/"
fi
echo "version=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout) released"
echo ">> v$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout) released"
echo "version=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)" >> $GITHUB_OUTPUT
26 changes: 14 additions & 12 deletions .github/workflows/core-upgrade.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,11 @@ name: Upgrade SDK Core
on:
workflow_call:
inputs:
upgrade_version:
description: 'Upgrade?'
required: true
type: boolean
upgrade_type:
description: 'Upgrade Type. Options: major, minor, patch'
description: 'Upgrade Type. Options: major, minor, patch, none'
required: true
type: string
default: 'patch'
default: 'none'
secrets:
GH_PERSONAL_ACCESS_TOKEN:
description: 'GitHub Personal Access Token'
Expand All @@ -26,9 +22,9 @@ jobs:
runs-on: ubuntu-latest

steps:
- name: Check confirmation
- name: Confirm Upgrade
run: |
if ! ${{ github.event.inputs.upgrade_version }}; then
if [ "${{ github.event.inputs.upgrade_type }}" == "none" ]; then
echo "Upgrade not requested. Skipping."
exit 1
else
Expand All @@ -43,6 +39,7 @@ jobs:
java-version: '21'

- name: Increment version
working-directory: core
id: increment_version
run: |
version=$(mvn -q \
Expand All @@ -55,18 +52,22 @@ jobs:
MINOR=${VERSION_PARTS[1]}
PATCH=${VERSION_PARTS[2]}
echo "Upgrade type: ${{ github.event.inputs.upgrade_type }}"
echo "Major: $MAJOR"
echo "Minor: $MINOR"
echo "Patch: $PATCH"
case "${{ github.event.inputs.upgrade_type }}" in
"major")
((MAJOR++))
MAJOR=$(expr $MAJOR + 1)
MINOR=0
PATCH=0
;;
"minor")
((MINOR++))
MINOR=$(expr $MINOR + 1)
PATCH=0
;;
"patch")
((PATCH++))
PATCH=$(expr $PATCH + 1)
;;
*)
echo "Invalid upgrade type. Must be one of: major, minor, patch."
Expand All @@ -75,6 +76,7 @@ jobs:
esac
NEW_VERSION="$MAJOR.$MINOR.$PATCH"
echo "New version: $NEW_VERSION"
mvn versions:set -DnewVersion=$NEW_VERSION
echo "version=$NEW_VERSION" >> $GITHUB_ENV
Expand All @@ -92,7 +94,7 @@ jobs:
name: branch-name
path: branch_name.txt

- name: Create Pull Request
- name: Publish Updated Version PR
uses: peter-evans/create-pull-request@v6
with:
token: ${{ secrets.GH_PERSONAL_ACCESS_TOKEN }}
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,6 @@ buildNumber.properties
.mvn/timing.properties
# https://github.com/takari/maven-wrapper#usage-without-binary-jar
.mvn/wrapper/maven-wrapper.jar


branch_name.txt

0 comments on commit 7c2ca58

Please sign in to comment.