Fix episodes #13
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Update Minor Version on PR | |
on: | |
pull_request: | |
types: | |
- opened | |
jobs: | |
minor-version-bump: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Set Git User Identity | |
env: | |
GH_EMAIL: ${{ secrets.GH_EMAIL }} | |
GH_USER: ${{ secrets.GH_USER }} | |
run: | | |
git config --global user.email "$GH_EMAIL" | |
git config --global user.name "$GH_USER" | |
- name: Checkout Repository | |
uses: actions/checkout@v3 | |
- name: Check if Minor Version Needs Bump | |
id: check_minor_bump | |
run: | | |
PR_NUMBER="${{ github.event.pull_request.number }}" | |
BRANCH_NAME="${{ github.event.pull_request.head.ref }}" | |
MINOR_BUMP_FLAG="bump_minor_${BRANCH_NAME}" | |
if [ -z "$(git show-ref --heads "$MINOR_BUMP_FLAG")" ]; then | |
git checkout -b $BRANCH_NAME | |
git pull --rebase origin $BRANCH_NAME | |
# Parse the current version | |
CURRENT_VERSION=$(cat VERSION) | |
MAJOR=$(echo $CURRENT_VERSION | cut -d. -f1) | |
MINOR=$(echo $CURRENT_VERSION | cut -d. -f2) | |
PATCH=$(echo $CURRENT_VERSION | cut -d. -f3) | |
# Calculate the new version | |
NEW_MINOR=$((MINOR + 1)) | |
NEW_VERSION="$MAJOR.$NEW_MINOR.0" | |
# Update the version file | |
echo "$NEW_VERSION" > VERSION | |
echo "Bumped version to $NEW_VERSION" | |
# Commit and push the changes | |
git commit -am "Bump version to $NEW_VERSION" | |
git push origin $BRANCH_NAME | |
# Set the new version as an output | |
echo "::set-output name=new_version::$NEW_VERSION" | |
else | |
echo "We already bumped minor for this branch" | |
fi |