-
Notifications
You must be signed in to change notification settings - Fork 3
161 lines (147 loc) · 5.26 KB
/
pypi-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
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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
# This workflow will upload a Python Package using Twine when a release is created
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python#publishing-to-package-registries
# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.
name: Release
on:
release:
types: [published]
permissions:
contents: read
jobs:
build:
name: Build make-argocd-fly
runs-on: home-use
steps:
- uses: actions/checkout@v4
# https://github.com/actions/checkout/issues/335
- name: Get tags
run: git fetch --tags origin
- if: ${{ runner.arch == 'arm64' }}
name: Set up Python
uses: deadsnakes/[email protected]
with:
python-version: "3.11"
- if: ${{ runner.arch == 'amd64' }}
name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.11'
- name: Install dependencies
run: |
python -m pip install --upgrade pip setuptools wheel
pip install build
- name: Build package
run: python -m build
- name: Store the distribution packages
uses: actions/upload-artifact@v4
with:
name: python-package-distributions
path: dist/
# `pypa/gh-action-pypi-publish` runs in docker, which does not work on self-hosted runners in kubernetes mode
publish-to-testpypi:
name: Publish make-argocd-fly to TestPyPI
needs:
- build
runs-on: home-use
environment:
name: testpypi
url: https://test.pypi.org/p/make-argocd-fly
permissions:
id-token: write
steps:
- name: Download all the dists
uses: actions/download-artifact@v4
with:
name: python-package-distributions
path: dist/
- if: ${{ runner.arch == 'arm64' }}
name: Set up Python
uses: deadsnakes/[email protected]
with:
python-version: "3.11"
- if: ${{ runner.arch == 'amd64' }}
name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.11'
- name: Clone Repository
run: git clone --depth 1 --branch v1.8.14 https://github.com/pypa/gh-action-pypi-publish.git
- name: Install pip packages
run: |
cd gh-action-pypi-publish
PIP_CONSTRAINT=requirements/runtime-prerequisites.txt pip install -r requirements/runtime-prerequisites.in
PIP_CONSTRAINT=requirements/runtime.txt pip install -r requirements/runtime.in
- name: Prepare scripts
run: |
sudo mkdir /app
sudo chown -R runner:runner /app
cp gh-action-pypi-publish/twine-upload.sh gh-action-pypi-publish/print-hash.py gh-action-pypi-publish/oidc-exchange.py /app
cp -r dist /app/dist
chmod +x /app/twine-upload.sh
- name: Publish package to TestPyPI
run: |
PYTHONPATH=/usr/lib/python3/site-packages \
INPUT_USER=__token__ \
INPUT_PASSWORD="" \
INPUT_VERBOSE=false \
INPUT_REPOSITORY_URL=https://test.pypi.org/legacy/ \
INPUT_PACKAGES_DIR=/app/dist \
INPUT_VERIFY_METADATA=true \
INPUT_SKIP_EXISTING=false \
INPUT_PRINT_HASH=false \
/app/twine-upload.sh
publish-to-pypi:
name: Publish make-argocd-fly to PyPI
needs:
- publish-to-testpypi
runs-on: home-use
environment:
name: pypi
url: https://pypi.org/p/make-argocd-fly
permissions:
id-token: write
steps:
- name: Download all the dists
uses: actions/download-artifact@v4
with:
name: python-package-distributions
path: dist/
- if: ${{ runner.arch == 'arm64' }}
name: Set up Python
uses: deadsnakes/[email protected]
with:
python-version: "3.11"
- if: ${{ runner.arch == 'amd64' }}
name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.11'
- name: Clone Repository
run: git clone --depth 1 --branch v1.8.14 https://github.com/pypa/gh-action-pypi-publish.git
- name: Install pip packages
run: |
cd gh-action-pypi-publish
PIP_CONSTRAINT=requirements/runtime-prerequisites.txt pip install -r requirements/runtime-prerequisites.in
PIP_CONSTRAINT=requirements/runtime.txt pip install -r requirements/runtime.in
- name: Prepare scripts
run: |
sudo mkdir /app
sudo chown -R runner:runner /app
cp gh-action-pypi-publish/twine-upload.sh gh-action-pypi-publish/print-hash.py gh-action-pypi-publish/oidc-exchange.py /app
cp -r dist /app/dist
chmod +x /app/twine-upload.sh
- name: Publish package to PyPI
run: |
PYTHONPATH=/usr/lib/python3/site-packages \
INPUT_USER=__token__ \
INPUT_PASSWORD="" \
INPUT_VERBOSE=false \
INPUT_REPOSITORY_URL=https://upload.pypi.org/legacy/ \
INPUT_PACKAGES_DIR=/app/dist \
INPUT_VERIFY_METADATA=true \
INPUT_SKIP_EXISTING=false \
INPUT_PRINT_HASH=false \
/app/twine-upload.sh