Skip to content

Commit 2d397f7

Browse files
authored
Merge pull request #8 from sqldef/gfx/fix-update-version-workflow
use yq to edit YAML file
2 parents 4cd1f85 + 60df79f commit 2d397f7

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

.github/workflows/update-sqldef-version.yaml

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -84,25 +84,30 @@ jobs:
8484
8585
echo "branch=$BRANCH_NAME" >> $GITHUB_ENV
8686
87+
- name: Install yq
88+
run: |
89+
curl -sL -o /tmp/yq https://github.com/mikefarah/yq/releases/download/${YQ_VERSION}/yq_linux_amd64
90+
sudo install -m 755 /tmp/yq /usr/local/bin/yq
91+
yq --version
92+
env:
93+
YQ_VERSION: v4.47.2
94+
8795
- name: Update version in action.yml
8896
env:
8997
VERSION: ${{ steps.version.outputs.version }}
9098
run: |
9199
# Store current version for comparison
92-
CURRENT_VERSION=$(grep -A 1 "description: 'Version of sqldef to use'" action.yml | grep "default:" | sed "s/.*default: '\(v[0-9.]*[^']*\)'.*/\1/")
100+
CURRENT_VERSION=$(yq '.inputs.version.default' action.yml)
93101
94102
if [ "$CURRENT_VERSION" = "$VERSION" ]; then
95103
echo "Version is already set to $VERSION, no changes needed"
96104
echo "changed=false" >> $GITHUB_ENV
97105
else
98106
echo "Updating from $CURRENT_VERSION to $VERSION"
99107
100-
# Update the default version in action.yml (more precise sed pattern)
101-
sed -i "s/\(default: '\)v[0-9]\+\.[0-9]\+\.[0-9]\+\(-[a-zA-Z0-9._-]\+\)\?\('/\1$VERSION\3/" action.yml
108+
# Update the default version in action.yml using yq
109+
yq -i '.inputs.version.default = strenv(VERSION)' action.yml
102110
103-
# Verify the change
104-
echo "Updated action.yml:"
105-
grep -A 1 "description: 'Version of sqldef to use'" action.yml
106111
echo "changed=true" >> $GITHUB_ENV
107112
fi
108113

0 commit comments

Comments
 (0)