diff --git a/.gitea/workflows/release.yml b/.gitea/workflows/release.yml index 83063dc..78545f6 100644 --- a/.gitea/workflows/release.yml +++ b/.gitea/workflows/release.yml @@ -24,12 +24,16 @@ jobs: - name: Read version id: version run: | - MAJOR=$(jq -r '.major' version.json) - MINOR=$(jq -r '.minor' version.json) - PATCH=$(jq -r '.patch' version.json) - PATCH_PADDED=$(printf "%03d" "$PATCH") - FULL_VERSION="${MAJOR}.${MINOR}.${PATCH_PADDED}" - echo "version=$FULL_VERSION" >> $GITHUB_OUTPUT + python3 -c " + import json, sys + with open('version.json') as f: + v = json.load(f) + patch_padded = f\"{v['patch']:03d}\" + 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 id: check @@ -38,6 +42,7 @@ jobs: CURRENT_VERSION="${{ steps.version.outputs.version }}" if [ -f "$VERSION_FILE" ]; then DEPLOYED_VERSION=$(cat "$VERSION_FILE" | cut -d: -f2) + echo "Deployed: $DEPLOYED_VERSION" if [ "$CURRENT_VERSION" = "$DEPLOYED_VERSION" ]; then echo "skip=true" >> $GITHUB_OUTPUT echo "No new version to deploy" @@ -50,32 +55,32 @@ jobs: if: steps.check.outputs.skip != 'true' id: bump run: | - MAJOR=$(jq -r '.major' version.json) - MINOR=$(jq -r '.minor' version.json) - PATCH=$(jq -r '.patch' version.json) - NEW_PATCH=$((PATCH + 1)) - PATCH_PADDED=$(printf "%03d" "$NEW_PATCH") - RELEASE_VERSION="${MAJOR}.${MINOR}.${PATCH_PADDED}" - - jq --argjson p "$NEW_PATCH" '.patch = $p' version.json > version_new.json - mv version_new.json version.json + python3 -c " + import json + with open('version.json') as f: + v = json.load(f) + v['patch'] += 1 + patch_padded = f\"{v['patch']:03d}\" + full = f\"{v['major']}.{v['minor']}.{patch_padded}\" + with open('version.json', 'w') as f: + 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.name "CI Release Bot" 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 tag -a "v${RELEASE_VERSION}" -m "release: $RELEASE_VERSION" - git push origin "v${RELEASE_VERSION}" - - echo "release_version=$RELEASE_VERSION" >> $GITHUB_OUTPUT + git tag -a "v${{ steps.bump.outputs.release_version }}" -m "release: ${{ steps.bump.outputs.release_version }}" + git push origin "v${{ steps.bump.outputs.release_version }}" - name: Login to Gitea Registry if: steps.check.outputs.skip != 'true' 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 }} - name: Build & Push to Registry