Skip to content

Commit

Permalink
Updated ci workflow to check that PROJECT_VERSION has been incremented
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewjong committed Dec 19, 2024
1 parent a99f0da commit 89ae41f
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 96 deletions.
96 changes: 0 additions & 96 deletions .github/workflows/dockerfile_version_check.yaml

This file was deleted.

42 changes: 42 additions & 0 deletions .github/workflows/main_version_increment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: Check Project Version Increment

on:
pull_request:
branches: [main]

jobs:
check_version:
runs-on: ubuntu-latest

steps:
- name: Checkout Code
uses: actions/checkout@v2

- name: Get Current Version from PR
run: |
PR_VERSION=$(grep 'PROJECT_VERSION=' .env | cut -d'=' -f2 | tr -d '"')
echo "PR_VERSION=$PR_VERSION" >> $GITHUB_ENV
- name: Get Previous Version from Main
run: |
git fetch origin main
PREV_VERSION=$(git show origin/main:.env | grep 'PROJECT_VERSION=' | cut -d'=' -f2 | tr -d '"')
echo "PREV_VERSION=$PREV_VERSION" >> $GITHUB_ENV
- name: Validate Version Increment
run: |
compare_versions() {
IFS='.' read -r -a CUR <<< "$PR_VERSION"
IFS='.' read -r -a PREV <<< "$PREV_VERSION"
if (( CUR[0] > PREV[0] )); then exit 0; fi
if (( CUR[0] == PREV[0] && CUR[1] > PREV[1] )); then exit 0; fi
if (( CUR[0] == PREV[0] && CUR[1] == PREV[1] && CUR[2] > PREV[2] )); then exit 0; fi
echo "ERROR: PROJECT_VERSION must be incremented semantically. Current: $PR_VERSION, Previous: $PREV_VERSION"
exit 1
}
compare_versions
- name: Report Success
run: |
echo "PROJECT_VERSION successfully incremented: $PR_VERSION"

0 comments on commit 89ae41f

Please sign in to comment.