Skip to content

Commit fa90d6a

Browse files
committed
deploy dev versions too
1 parent 366ff60 commit fa90d6a

File tree

1 file changed

+41
-27
lines changed

1 file changed

+41
-27
lines changed

.github/workflows/release.yml

+41-27
Original file line numberDiff line numberDiff line change
@@ -2,55 +2,69 @@ name: Release
22

33
on:
44
push:
5+
branches:
6+
- main
57
tags:
6-
- v[0-9]+.[0-9]+.[0-9]+
8+
- v*
79

810
jobs:
9-
pypi:
11+
version:
12+
runs-on: ubuntu-latest
13+
outputs:
14+
version: ${{ steps.version.outputs.version }}
15+
steps:
16+
- uses: actions/checkout@v4
17+
- name: Get version
18+
id: version
19+
run: |
20+
LATEST_TAG=v$(git describe --tags --abbrev=0 || echo "0.0.0")
21+
GIT_DESCRIBE=$(git describe --always --tags --long)
22+
# Check if the current commit is exactly on a tag
23+
if [[ "$GIT_DESCRIBE" == "$LATEST_TAG" ]]; then
24+
echo "version=${LATEST_TAG}" >> $GITHUB_OUTPUT
25+
else
26+
echo "version=${LATEST_TAG}.dev-${GIT_DESCRIBE#$LATEST_TAG-}" >> $GITHUB_OUTPUT
27+
fi
28+
29+
pypi:
1030
runs-on: ubuntu-latest
1131
container: python:3.12
32+
needs: version
1233
steps:
13-
- uses: actions/checkout@v4
14-
- name: Install package tools
15-
run: pip install twine setuptools wheel
16-
- run: python setup.py sdist bdist_wheel
17-
- uses: actions/upload-artifact@v4
18-
with:
19-
name: dist
20-
path: dist
21-
- run: twine upload dist/*
22-
env:
23-
TWINE_USERNAME: ${{secrets.PYPI_USERNAME}}
24-
TWINE_PASSWORD: ${{secrets.PYPI_PASSWORD}}
34+
- uses: actions/checkout@v4
35+
- name: Install package tools
36+
run: pip install twine setuptools wheel
37+
- name: Build package
38+
run: python setup.py sdist bdist_wheel
39+
- name: Upload to PyPI
40+
run: twine upload dist/*
41+
env:
42+
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
43+
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
2544

2645
docker:
2746
runs-on: ubuntu-latest
47+
needs: version
2848
steps:
29-
-
30-
name: Checkout
49+
- name: Checkout
3150
uses: actions/checkout@v4
32-
-
33-
name: Docker meta
51+
- name: Docker meta
3452
id: meta
3553
uses: docker/metadata-action@v5
3654
with:
3755
images: |
3856
rwnxt/pynonymizer
3957
tags: |
40-
type=semver,pattern={{version}}
41-
type=semver,pattern={{major}}.{{minor}}
42-
-
43-
name: Login to DockerHub
44-
if: github.event_name != 'pull_request'
58+
type=raw,value=latest,enable=${{ startsWith(github.ref, 'refs/tags/v') }}
59+
type=raw,value=${{ needs.version.outputs.version }},enable=${{ github.event_name == 'push' }}
60+
- name: Login to DockerHub
4561
uses: docker/login-action@v3
4662
with:
4763
username: ${{ secrets.DOCKERHUB_USERNAME }}
4864
password: ${{ secrets.DOCKERHUB_TOKEN }}
49-
-
50-
name: Build and push
65+
- name: Build and push
5166
uses: docker/build-push-action@v5
5267
with:
5368
context: .
54-
push: ${{ github.event_name != 'pull_request' }}
5569
tags: ${{ steps.meta.outputs.tags }}
56-
labels: ${{ steps.meta.outputs.labels }}
70+
labels: ${{ steps.meta.outputs.labels }}

0 commit comments

Comments
 (0)