Skip to content

Commit b3b8d09

Browse files
authored
Fixed Windows and created Release job
1 parent bfa06a9 commit b3b8d09

File tree

1 file changed

+98
-93
lines changed

1 file changed

+98
-93
lines changed

.github/workflows/build_wheels.yml

+98-93
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,80 @@ on:
88
branches:
99
- master
1010
release:
11-
# Only use the types keyword to narrow down the activity types that will trigger your workflow.
12-
types: [published, created, edited]
11+
types: [published, edited]
1312

1413

1514
jobs:
15+
build-windows-x86_64:
16+
runs-on: ${{ matrix.os }}
17+
defaults:
18+
run:
19+
shell: powershell
20+
21+
strategy:
22+
fail-fast: false
23+
matrix:
24+
os: [windows-latest]
25+
python-version: [3.6, 3.7, 3.8, 3.9]
26+
platform: [x86, x64]
27+
with_contrib: [0, 1]
28+
without_gui: [0, 1]
29+
build_sdist: [0]
30+
31+
env:
32+
ACTIONS_ALLOW_UNSECURE_COMMANDS: true
33+
SDIST: ${{ matrix.build_sdist || 0}}
34+
ENABLE_HEADLESS: ${{ matrix.without_gui }}
35+
ENABLE_CONTRIB: ${{ matrix.with_contrib }}
36+
37+
steps:
38+
- name: Checkout
39+
uses: actions/checkout@v2
40+
with:
41+
submodules: true
42+
fetch-depth: 0
43+
44+
- name: Update submodules
45+
run: |
46+
git submodule update --remote
47+
48+
- name: Set up Python ${{ matrix.python-version }}
49+
uses: actions/setup-python@v2
50+
with:
51+
python-version: ${{ matrix.python-version }}
52+
architecture: ${{ matrix.platform }}
53+
54+
- name: Setup MSBuild.exe
55+
uses: warrenbuckley/Setup-MSBuild@v1
56+
57+
- name: build script
58+
run: |
59+
python --version
60+
python -m pip install --upgrade pip
61+
python -m pip install --upgrade setuptools
62+
set "CI_BUILD=1" && python -m pip wheel --wheel-dir=%cd%\wheelhouse . --verbose
63+
shell: cmd
64+
65+
- name: before test
66+
run: |
67+
cd ${{ github.workspace }}/tests
68+
$env:PYTHONWARNINGS = "ignore:::pip._internal.cli.base_command"
69+
&python -m pip install --user --no-warn-script-location (ls "../wheelhouse/opencv*.whl")
70+
if ($LastExitCode -ne 0) {throw $LastExitCode}
71+
shell: powershell
72+
73+
- name: run test
74+
run: |
75+
cd ${{ github.workspace }}/tests
76+
python -m unittest test
77+
shell: cmd
78+
79+
- name: saving artifacts
80+
uses: actions/upload-artifact@v2
81+
with:
82+
name: wheels
83+
path: wheelhouse/opencv*.whl
84+
1685
build:
1786
runs-on: ${{ matrix.os }}
1887
defaults:
@@ -22,17 +91,12 @@ jobs:
2291
strategy:
2392
fail-fast: false
2493
matrix:
25-
os: [windows-latest, ubuntu-latest, macos-latest]
94+
os: [ubuntu-latest, macos-latest]
2695
python-version: [3.6, 3.7, 3.8, 3.9]
27-
platform: [x32, x64]
96+
platform: [x64]
2897
with_contrib: [0, 1]
2998
without_gui: [0, 1]
3099
build_sdist: [0]
31-
exclude:
32-
- os: macos-latest
33-
platform: x32
34-
- os: ubuntu-latest
35-
platform: x32
36100

37101
env:
38102
ACTIONS_ALLOW_UNSECURE_COMMANDS: true
@@ -68,9 +132,9 @@ jobs:
68132
uses: actions/setup-python@v2
69133
with:
70134
python-version: ${{ matrix.python-version }}
135+
architecture: ${{ matrix.platform }}
71136

