Skip to content

Commit

Permalink
Update version-manage.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
sorinmarti authored Apr 16, 2024
1 parent 8d48ebf commit d7e4f85
Showing 1 changed file with 49 additions and 53 deletions.
102 changes: 49 additions & 53 deletions .github/workflows/version-manage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,56 +9,52 @@ 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"
((PATCH++))
echo "Patch after increment: $PATCH"
NEW_VERSION="${VER[0]}.${VER[1]}.$PATCH"
echo "New version: $NEW_VERSION"
# Assuming the rest of your script continues from here...
# Update the JSON file with the new version
jq --arg v "$NEW_VERSION" '.version = $v' ./info.json > temp.json && mv temp.json ./info.json
echo "New version saved"
# Write the new version to a separate file
echo $NEW_VERSION > ./ndr_core/VERSION
echo "Version file updated"

# Set up Git
git config --local user.email "[email protected]"
git config --local user.name "GitHub Action"

# Add changes to staging
git add ./info.json ./ndr_core/VERSION
echo "Files added to Git staging"

# Check if there are changes to commit
git diff --cached --exit-code
if [ $? -ne 0 ]; then
# Commit and push the changes
git commit -m "Bump version to $NEW_VERSION"
echo "Commit made"
git push
echo "Changes pushed"
else
echo "No changes to commit."
exit 1
end
- 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++)) || (echo "Failed to increment" && exit 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 > ./ndr_core/VERSION
echo "Version file updated"
# Set up Git
git config --local user.email "[email protected]"
git config --local user.name "GitHub Action"
# Add changes to staging
git add ./info.json ./ndr_core/VERSION
echo "Files added to Git staging"
# Check if there are changes to commit
git diff --cached --exit-code
if [ $? -ne 0 ]; then
# Commit

0 comments on commit d7e4f85

Please sign in to comment.