-
Notifications
You must be signed in to change notification settings - Fork 16
105 lines (95 loc) · 2.88 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
102
103
104
105
name: PyPI Release
# https://help.github.com/en/actions/reference/events-that-trigger-workflows
on: # Trigger the workflow on push or pull request, but only for the master branch
push:
branches: [main, "release/*"]
tags: ["v?[0-9]+.[0-9]+.[0-9]+"]
release:
types: [published]
defaults:
run:
shell: bash
jobs:
# based on https://github.com/pypa/gh-action-pypi-publish
build-package:
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- name: Checkout 🛎️
uses: actions/checkout@v4
with:
submodules: recursive
- name: Set up Python 🐍
uses: actions/setup-python@v5
with:
python-version: 3.8
- name: Prepare build env.
run: pip install -r ./requirements/gha-package.txt
- name: Create 📦 package
uses: ./.github/actions/pkg-create
- name: Upload 📤 to the share store
uses: actions/upload-artifact@v3
with:
name: pypi-packages-${{ github.sha }}
path: dist
include-hidden-files: true
upload-package:
needs: build-package
if: github.event_name == 'release'
timeout-minutes: 5
runs-on: ubuntu-latest
steps:
- name: Checkout 🛎️
uses: actions/checkout@v4
with:
submodules: recursive
- name: Download 📥 artifact
uses: actions/download-artifact@v3
with:
name: pypi-packages-${{ github.sha }}
path: dist
- name: local 🗃️ files
run: ls -lh dist/
- name: Upload to release
uses: AButler/[email protected]
with:
files: "dist/*"
repo-token: ${{ secrets.GITHUB_TOKEN }}
delay-publish:
needs: build-package
if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags')
runs-on: ubuntu-latest
steps:
- name: Delay ⏰ releasing
uses: juliangruber/sleep-action@v2
with:
time: 5m
publish-package:
needs: delay-publish
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- name: Checkout 🛎️
uses: actions/checkout@v4
with:
submodules: recursive
- name: Download 📥 artifact
uses: actions/download-artifact@v3
with:
name: pypi-packages-${{ github.sha }}
path: dist
- name: local 🗃️ files
run: ls -lh dist/
# We do this, since failures on test.pypi aren't that bad
- name: Publish to Test PyPI
uses: pypa/[email protected]
with:
user: __token__
password: ${{ secrets.test_pypi_password }}
repository_url: https://test.pypi.org/legacy/
verbose: true
- name: Publish distribution 📦 to PyPI
uses: pypa/[email protected]
with:
user: __token__
password: ${{ secrets.pypi_password }}