-
Notifications
You must be signed in to change notification settings - Fork 13
186 lines (161 loc) · 5.3 KB
/
ci.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
183
184
185
186
name: test-and-deploy
on:
push:
branches: [ dev ]
paths-ignore:
- '**.md'
- '**.txt'
concurrency:
# subsequently queued workflow run will interrupt previous runs
group: '${{ github.workflow }} @ ${{ github.event.pull_request.head.label || github.head_ref || github.ref }}'
cancel-in-progress: true
jobs:
release-flag:
if: contains(github.event.head_commit.message, 'gha:release')
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
pypi-flag:
if: contains(github.event.head_commit.message, 'gha:pypi')
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
master-flag:
if: contains(github.event.head_commit.message, 'gha:master')
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
test:
timeout-minutes: 15
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ ubuntu-latest, macos-latest, windows-latest ]
python-version: [ '3.8', '3.11', '3.12' ]
steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install --upgrade setuptools distlib
pip install -e .
pip install -r requirements.txt
- name: Lint
run: |
python3 ./do.py lint
- name: Run unit tests
run: |
python3 ./do.py test
- name: Run pkg tests
# важно, чтобы в случае Windows это был действительно python, а
# не python3. Иначе вызовы самого-себя в качестве дочернего процесса
# приведут к ошибкам с "ненайденными файлами". Ненайденный - вероятно
# сам пайтоне внутри venv
run: |
python ./do.py test-pkg
to-staging:
needs: [test, build-exe]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- name: Merge current -> staging
uses: devmasx/[email protected]
with:
type: now
target_branch: staging
github_token: ${{ github.token }}
build-exe:
#needs: [ to-staging ]
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ ubuntu-latest, macos-latest, windows-latest ]
steps:
- uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v4
with:
#python-version: '3.11.2'
python-version: '3.12'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install --upgrade setuptools distlib
pip install -e .
pip install -r requirements.txt
- name: Build
run: python ./do.py build
- name: Run exe (test A)
run: dist/img2texture --version
- name: Run exe (test B)
run: dist/img2texture docs/1_orion_src.jpg texture.tmp.jpg
- name: Store Exe as artifact
uses: actions/upload-artifact@v3
with:
name: binary_from_${{ matrix.os }}
path: dist/*
retention-days: 3
to-master:
# if the commit message was "publish", copy the tested code
# to "master" branch and create GitHub release
needs: [ to-staging, master-flag ]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
# UPDATE MASTER BRANCH
- name: Merge to master branch
uses: devmasx/[email protected]
with:
type: now
target_branch: master
github_token: ${{ github.token }}
to-pypi:
needs: [ to-master, pypi-flag ]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
# ADD PYPI RELEASE
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.x'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install setuptools wheel twine
- name: Build and publish
env:
TWINE_USERNAME: ${{ secrets.PYPI_USR }}
TWINE_PASSWORD: ${{ secrets.PYPI_PWD }}
run: |
python setup.py sdist bdist_wheel
twine upload dist/*
to-github-release:
needs: [ build-exe, to-staging, release-flag ]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Get previously built artifacts
uses: actions/download-artifact@v3
with:
path: downloaded_artifacts
- name: Create distributable archives
run: |
wget -c https://github.com/rtmigo/exe2dist/releases/latest/download/exe2dist_linux_amd64.tgz -O - | tar -xz
./exe2dist img2texture 'downloaded_artifacts/*/*' dist
- name: Get the project version
run: |
echo "::set-output name=VER::$(python setup.py --version)"
id: version
- name: Publish GitHub release
id: publish_github_release
uses: softprops/action-gh-release@v1
with:
tag_name: ${{ steps.version.outputs.VER }}
files: ./dist/*
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}