-
Notifications
You must be signed in to change notification settings - Fork 1
52 lines (52 loc) · 1.52 KB
/
publish.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# Creates a git tag and publishes to pypi based on the
# version specified in pyproject.toml.
name: Publish to PyPI
on:
push:
branches:
- main
paths:
- pyproject.toml
workflow_dispatch:
permissions:
contents: write
jobs:
test:
uses: ./.github/workflows/test.yml
publish:
needs: test
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v4
- name: Install poetry
run: pipx install poetry
- uses: actions/setup-python@v5
with:
cache: "poetry"
python-version: "3.11"
- name: Install dependencies
run: poetry install --only main
- name: get cvml package version
run: echo "VERSION=$(poetry version --short)" >> $GITHUB_ENV
- name: check if git tag exists
run: |
git fetch --tags
if [[ $(git tag -l $VERSION | wc -l) -eq '1' ]]; then
echo "git tag already exists"
echo "PUBLISH=false" >> $GITHUB_ENV
else
echo "git tag does not exist"
echo "PUBLISH=true" >> $GITHUB_ENV
fi
- name: create git tag
if: env.PUBLISH == 'true'
run: git tag $VERSION
- name: push git tag
if: env.PUBLISH == 'true'
run: git push --tags
- name: build and publish to pypi
if: env.PUBLISH == 'true'
run: poetry publish --build --username $PYPI_USERNAME --password $PYPI_TOKEN
env:
PYPI_TOKEN: ${{ secrets.PYPI_TOKEN }}
PYPI_USERNAME: ${{ secrets.PYPI_USERNAME }}