-
Notifications
You must be signed in to change notification settings - Fork 1
66 lines (66 loc) · 2.26 KB
/
release-on-push-to-main.yaml
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
name: Release on push to `main`
on:
push:
branches:
- main
paths:
- pyproject.toml
jobs:
check-publishability:
runs-on: ubuntu-latest
outputs:
publishable: ${{ steps.check.outputs.publish }}
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 2
# Only publish if the version has changed; otherwise, we would be
# re-publishing existing stuff without updating the version, and that
# could cause problems.
- run: |
set -x
publishable=false
diff=$(git diff HEAD:pyproject.toml HEAD~1:pyproject.toml)
echo "$diff" | grep '+version ='
if [[ "$?" == "0" ]]
then
publishable=true
fi
echo "::set-output name=publish::${publishable}"
name: Check if the change should be published
id: check
build-and-publish:
needs: [check-publishability]
if: needs.check-publishability.outputs.publishable == 'true'
runs-on: ubuntu-latest
permissions:
packages: write
steps:
- uses: actions/checkout@v3
- uses: abatilo/[email protected]
- run: poetry config virtualenvs.create false
- run: sudo apt-get -y install jq
- name: Log in to the Container registry
uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- run: |
version=$(poetry version -s)
echo "::notice::Publishing version ${version}"
echo "::set-output name=version::${version}"
umbrella_version=$(echo "${version}" | cut -f1-2 -d.)
echo "::set-output name=umbrella-version::${umbrella_version}"
id: get-version
- run: poetry install
- run: |
$(fingerprinter -o build-script) --release ${version} --cache
$(fingerprinter -o build-script) --release ${umbrella-version} --cache
env:
version: ${{ steps.get-version.outputs.version }}
umbrella_version: ${{ steps.get-version.outputs.umbrella-version }}
- run: |
poetry config pypi-token.pypi ${{ secrets.PYPI_TOKEN }}
poetry build -n
poetry publish -n