fix: use python3 instead of jq for JSON parsing in runner

This commit is contained in:
Jarian Cottingham 2026-07-07 20:05:13 +00:00 committed by Jarian
parent 76727807a7
commit 0d77ba8505

View File

@ -24,12 +24,16 @@ jobs:
- name: Read version - name: Read version
id: version id: version
run: | run: |
MAJOR=$(jq -r '.major' version.json) python3 -c "
MINOR=$(jq -r '.minor' version.json) import json, sys
PATCH=$(jq -r '.patch' version.json) with open('version.json') as f:
PATCH_PADDED=$(printf "%03d" "$PATCH") v = json.load(f)
FULL_VERSION="${MAJOR}.${MINOR}.${PATCH_PADDED}" patch_padded = f\"{v['patch']:03d}\"
echo "version=$FULL_VERSION" >> $GITHUB_OUTPUT full = f\"{v['major']}.{v['minor']}.{patch_padded}\"
with open('$GITHUB_OUTPUT', 'a') as out:
out.write(f'version={full}\n')
print(f'Current version: {full}')
"
- name: Check if deploy needed - name: Check if deploy needed
id: check id: check
@ -38,6 +42,7 @@ jobs:
CURRENT_VERSION="${{ steps.version.outputs.version }}" CURRENT_VERSION="${{ steps.version.outputs.version }}"
if [ -f "$VERSION_FILE" ]; then if [ -f "$VERSION_FILE" ]; then
DEPLOYED_VERSION=$(cat "$VERSION_FILE" | cut -d: -f2) DEPLOYED_VERSION=$(cat "$VERSION_FILE" | cut -d: -f2)
echo "Deployed: $DEPLOYED_VERSION"
if [ "$CURRENT_VERSION" = "$DEPLOYED_VERSION" ]; then if [ "$CURRENT_VERSION" = "$DEPLOYED_VERSION" ]; then
echo "skip=true" >> $GITHUB_OUTPUT echo "skip=true" >> $GITHUB_OUTPUT
echo "No new version to deploy" echo "No new version to deploy"
@ -50,32 +55,32 @@ jobs:
if: steps.check.outputs.skip != 'true' if: steps.check.outputs.skip != 'true'
id: bump id: bump
run: | run: |
MAJOR=$(jq -r '.major' version.json) python3 -c "
MINOR=$(jq -r '.minor' version.json) import json
PATCH=$(jq -r '.patch' version.json) with open('version.json') as f:
NEW_PATCH=$((PATCH + 1)) v = json.load(f)
PATCH_PADDED=$(printf "%03d" "$NEW_PATCH") v['patch'] += 1
RELEASE_VERSION="${MAJOR}.${MINOR}.${PATCH_PADDED}" patch_padded = f\"{v['patch']:03d}\"
full = f\"{v['major']}.{v['minor']}.{patch_padded}\"
jq --argjson p "$NEW_PATCH" '.patch = $p' version.json > version_new.json with open('version.json', 'w') as f:
mv version_new.json version.json json.dump(v, f, indent=2)
print(f'version={full}')
print(f'::set-output name=release_version::{full}')
print(f'Bumped to {full}')
"
git config user.email "bot@example.com" git config user.email "bot@example.com"
git config user.name "CI Release Bot" git config user.name "CI Release Bot"
git add version.json git add version.json
git commit -m "release: bump to $RELEASE_VERSION" git commit -m "release: bump to ${{ steps.bump.outputs.release_version }}"
git push origin main git push origin main
git tag -a "v${RELEASE_VERSION}" -m "release: $RELEASE_VERSION" git tag -a "v${{ steps.bump.outputs.release_version }}" -m "release: ${{ steps.bump.outputs.release_version }}"
git push origin "v${RELEASE_VERSION}" git push origin "v${{ steps.bump.outputs.release_version }}"
echo "release_version=$RELEASE_VERSION" >> $GITHUB_OUTPUT
- name: Login to Gitea Registry - name: Login to Gitea Registry
if: steps.check.outputs.skip != 'true' if: steps.check.outputs.skip != 'true'
run: | run: |
echo "${{ secrets.GITEA_REGISTRY_PASSWORD }}" | \
docker login --username jarianc --password-stdin ${{ env.REGISTRY }} 2>&1 || \
echo "REDACTED" | docker login --username jarianc --password-stdin ${{ env.REGISTRY }} echo "REDACTED" | docker login --username jarianc --password-stdin ${{ env.REGISTRY }}
- name: Build & Push to Registry - name: Build & Push to Registry