1
1
name : Release
2
2
3
3
on :
4
- workflow_dispatch : {}
4
+ workflow_dispatch :
5
+ inputs :
6
+ version :
7
+ required : true
8
+ description : Version to release
9
+ test-repository :
10
+ required : true
11
+ type : boolean
12
+ default : true
13
+ description : Upload to Test PyPI repository?
14
+ test-package :
15
+ required : true
16
+ type : boolean
17
+ default : true
18
+ description : Try installing from Test PyPI repository?
5
19
6
20
jobs :
7
21
Release :
@@ -11,3 +25,102 @@ jobs:
11
25
steps :
12
26
- name : Checkout
13
27
uses : actions/checkout@v3
28
+ - name : Install Python
29
+ uses : actions/setup-python@v4
30
+ with :
31
+ python-version : " 3.9"
32
+
33
+ - name : Set version
34
+ run : echo "VERSION=${{ github.event.inputs.version }}" >> $GITHUB_ENV
35
+ - name : Validate version
36
+ run : test "${{ env.VERSION }}"
37
+
38
+ - name : Override version in setup.py
39
+ shell : python
40
+ run : |-
41
+ FILE = "setup.py"
42
+ with open(FILE, "r") as f:
43
+ data = f.read()
44
+
45
+ data = data.replace("$VERSION$", "${{ github.event.inputs.version }}")
46
+ with open(FILE, "w") as f:
47
+ f.write(data)
48
+
49
+ - name : Override requirements in setup.py
50
+ shell : python
51
+ run : |-
52
+ requirements = list()
53
+ with open("requirements.txt", "r") as f:
54
+ for line in f.readlines():
55
+ line = line.split("#")[0].strip()
56
+ if line:
57
+ requirements.append(line)
58
+
59
+ FILE = "setup.py"
60
+ with open(FILE, "r") as f:
61
+ data = f.read()
62
+
63
+ import json
64
+ data = data.replace("$REQUIREMENTS$", json.dumps(requirements))
65
+ with open(FILE, "w") as f:
66
+ f.write(data)
67
+
68
+ - name : Set PyPI repository/token (production)
69
+ if : ${{ github.event.inputs.test-repository == 'false' }}
70
+ run : |-
71
+ echo "PYPI_REPOSITORY=https://pypi.python.org/simple/" >> $GITHUB_ENV
72
+ echo "PYPI_TOKEN=${{ secrets.PYPI_TOKEN }}" >> $GITHUB_ENV
73
+
74
+ - name : Set PyPI repository/token (test)
75
+ if : ${{ github.event.inputs.test-repository == 'true' }}
76
+ run : |-
77
+ echo "PYPI_REPOSITORY=https://test.pypi.org/legacy/" >> $GITHUB_ENV
78
+ echo "PYPI_TOKEN=${{ secrets.PYPI_TEST_TOKEN }}" >> $GITHUB_ENV
79
+
80
+ - name : Build package
81
+ run : python setup.py sdist
82
+
83
+ - name : Publish package to PyPI
84
+ uses : pypa/gh-action-pypi-publish@5fb2f047e26679d7846a8370de1642ff160b9025
85
+ with :
86
+ repository_url : ${{ env.PYPI_REPOSITORY }}
87
+ password : ${{ env.PYPI_TOKEN }}
88
+
89
+ TestRelease :
90
+ name : Test Release
91
+ if : ${{ github.event.inputs.test-repository == 'true' && github.event.inputs.test-package == 'true' }}
92
+ runs-on : ubuntu-latest
93
+ needs :
94
+ - Release
95
+
96
+ steps :
97
+ - name : Checkout
98
+ uses : actions/checkout@v3
99
+ - name : Install Python
100
+ uses : actions/setup-python@v4
101
+ with :
102
+ python-version : " 3.9"
103
+
104
+ - name : Install pnytter requirements from main PyPI repository
105
+ run : pip install -r requirements.txt
106
+
107
+ # TODO allow testing from production index
108
+ - name : Install pnytter package
109
+ uses : nick-fields/retry@v2
110
+ with :
111
+ timeout_seconds : 30
112
+ max_attempts : 12
113
+ retry_wait_seconds : 5
114
+ retry_on : error
115
+ command : pip install --index-url="https://test.pypi.org/simple/" "pnytter==${{ github.event.inputs.version }}"
116
+ - name : Install test requirements
117
+ run : pip install -r requirements-test.txt
118
+
119
+ - name : Move tests directory
120
+ run : mv tests /tmp/pnytter-tests
121
+ - name : Run tests
122
+ working-directory : /tmp/pnytter-tests
123
+ run : pytest -sv .
124
+ env :
125
+ TEST_NITTER_INSTANCES : |-
126
+ ["https://nitter.pussthecat.org"]
0 commit comments