@@ -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 }}
0 commit comments