-
Notifications
You must be signed in to change notification settings - Fork 2
120 lines (103 loc) · 3.51 KB
/
Copy pathcd-release.yaml
File metadata and controls
120 lines (103 loc) · 3.51 KB
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
name: Release
on:
workflow_dispatch:
inputs:
version:
required: true
description: Version to release
test-repository:
required: true
type: boolean
default: true
description: Upload to Test PyPI repository?
test-package:
required: true
type: boolean
default: true
description: Try installing from Test PyPI repository?
jobs:
Release:
name: Release
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Install Python
uses: actions/setup-python@v4
with:
python-version: "3.9"
- name: Set version
run: echo "VERSION=${{ github.event.inputs.version }}" >> $GITHUB_ENV
- name: Validate version
run: test "${{ env.VERSION }}"
- name: Override version in setup.py
shell: python
run: |-
FILE = "setup.py"
with open(FILE, "r") as f:
data = f.read()
data = data.replace("$VERSION$", "${{ github.event.inputs.version }}")
with open(FILE, "w") as f:
f.write(data)
- name: Override requirements in setup.py
shell: python
run: |-
requirements = list()
with open("requirements.txt", "r") as f:
for line in f.readlines():
line = line.split("#")[0].strip()
if line:
requirements.append(line)
FILE = "setup.py"
with open(FILE, "r") as f:
data = f.read()
import json
data = data.replace("$REQUIREMENTS$", json.dumps(requirements))
with open(FILE, "w") as f:
f.write(data)
- name: Set PyPI repository/token (production)
if: ${{ github.event.inputs.test-repository == 'false' }}
run: |-
echo "PYPI_REPOSITORY=https://upload.pypi.org/legacy/" >> $GITHUB_ENV
echo "PYPI_TOKEN=${{ secrets.PYPI_TOKEN }}" >> $GITHUB_ENV
- name: Set PyPI repository/token (test)
if: ${{ github.event.inputs.test-repository == 'true' }}
run: |-
echo "PYPI_REPOSITORY=https://test.pypi.org/legacy/" >> $GITHUB_ENV
echo "PYPI_TOKEN=${{ secrets.PYPI_TEST_TOKEN }}" >> $GITHUB_ENV
- name: Build package
run: python setup.py sdist
- name: Publish package to PyPI
uses: pypa/gh-action-pypi-publish@5fb2f047e26679d7846a8370de1642ff160b9025
with:
repository_url: ${{ env.PYPI_REPOSITORY }}
password: ${{ env.PYPI_TOKEN }}
TestRelease:
name: Test Release
if: ${{ github.event.inputs.test-repository == 'true' && github.event.inputs.test-package == 'true' }}
runs-on: ubuntu-latest
needs:
- Release
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Install Python
uses: actions/setup-python@v4
with:
python-version: "3.9"
- name: Install qqddm requirements from GitHub repository
run: pip install -r requirements.txt
# TODO allow testing from production index
- name: Install qqddm package
uses: nick-fields/retry@v2
with:
timeout_seconds: 30
max_attempts: 12
retry_wait_seconds: 5
retry_on: error
command: pip install --index-url="https://test.pypi.org/simple/" "qqddm==${{ github.event.inputs.version }}"
- name: Test
shell: python
run: |-
from qqddm import AnimeConverter
print(AnimeConverter())