Rollback to the last working point

This commit is contained in:
Edward Firmo
2024-12-21 14:54:47 +01:00
parent 3c98d81bb7
commit 5a993165cd
2 changed files with 22 additions and 20 deletions

View File

@@ -1,11 +1,14 @@
# Workflow for managing versioning, tagging, and conditional updates # Workflow for managing versioning and tagging
--- ---
name: Bump Version and Tag name: Version Bump and Tag
on: # yamllint disable-line rule:truthy on: # yamllint disable-line rule:truthy
push: push:
branches: branches:
- main - main
paths-ignore:
- '**/VERSION'
- '**/VERSION_YAML'
workflow_dispatch: workflow_dispatch:
inputs: inputs:
update_stable: update_stable:
@@ -18,7 +21,7 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v4 - uses: "actions/checkout@v4"
- name: Set up Git - name: Set up Git
run: | run: |
@@ -27,19 +30,13 @@ jobs:
- name: Bump Version - name: Bump Version
run: | run: |
chmod +x ./versioning/bump_version.sh chmod +x "./versioning/bump_version.sh"
./versioning/bump_version.sh "./versioning/bump_version.sh"
- name: Push Changes and Tags - name: Push Changes and Tags
env: env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
run: | run: |
git push https://x-access-token:${GITHUB_TOKEN}@github.com/edwardtfn/TX-Ultimate-Easy.git main git push "https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}.git" main
git push https://x-access-token:${GITHUB_TOKEN}@github.com/edwardtfn/TX-Ultimate-Easy.git --tags git push "https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}.git" --tags
- name: Conditionally Update Stable Tag
if: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.update_stable == 'true' }}
run: |
git tag -f stable
git push https://x-access-token:${GITHUB_TOKEN}@github.com/edwardtfn/TX-Ultimate-Easy.git stable --force
... ...

View File

@@ -5,15 +5,15 @@ VERSION_YAML_FILE="./versioning/VERSION_YAML"
# Read the current version # Read the current version
if [ -f "$VERSION_FILE" ]; then if [ -f "$VERSION_FILE" ]; then
CURRENT_VERSION=$(cat "$VERSION_FILE") CURRENT_VERSION=$(cat $VERSION_FILE)
else else
CURRENT_VERSION="0.0.0" # Default if file doesn't exist CURRENT_VERSION="0.0.0" # Default if file doesn't exist
fi fi
# Extract components # Extract components
CURRENT_YEAR=$(date +%Y) CURRENT_YEAR=$(date +%Y)
CURRENT_MONTH=$(date +%-m) # Use %-m to avoid leading zero for the month CURRENT_MONTH=$(date +%m)
if ! [[ "$CURRENT_VERSION" =~ ^[0-9]{4}\.[0-9]+\.[0-9]+$ ]]; then if ! [[ "$CURRENT_VERSION" =~ ^[0-9]{4}\.[0-9]{2}\.[0-9]{2}$ ]]; then
echo "Error: Invalid version format in $VERSION_FILE" echo "Error: Invalid version format in $VERSION_FILE"
exit 1 exit 1
fi fi
@@ -24,12 +24,17 @@ VERSION_MONTH=$(echo "$CURRENT_VERSION" | awk -F. '{print $2}')
# Determine new version # Determine new version
if [[ "$CURRENT_YEAR" == "$VERSION_YEAR" && "$CURRENT_MONTH" == "$VERSION_MONTH" ]]; then 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 else
NEXT_SEQ=1 # Reset sequence for a new month NEW_SEQ="01" # Reset sequence for a new month
fi fi
NEW_VERSION="${CURRENT_YEAR}.${CURRENT_MONTH}.${NEXT_SEQ}" NEW_VERSION="${CURRENT_YEAR}.${CURRENT_MONTH}.${NEW_SEQ}"
# Update the plain text VERSION file # Update the plain text VERSION file
echo "$NEW_VERSION" > "$VERSION_FILE" echo "$NEW_VERSION" > "$VERSION_FILE"