-
-
Notifications
You must be signed in to change notification settings - Fork 2
182 lines (139 loc) · 4.55 KB
/
ci-cd.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
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
name: ci-cd
on: [push, pull_request]
jobs:
linux-ci:
# Set up operating system
runs-on: ubuntu-latest
# Define job steps
steps:
- name: Set up Python 3.11
uses: actions/setup-python@v4
with:
python-version: 3.11
- name: Check-out repository
uses: actions/checkout@v4
with:
submodules: true
- name: Install babel
run: pip install Babel
- name: Build MO files
run: python setup.py compile_catalog
- name: Install build
run: pip install build
- name: Build package
run: python -m build
- name: Install built sdist
run: pip install --find-links=. dist/shithappens*.tar.gz
- name: Install built wheel
run: pip install --find-links=. dist/shithappens*.whl --force-reinstall
- name: Install twine
run: pip install twine
- name: Check README rendering for PyPI
run: twine check dist/*
- name: Install pyinstaller
run: pip install pyinstaller
- name: Build executable
run: pyinstaller shithappens.spec -y
- name: Zip bundle
run: cd dist && tar -acf shithappens-linux.tar.gz shithappens
- uses: actions/upload-artifact@v4
with:
name: shithappens-linux
path: dist/shithappens-linux.tar.gz
windows-ci:
runs-on: windows-latest
steps:
- name: Set up Python 3.11
uses: actions/setup-python@v4
with:
python-version: 3.11
- name: Check-out repository
uses: actions/checkout@v4
with:
submodules: true
- name: Install babel
run: pip install Babel
- name: Build MO files
run: python setup.py compile_catalog
- name: Install pyinstaller
run: pip install pyinstaller
- name: Build executable
run: pyinstaller shithappens.spec -y
- name: Zip bundle
run: cd dist && tar -acf shithappens-windows.zip shithappens
- uses: actions/upload-artifact@v4
with:
name: shithappens-windows
path: dist/shithappens-windows.zip
cd:
# Only run this job if the "ci" job passes
needs: [linux-ci, windows-ci]
# Only run this job if new work is pushed to "main"
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
# Set up operating system
runs-on: ubuntu-latest
# Define job steps
steps:
- name: Set up Python 3.11
uses: actions/setup-python@v4
with:
python-version: 3.11
- name: Check-out repository
uses: actions/checkout@v4
with:
fetch-depth: 0
submodules: true
ref: ${{ github.sha }}
- name: Setup | Force correct release branch on workflow sha
run: git checkout -B ${{ github.ref_name }} ${{ github.sha }}
- uses: actions/download-artifact@v4
with:
name: shithappens-windows
path: dist
- uses: actions/download-artifact@v4
with:
name: shithappens-linux
path: dist
- name: Install babel
run: pip install Babel
- name: Build MO files
run: python setup.py compile_catalog
- name: Install build
run: pip install build
- name: Action | Semantic Version Release
id: release
# Adjust tag with desired version if applicable.
uses: python-semantic-release/python-semantic-release@v9.9.0
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
git_committer_name: "github-actions"
git_committer_email: "actions@users.noreply.github.com"
- name: Remove executable bundles
run:
rm -f dist/shithappens-windows.zip dist/shithappens-linux.tar.gz
- name: Publish to TestPyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.TEST_PYPI_API_TOKEN }}
repository-url: https://test.pypi.org/legacy/
- name: Test install from TestPyPI
run: |
pip install \
--index-url https://test.pypi.org/simple/ \
--extra-index-url https://pypi.org/simple \
shithappens
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}
- name: Test install from PyPI
run: |
pip install shithappens --force-reinstall
- name: Publish | Upload to GitHub Release Assets
uses: python-semantic-release/publish-action@v9.9.0
if: steps.release.outputs.released == 'true'
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
tag: ${{ steps.release.outputs.tag }}