This commit is contained in:
Edward Firmo
2024-12-21 10:33:54 +01:00
2 changed files with 31 additions and 7 deletions

View File

@@ -18,7 +18,7 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v4
- name: Set up Git - name: Set up Git
run: | run: |
@@ -34,8 +34,14 @@ jobs:
env: env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: | run: |
git push origin main if ! git push origin main; then
git push origin --tags --force echo "Failed to push to main branch"
exit 1
fi
if ! git push origin --tags --force; then
echo "Failed to push tags"
exit 1
fi
- name: Conditionally Update Stable Tag - name: Conditionally Update Stable Tag
if: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.update_stable == 'true' }} if: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.update_stable == 'true' }}

View File

@@ -13,6 +13,10 @@ fi
# Extract components # Extract components
CURRENT_YEAR=$(date +%Y) CURRENT_YEAR=$(date +%Y)
CURRENT_MONTH=$(date +%m) 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
CURRENT_SEQ=$(echo "$CURRENT_VERSION" | awk -F. '{print $3}') CURRENT_SEQ=$(echo "$CURRENT_VERSION" | awk -F. '{print $3}')
VERSION_YEAR=$(echo "$CURRENT_VERSION" | awk -F. '{print $1}') VERSION_YEAR=$(echo "$CURRENT_VERSION" | awk -F. '{print $1}')
@@ -20,7 +24,12 @@ 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
NEW_SEQ=$(printf "%02d" $((10#$CURRENT_SEQ + 1))) # Increment sequence 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
NEW_SEQ="01" # Reset sequence for a new month NEW_SEQ="01" # Reset sequence for a new month
fi fi
@@ -34,6 +43,15 @@ echo "$NEW_VERSION" > "$VERSION_FILE"
echo "version: $NEW_VERSION" > "$VERSION_YAML_FILE" echo "version: $NEW_VERSION" > "$VERSION_YAML_FILE"
# Commit and tag # Commit and tag
git add "$VERSION_FILE" "$VERSION_YAML_FILE" if ! git add "$VERSION_FILE" "$VERSION_YAML_FILE"; then
git commit -m "Bump version to $NEW_VERSION" echo "Error: Failed to stage version files"
git tag "v$NEW_VERSION" exit 1
fi
if ! git commit -m "Bump version to $NEW_VERSION"; then
echo "Error: Failed to commit version bump"
exit 1
fi
if ! git tag "v$NEW_VERSION"; then
echo "Error: Failed to create version tag"
exit 1
fi