This commit is contained in:
Timothy Jaeryang Baek committed 2026-06-06 14:10:07 +01:00
1 parent dbb9ea1625
commit fa0959981a
3 files changed
+71 -164

No files matched your search

+15 -39
View File
@@ -17,52 +17,27 @@ permissions:
packages: write
jobs:
detect-version-change:
# ── Read version from pyproject.toml (release builds only) ─────────────────
read-version:
if: github.ref == 'refs/heads/release'
runs-on: ubuntu-latest
outputs:
version_changed: ${{ steps.check.outputs.changed }}
version: ${{ steps.check.outputs.version }}
version: ${{ steps.pkg.outputs.version }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 2
- uses: actions/checkout@v4
- name: Check for version bump
id: check
- name: Read version
id: pkg
run: |
CURRENT=$(python3 -c "
VERSION=$(python3 -c "
import re, pathlib
text = pathlib.Path('pyproject.toml').read_text()
m = re.search(r'^version\s*=\s*\"([^\"]+)\"', text, re.M)
print(m.group(1))
")
echo "version=$VERSION" >> $GITHUB_OUTPUT
git show HEAD~1:pyproject.toml > /tmp/prev_pyproject.toml 2>/dev/null || true
if [ -f /tmp/prev_pyproject.toml ]; then
PREVIOUS=$(python3 -c "
import re, pathlib
text = pathlib.Path('/tmp/prev_pyproject.toml').read_text()
m = re.search(r'^version\s*=\s*\"([^\"]+)\"', text, re.M)
print(m.group(1) if m else '')
")
else
PREVIOUS=""
fi
echo "current=$CURRENT"
echo "previous=$PREVIOUS"
if [ "$CURRENT" != "$PREVIOUS" ] && [ -n "$CURRENT" ]; then
echo "changed=true" >> "$GITHUB_OUTPUT"
echo "version=$CURRENT" >> "$GITHUB_OUTPUT"
echo "Version changed: $PREVIOUS -> $CURRENT"
else
echo "changed=false" >> "$GITHUB_OUTPUT"
echo "No version change detected"
fi
# ── Dev builds (main branch) ──────────────────────────────────────────────
build-dev:
if: github.ref == 'refs/heads/main'
strategy:
@@ -145,9 +120,10 @@ jobs:
-t "${{ env.IMAGE }}:dev-${SHORT_SHA}" \
$(printf '${{ env.IMAGE }}@sha256:%s ' *)
# ── Release builds (release branch) ───────────────────────────────────────
build-release:
needs: detect-version-change
if: github.ref == 'refs/heads/release' && needs.detect-version-change.outputs.version_changed == 'true'
needs: read-version
if: github.ref == 'refs/heads/release'
strategy:
fail-fast: false
matrix:
@@ -198,8 +174,8 @@ jobs:
retention-days: 1
merge-release:
needs: [detect-version-change, build-release]
if: github.ref == 'refs/heads/release' && needs.detect-version-change.outputs.version_changed == 'true'
needs: [read-version, build-release]
if: github.ref == 'refs/heads/release'
runs-on: ubuntu-latest
steps:
- name: Download digests
@@ -222,7 +198,7 @@ jobs:
- name: Create release multi-arch manifest
working-directory: /tmp/digests
run: |
VERSION="${{ needs.detect-version-change.outputs.version }}"
VERSION="${{ needs.read-version.outputs.version }}"
MAJOR_MINOR="${VERSION%.*}"
docker buildx imagetools create \
-t "${{ env.IMAGE }}:latest" \