72137
- name: Setup Environment variables
73-
if: ${{ matrix.os == 'ubuntu-latest' || matrix.os == 'macos-latest' }}
74138
run: |
75139
if [ "macos-latest" == "${{ matrix.os }}" ]; then echo "TRAVIS_OS_NAME=osx" >> $GITHUB_ENV; else echo "TRAVIS_OS_NAME=${{ matrix.os }}" >> $GITHUB_ENV; fi
76140
if [ "schedule" == "${{ github.event_name }}" ]; then echo "TRAVIS_EVENT_TYPE=cron" >> $GITHUB_ENV; else echo "TRAVIS_EVENT_TYPE=${{ github.event_name }}" >> $GITHUB_ENV; fi
@@ -79,7 +143,6 @@ jobs:
79143
echo "TEST_DEPENDS=$(echo $NP_TEST_DEP)" >> $GITHUB_ENV;
80144
81145
- name: before install
82-
if: ${{ matrix.os == 'ubuntu-latest' || matrix.os == 'macos-latest' }}
83146
run: |
84147
set -e
85148
if [[ $SDIST == 0 ]]; then
@@ -123,89 +186,31 @@ jobs:
123186
#https://travis-ci.community/t/shell-session-update-command-not-found-in-build-log-causes-build-to-fail-if-trap-err-is-set/817
124187
trap ERR
125188
test "$rc" -eq 0
126-
127-
- name: Setup MSBuild.exe
128-
if: ${{ matrix.os == 'windows-latest' }}
129-
uses: warrenbuckley/Setup-MSBuild@v1
130-
131-
- name: build script
132-
if: ${{ matrix.os == 'windows-latest' }}
133-
run: |
134-
python --version
135-
python -m pip install --upgrade pip
136-
python -m pip install --upgrade setuptools
137-
set "CI_BUILD=1" && python -m pip wheel --wheel-dir=%cd%\dist . --verbose
138-
shell: cmd
139-
140-
- name: before test
141-
if: ${{ matrix.os == 'windows-latest' }}
142-
run: |
143-
cd ${{ github.workspace }}/tests
144-
$env:PYTHONWARNINGS = "ignore:::pip._internal.cli.base_command"
145-
&python -m pip install --user --no-warn-script-location (ls "../dist/opencv_*.whl")
146-
if ($LastExitCode -ne 0) {throw $LastExitCode}
147-
shell: powershell
148-
149-
- name: run test
150-
if: ${{ matrix.os == 'windows-latest' }}
151-
run: |
152-
cd ${{ github.workspace }}/tests
153-
python -m unittest test
154-
shell: cmd
155-
156189
- name: saving artifacts
157-
if: ${{ matrix.os == 'windows-latest' }}
158190
uses: actions/upload-artifact@v2
159191
with:
160-
name: ${{ matrix.os }}-wheels-${{ matrix.python-version }}-${{ matrix.platform }}-${{ matrix.with_contrib }}-${{ matrix.without_gui }}-${{ matrix.build_sdist }}
161-
path: dist\opencv*.whl
192+
name: wheels
193+
path: wheelhouse/opencv*.whl
162194

163-
- name: saving artifacts
164-
if: ${{ matrix.os == 'ubuntu-latest' || matrix.os == 'macos-latest' }}
165-
uses: actions/upload-artifact@v2
166-
with:
167-
name: ${{ matrix.os }}-wheels-${{ matrix.python-version }}-${{ matrix.platform }}-${{ matrix.with_contrib }}-${{ matrix.without_gui }}-${{ matrix.build_sdist }}
168-
path: ./wheelhouse/opencv*.whl
169-
170-
171-
# - name: Upload wheels ${{ matrix.os }}
172-
# if: ${{ matrix.os == 'ubuntu-latest' || matrix.os == 'macos-latest' }}
173-
# env:
174-
# # PYPI repository
175-
# TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
176-
# TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
177-
# # PYPITEST repository
178-
# # TWINE_USERNAME: ${{ secrets.PYPITEST_USERNAME }}
179-
# # TWINE_PASSWORD: ${{ secrets.PYPITEST_PASSWORD }}
180-
# # TWINE_REPOSITORY_URL: 'https://test.pypi.org/legacy/'
181-
# run: |
182-
# twine upload --skip-existing ${TRAVIS_BUILD_DIR}/wheelhouse/*
183-
# # Upload wheels to PYPITEST
184-
# #twine upload --skip-existing ${TRAVIS_BUILD_DIR}/wheelhouse/*
185-
186-
# - name: Upload wheels ${{ matrix.os }}
187-
# if: ${{ matrix.os == 'windows-latest' && startsWith(github.ref, 'refs/tags/')}}
188-
# env:
189-
# USER: fXgF9uyy6sT0JoVOR7BoqA==
190-
# PASS: 0bXSOVjf9x8L7nErTivu92TF1FwNosTjFJQPmxp8Dys=
191-
# run: |
192-
# cd ${{ github.workspace }}
193-
# if (${Env:ENABLE_CONTRIB} -eq 0) {
194-
# if (${Env:ENABLE_HEADLESS} -eq 0) {
195-
# echo "This is a default build. Deployment will be done to PyPI entry opencv-python."
196-
# }
197-
# else {
198-
# echo "This is a headless build. Deployment will be done to PyPI entry opencv-python-headless."
199-
# }
200-
# }
201-
# else {
202-
# if (${Env:ENABLE_HEADLESS} -eq 0) {
203-
# echo "This is a contrib build. Deployment will be done to PyPI entry opencv-contrib-python."
204-
# }
205-
# else {
206-
# echo "This is a headless contrib build. Deployment will be done to PyPI entry opencv-contrib-python-headless."
207-
# }
208-
# }
209-
# &python -m pip install twine
210-
# &python -m twine upload -u ${Env:USER} -p ${Env:PASS} --skip-existing dist/opencv*
211-
# shell: powershell
195+
release:
196+
if: startsWith(github.ref, 'refs/tags/v')
197+
needs: [build, build-windows-x86_64]
198+
runs-on: ubuntu-latest
199+
defaults:
200+
run:
201+
shell: bash
202+
steps:
203+
- uses: actions/download-artifact@v2
204+
with:
205+
name: wheels
206+
path: wheelhouse/
207+
208+
- name: Upload wheels ${{ matrix.os }}
209+
if: ${{ matrix.os == 'ubuntu-latest' || matrix.os == 'macos-latest' }} && startsWith(github.ref, 'refs/tags/')
210+
env:
211+
# PYPI repository credentials
212+
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
213+
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
214+
run: |
215+
python -m pip install twine
216+
python -m twine upload -u ${Env:TWINE_USERNAME} -p ${Env:TWINE_PASSWORD} --skip-existing wheelhouse/opencv*

0 commit comments

Comments
 (0)