-
Notifications
You must be signed in to change notification settings - Fork 10
101 lines (90 loc) · 2.85 KB
/
release_pypi.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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
name: Build and upload to PyPI and ghcr.io
on:
workflow_dispatch:
release:
types:
- published
jobs:
build:
name: Build universal wheel and source distribution
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: ["ubuntu-22.04"]
python-version: ["3.10"]
# https://github.com/marketplace/actions/setup-miniconda#use-a-default-shell
defaults:
run:
shell: bash -l {0}
steps:
- uses: actions/checkout@v3
- uses: ./.github/actions/install-python-and-package
with:
python-version: ${{ matrix.python-version }}
extras-require: publishing
pkg-installation-type: "repository"
- name: Build wheel and source distribution
run: python3 -m build
- uses: actions/upload-artifact@v3
with:
path: dist/*
upload_test_pypi:
needs: build
runs-on: ubuntu-22.04
if: github.event_name == 'workflow_dispatch'
steps:
- uses: actions/download-artifact@v3
with:
name: artifact
path: dist
- uses: pypa/[email protected]
with:
user: __token__
password: ${{ secrets.TEST_PYPI_TOKEN_DEEPRANK2 }}
repository_url: https://test.pypi.org/legacy/
upload_pypi:
needs: build
runs-on: ubuntu-22.04
if: github.event_name == 'release' && github.event.action == 'published'
steps:
- uses: actions/download-artifact@v3
with:
name: artifact
path: dist
- uses: pypa/[email protected]
with:
user: __token__
password: ${{ secrets.PYPI_TOKEN_DEEPRANK2 }}
read_only_version:
needs: upload_pypi
name: Read version from TOML
runs-on: ubuntu-22.04
outputs:
version: ${{ steps.get_version.outputs.VERSION }}
repo_lowercase: ${{ steps.repo_lowercase.outputs.REPO_LOWERCASE }}
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Read version from TOML
id: get_version
run: |
VERSION=$(grep '^version =' pyproject.toml | awk -F '"' '{print $2}')
echo "VERSION=$VERSION" >> $GITHUB_OUTPUT
- name: Convert repository name to lowercase
id: repo_lowercase
run: |
REPO_LOWERCASE=$(echo "${{ github.repository }}" | tr '[:upper:]' '[:lower:]')
echo "REPO_LOWERCASE=$REPO_LOWERCASE" >> $GITHUB_OUTPUT
upload_docker_image:
needs: read_only_version
name: Upload Docker image to ghcr.io
uses: ./.github/workflows/_ghcr.yml
with:
ghcr_user: ${{github.actor}}
base_image_name: ghcr.io/${{ needs.read_only_version.outputs.repo_lowercase }}
image_tag: ${{ needs.read_only_version.outputs.version }}
dockerfile: ./Dockerfile
docker_context: .
secrets:
token: ${{secrets.GITHUB_TOKEN}}