Fixing Github Workflow Actions #184
This file contains hidden or 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
| name: Bump Version and update Version file | |
| on: | |
| push: | |
| branches: | |
| - master | |
| jobs: | |
| bump-version: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v3 | |
| - name: Bump version in JSON | |
| shell: bash | |
| run: | | |
| # Read the current version from the JSON file | |
| VERSION=$(jq -r '.version' ./info.json) | |
| echo "Current version: $VERSION" | |
| # Bump the patch version | |
| IFS='.' read -ra VER <<< "$VERSION" | |
| echo "Current version parts: ${VER[0]}, ${VER[1]}, ${VER[2]}" | |
| # Try to increment the patch version using a temporary variable | |
| PATCH=${VER[2]} | |
| echo "Patch before increment: $PATCH" | |
| # Attempt to increment the patch | |
| PATCH=$(($PATCH + 1)) | |
| echo "Patch after increment: $PATCH" | |
| NEW_VERSION="${VER[0]}.${VER[1]}.$PATCH" | |
| echo "New version: $NEW_VERSION" | |
| # Update the JSON file with the new version | |
| if ! jq --arg v "$NEW_VERSION" '.version = $v' ./info.json > temp.json; then | |
| echo "Failed to update JSON file" | |
| exit 1 | |
| fi | |
| mv temp.json ./info.json | |
| echo "New version saved" | |
| # Write the new version to a separate file | |
| echo $NEW_VERSION > ./twf/VERSION | |
| echo "Version file updated" | |
| # Set up Git | |
| git config --local user.email "[email protected]" | |
| git config --local user.name "sorinmarti" | |
| git remote set-url origin https://x-access-token:${{ secrets.PAT_GITHUB }}@github.com/${{ github.repository }}.git | |
| # Add changes to staging | |
| git add ./info.json ./twf/VERSION | |
| echo "Files added to Git staging" | |
| git commit -m "Bump version to $NEW_VERSION" | |
| git push origin master --force | |
| echo "Changes pushed" |