-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #348 from fboundy/patch
Bug fix
- Loading branch information
Showing
5 changed files
with
99 additions
and
111 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,93 +6,9 @@ on: | |
- main # Trigger on pushes to main (e.g., after a PR is merged) | ||
|
||
jobs: | ||
validate-version: | ||
name: Validate Version | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout Repository | ||
uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: Fetch main branch into a temporary branch | ||
run: | | ||
git fetch origin main | ||
git checkout -b temp-main origin/main | ||
- name: Get VERSION from patch branch | ||
id: get_patch_version | ||
run: | | ||
VERSION=$(grep -m 1 -oP '(?<=^VERSION = ")[^"]+' apps/pv_opt/pv_opt.py) | ||
if [ -z "$VERSION" ]; then | ||
echo "Error: VERSION not found in apps/pv_opt/pv_opt.py on patch branch." >&2 | ||
exit 1 | ||
fi | ||
echo "patch_version=$VERSION" >> $GITHUB_ENV | ||
- name: Get VERSION from main branch | ||
id: get_main_version | ||
run: | | ||
git checkout temp-main | ||
VERSION=$(grep -m 1 -oP '(?<=^VERSION = ")[^"]+' apps/pv_opt/pv_opt.py) | ||
if [ -z "$VERSION" ]; then | ||
echo "Error: VERSION not found in apps/pv_opt/pv_opt.py on main branch." >&2 | ||
exit 1 | ||
fi | ||
echo "main_version=$VERSION" >> $GITHUB_ENV | ||
- name: Validate or Fix Version Increment | ||
id: validate_or_fix_version | ||
run: | | ||
patch_version=$patch_version | ||
main_version=$main_version | ||
# Extract PATCH numbers | ||
main_patch=$(echo "$main_version" | awk -F '.' '{print $3}') | ||
patch_patch=$(echo "$patch_version" | awk -F '.' '{print $3}') | ||
# Check if the patch version is incremented correctly | ||
if [ "$patch_patch" -ne $((main_patch + 1)) ]; then | ||
echo "Warning: PATCH version is not incremented correctly. Fixing..." | ||
new_patch_version=$(echo "$main_version" | awk -F '.' '{print $1"."$2"."($3+1)}') | ||
sed -i "s/^VERSION = \".*\"/VERSION = \"$new_patch_version\"/" apps/pv_opt/pv_opt.py | ||
echo "Corrected version to $new_patch_version." | ||
echo "patch_version=$new_patch_version" >> $GITHUB_ENV | ||
fi | ||
- name: Update README.md version | ||
run: | | ||
sed -i "1s/v[0-9]*\.[0-9]*\.[0-9]*/v$patch_version/" README.md | ||
- name: Commit Changes if Needed | ||
run: | | ||
git config user.name "GitHub Actions" | ||
git config user.email "[email protected]" | ||
git add apps/pv_opt/pv_opt.py README.md | ||
git diff --cached --quiet || git commit -m "Fix version and update README.md to $patch_version" | ||
- name: Push changes back to patch branch | ||
run: | | ||
git push origin HEAD:patch | ||
- name: Create or Update Pull Request for Main | ||
uses: peter-evans/create-pull-request@v5 | ||
with: | ||
token: ${{ secrets.GITHUB_TOKEN }} | ||
branch: patch | ||
base: main | ||
title: "Automated Version Fix and README Update" | ||
body: | | ||
This pull request was automatically created or updated to fix the version number and update the README.md file. | ||
Please review and merge to apply these changes to the main branch. | ||
labels: automated | ||
delete-branch: false | ||
|
||
publish-release: | ||
name: Publish Release | ||
runs-on: ubuntu-latest | ||
needs: validate-version | ||
|
||
steps: | ||
# Step 1: Checkout the repository | ||
|
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
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
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
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