Skip to content

Commit

Permalink
Merge pull request #46 from edwardtfn/new-versioning-03
Browse files Browse the repository at this point in the history
Rollback to the last working point
  • Loading branch information
edwardtfn authored Dec 21, 2024
2 parents d04c2af + 8558bc3 commit 46c04eb
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 26 deletions.
28 changes: 7 additions & 21 deletions .github/workflows/versioning.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Workflow for managing versioning, tagging, and temporary branches
# Workflow for managing versioning and tagging
---
name: Version Bump and Tag

Expand All @@ -21,7 +21,7 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- uses: "actions/checkout@v4"

- name: Set up Git
run: |
Expand All @@ -36,27 +36,13 @@ jobs:
- name: Bump Version
run: |
chmod +x ./versioning/bump_version.sh
./versioning/bump_version.sh
chmod +x "./versioning/bump_version.sh"
"./versioning/bump_version.sh"
- name: Push Changes to Temporary Branch
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
run: |
git push "https://x-access-token:${GITHUB_TOKEN}@github.com/${{ github.repository }}.git" HEAD
- name: Merge Changes into Main
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
git checkout main
git pull "https://x-access-token:${GITHUB_TOKEN}@github.com/${{ github.repository }}.git" main
git merge --no-ff "$TEMP_BRANCH" -m "Automated Version Bump [skip-versioning]"
git push "https://x-access-token:${GITHUB_TOKEN}@github.com/${{ github.repository }}.git" main
- name: Delete Temporary Branch
if: always()
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
git push "https://x-access-token:${GITHUB_TOKEN}@github.com/${{ github.repository }}.git" --delete "$TEMP_BRANCH"
git push "https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}.git" main
git push "https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}.git" --tags
...
15 changes: 10 additions & 5 deletions versioning/bump_version.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ fi

# Extract components
CURRENT_YEAR=$(date +%Y)
CURRENT_MONTH=$(date +%-m) # Use %-m to avoid leading zero for the month
if ! [[ "$CURRENT_VERSION" =~ ^[0-9]{4}\.[0-9]+\.[0-9]+$ ]]; then
CURRENT_MONTH=$(date +%m)
if ! [[ "$CURRENT_VERSION" =~ ^[0-9]{4}\.[0-9]{2}\.[0-9]{2}$ ]]; then
echo "Error: Invalid version format in $VERSION_FILE"
exit 1
fi
Expand All @@ -24,12 +24,17 @@ VERSION_MONTH=$(echo "$CURRENT_VERSION" | awk -F. '{print $2}')

# Determine new version
if [[ "$CURRENT_YEAR" == "$VERSION_YEAR" && "$CURRENT_MONTH" == "$VERSION_MONTH" ]]; then
NEXT_SEQ=$((CURRENT_SEQ + 1))
NEXT_SEQ=$((10#$CURRENT_SEQ + 1))
if [ $NEXT_SEQ -gt 99 ]; then
echo "Error: Sequence number would exceed 99"
exit 1
fi
NEW_SEQ=$(printf "%02d" $NEXT_SEQ)
else
NEXT_SEQ=1 # Reset sequence for a new month
NEW_SEQ="01" # Reset sequence for a new month
fi

NEW_VERSION="${CURRENT_YEAR}.${CURRENT_MONTH}.${NEXT_SEQ}"
NEW_VERSION="${CURRENT_YEAR}.${CURRENT_MONTH}.${NEW_SEQ}"

# Update the plain text VERSION file
echo "$NEW_VERSION" > "$VERSION_FILE"
Expand Down

0 comments on commit 46c04eb

Please sign in to comment.