Skip to content

Commit ae7d921

Browse files
Fix release pipeline: run publish in auto-release workflow
Events created by GITHUB_TOKEN don't trigger other workflows, so the auto-release -> release.yml chain never fired. Fix by moving PyPI publish and Docker push jobs directly into auto-release.yml. release.yml is now a manual fallback (workflow_dispatch) for re-running publishes without re-creating a release. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 2193bd7 commit ae7d921

2 files changed

Lines changed: 93 additions & 21 deletions

File tree

.github/workflows/auto-release.yml

Lines changed: 70 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,30 +11,37 @@ jobs:
1111
runs-on: ubuntu-latest
1212
permissions:
1313
contents: write
14+
outputs:
15+
version: ${{ steps.version.outputs.VERSION }}
16+
tag: ${{ steps.version.outputs.TAG }}
17+
skipped: ${{ steps.check_tag.outputs.SKIP }}
1418
steps:
1519
- uses: actions/checkout@v4
1620
with:
1721
fetch-depth: 0
1822

1923
- name: Read version
24+
id: version
2025
run: |
2126
VERSION=$(cat ./version | tr -d '[:space:]')
27+
echo "VERSION=$VERSION" >> $GITHUB_OUTPUT
28+
echo "TAG=v$VERSION" >> $GITHUB_OUTPUT
2229
echo "VERSION=$VERSION" >> $GITHUB_ENV
2330
echo "TAG=v$VERSION" >> $GITHUB_ENV
2431
2532
- name: Check if tag already exists
33+
id: check_tag
2634
run: |
2735
if git rev-parse "${{ env.TAG }}" >/dev/null 2>&1; then
2836
echo "Tag ${{ env.TAG }} already exists, skipping release."
29-
echo "SKIP=true" >> $GITHUB_ENV
37+
echo "SKIP=true" >> $GITHUB_OUTPUT
3038
else
31-
echo "SKIP=false" >> $GITHUB_ENV
39+
echo "SKIP=false" >> $GITHUB_OUTPUT
3240
fi
3341
3442
- name: Extract changelog for this version
35-
if: env.SKIP == 'false'
43+
if: steps.check_tag.outputs.SKIP == 'false'
3644
run: |
37-
# Extract the section between "## $VERSION" and the next "## "
3845
CHANGELOG=$(awk -v ver="${VERSION}" '
3946
/^## / {
4047
if (found) exit
@@ -43,18 +50,74 @@ jobs:
4350
found { print }
4451
' CHANGELOG.md | sed '/^$/N;/^\n$/d')
4552
46-
# Write to file for the release body (handles multiline safely)
4753
echo "$CHANGELOG" > /tmp/release_notes.md
48-
4954
echo "Changelog extracted:"
5055
cat /tmp/release_notes.md
5156
5257
- name: Create GitHub Release
53-
if: env.SKIP == 'false'
58+
if: steps.check_tag.outputs.SKIP == 'false'
5459
env:
5560
GH_TOKEN: ${{ github.token }}
5661
run: |
5762
gh release create "${{ env.TAG }}" \
5863
--title "${{ env.TAG }}" \
5964
--notes-file /tmp/release_notes.md \
6065
--target main
66+
67+
pypi-publish:
68+
needs: create-release
69+
if: needs.create-release.outputs.skipped == 'false'
70+
runs-on: ubuntu-latest
71+
steps:
72+
- uses: actions/checkout@v4
73+
74+
- name: Set up Python
75+
uses: actions/setup-python@v5
76+
with:
77+
python-version: "3.10"
78+
79+
- name: Install build dependencies
80+
run: |
81+
python -m pip install --upgrade pip
82+
pip install build twine
83+
84+
- name: Build package
85+
run: |
86+
python -m build
87+
88+
- name: Publish package to PyPI
89+
env:
90+
TWINE_USERNAME: ${{ secrets.TWINE_USERNAME }}
91+
TWINE_PASSWORD: ${{ secrets.TWINE_PASSWORD }}
92+
run: |
93+
twine upload -u $TWINE_USERNAME -p $TWINE_PASSWORD dist/*
94+
95+
docker-push:
96+
needs: create-release
97+
if: needs.create-release.outputs.skipped == 'false'
98+
runs-on: ubuntu-latest
99+
steps:
100+
- uses: actions/checkout@v4
101+
102+
- name: Set VERSION variable
103+
run: echo "VERSION=$(cat ./version | tr -d '[:space:]')" >> $GITHUB_ENV
104+
105+
- name: Login to Docker Hub
106+
env:
107+
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
108+
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
109+
run: docker login -u $DOCKER_USERNAME -p $DOCKER_PASSWORD docker.io
110+
111+
- name: Build and push facetorch
112+
run: |
113+
docker compose build facetorch
114+
docker tag tomasgajarsky/facetorch:latest tomasgajarsky/facetorch:${{ env.VERSION }}
115+
docker push tomasgajarsky/facetorch:latest
116+
docker push tomasgajarsky/facetorch:${{ env.VERSION }}
117+
118+
- name: Build and push facetorch-gpu
119+
run: |
120+
docker compose build facetorch-gpu-no-device
121+
docker tag tomasgajarsky/facetorch-gpu:latest tomasgajarsky/facetorch-gpu:${{ env.VERSION }}
122+
docker push tomasgajarsky/facetorch-gpu:latest
123+
docker push tomasgajarsky/facetorch-gpu:${{ env.VERSION }}

.github/workflows/release.yml

Lines changed: 23 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,37 @@
11
name: release
22

33
on:
4-
release:
5-
types: [published]
4+
workflow_dispatch:
5+
inputs:
6+
tag:
7+
description: "Release tag (e.g., v0.6.1). Defaults to version file."
8+
required: false
69

710
jobs:
8-
validate-version:
11+
resolve-version:
912
runs-on: ubuntu-latest
13+
outputs:
14+
version: ${{ steps.resolve.outputs.VERSION }}
15+
tag: ${{ steps.resolve.outputs.TAG }}
1016
steps:
1117
- uses: actions/checkout@v4
1218

13-
- name: Validate release tag matches version file
19+
- name: Resolve version
20+
id: resolve
1421
run: |
15-
FILE_VERSION=$(cat ./version | tr -d '[:space:]')
16-
TAG_VERSION="${GITHUB_REF_NAME#v}"
17-
if [ "$FILE_VERSION" != "$TAG_VERSION" ]; then
18-
echo "::error::Version mismatch: version file says '$FILE_VERSION' but release tag is '$TAG_VERSION'"
19-
echo "Please ensure the version file matches the release tag (with or without 'v' prefix)."
20-
exit 1
22+
if [ -n "${{ github.event.inputs.tag }}" ]; then
23+
TAG="${{ github.event.inputs.tag }}"
24+
else
25+
FILE_VERSION=$(cat ./version | tr -d '[:space:]')
26+
TAG="v$FILE_VERSION"
2127
fi
22-
echo "Version validated: $FILE_VERSION"
28+
VERSION="${TAG#v}"
29+
echo "VERSION=$VERSION" >> $GITHUB_OUTPUT
30+
echo "TAG=$TAG" >> $GITHUB_OUTPUT
31+
echo "Releasing version: $VERSION (tag: $TAG)"
2332
2433
pypi-publish:
25-
needs: validate-version
34+
needs: resolve-version
2635
runs-on: ubuntu-latest
2736
steps:
2837
- uses: actions/checkout@v4
@@ -49,13 +58,13 @@ jobs:
4958
twine upload -u $TWINE_USERNAME -p $TWINE_PASSWORD dist/*
5059
5160
docker-push:
52-
needs: validate-version
61+
needs: resolve-version
5362
runs-on: ubuntu-latest
5463
steps:
5564
- uses: actions/checkout@v4
5665

5766
- name: Set VERSION variable
58-
run: echo "VERSION=$(cat ./version | tr -d '[:space:]')" >> $GITHUB_ENV
67+
run: echo "VERSION=${{ needs.resolve-version.outputs.version }}" >> $GITHUB_ENV
5968

6069
- name: Login to Docker Hub
6170
env:

0 commit comments

Comments
 (0)