-
Notifications
You must be signed in to change notification settings - Fork 139
164 lines (141 loc) · 6.05 KB
/
release.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
# This workflow will build the package with Pyinstaller, upload it to GitHub Releases, and publish it to PyPI
name: Release
on:
push:
tags:
- "v*.*.*"
jobs:
build_and_release:
if: ${{ startsWith(github.ref, 'refs/tags/') }}
strategy:
matrix:
python-version: ["3.11"]
platform: ["ubuntu-20.04", "macos-latest", "windows-latest"]
architecture: ["x64"]
include:
- architecture: "x86"
platform: "windows-latest"
python-version: "3.11"
runs-on: ${{ matrix.platform }}
defaults:
run:
working-directory: ./main
steps:
# https://github.com/actions/checkout#Checkout-multiple-repos-side-by-side
# pull into mapillary/mapillary_tools/main
- uses: actions/checkout@v4
with:
path: main
# https://github.com/actions/checkout#Checkout-multiple-repos-side-by-side
# pull into mapillary/mapillary_tools/exiftool
- name: Setup ExifTool
uses: actions/checkout@v4
with:
repository: "exiftool/exiftool"
path: exiftool
- name: Check ExifTool version
# DO NOT USE envvars here which does not work on Windows (needs prefixing with $env:)
# need to rename exiftool to exiftool.pl according to https://exiftool.org/install.html
run: |
mv ${{ github.workspace }}/exiftool/exiftool ${{ github.workspace }}/exiftool/exiftool.pl
perl ${{ github.workspace }}/exiftool/exiftool.pl -ver
- name: Setup FFmpeg
uses: FedericoCarboni/setup-ffmpeg@v3
# ffmpeg is not supported in the latest macOS arch:
# Error: setup-ffmpeg can only be run on 64-bit systems
if: matrix.platform != 'macos-latest'
- name: Set up ${{ matrix.architecture }} Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
# optional x64 or x86. Defaults to x64 if not specified
architecture: ${{ matrix.architecture }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install .
python -m pip install -r requirements-dev.txt
- name: Validate version
run: |
EXPECTED_GITHUB_REF=$(mapillary_tools --version | awk '{print "refs/tags/v" $3}')
if [[ "$EXPECTED_GITHUB_REF" != "$GITHUB_REF" ]]; then
echo "Version mismatch: $EXPECTED_GITHUB_REF != $GITHUB_REF"
exit 1
fi
if: matrix.platform != 'windows-latest'
- name: Build and test with Pyinstaller on MacOS
# Enable for Python3.11 only because it often fails at codesign (subprocess timeout)
if: matrix.platform == 'macos-latest'
run: |
# see https://github.com/mapillary/mapillary_tools/issues/566
# TODO: move it to extras in setup.py
python3 -m pip install pysocks
./script/build_osx
# Could run full integration tests with the binary (it might be slow)
pytest tests/integration
env:
MAPILLARY_TOOLS__TESTS_EXECUTABLE: ./dist/osx/mapillary_tools
MAPILLARY_TOOLS__TESTS_EXIFTOOL_EXECUTABLE: perl ${{ github.workspace }}/exiftool/exiftool.pl
- name: Build and test with Pyinstaller on Ubuntu
if: matrix.platform == 'ubuntu-20.04'
run: |
# see https://github.com/mapillary/mapillary_tools/issues/566
# TODO: move it to extras in setup.py
python3 -m pip install pysocks
./script/build_linux
# Could run full integration tests with the binary (it might be slow)
pytest tests/integration
env:
MAPILLARY_TOOLS__TESTS_EXECUTABLE: ./dist/linux/mapillary_tools
MAPILLARY_TOOLS__TESTS_EXIFTOOL_EXECUTABLE: perl ${{ github.workspace }}/exiftool/exiftool.pl
- name: Build and test with Pyinstaller on Windows
if: matrix.platform == 'windows-latest'
run: |
# see https://github.com/mapillary/mapillary_tools/issues/566
# TODO: move it to extras in setup.py
python3 -m pip install pysocks
./script/build_bootloader.ps1
./script/build_win.ps1
# Could run full integration tests with the binary (it might be slow)
cp ./dist/win/mapillary_tools.exe mapillary_tools_WINDOWS_VERY_HARD_TO_FIND_YOU_IN_ANOTHER_DIR_SO_I_MOVE_YOU_HERE.exe
pytest tests/integration
env:
MAPILLARY_TOOLS__TESTS_EXECUTABLE: mapillary_tools_WINDOWS_VERY_HARD_TO_FIND_YOU_IN_ANOTHER_DIR_SO_I_MOVE_YOU_HERE.exe
MAPILLARY_TOOLS__TESTS_EXIFTOOL_EXECUTABLE: perl ${{ github.workspace }}/exiftool/exiftool.pl
- name: Release
uses: softprops/action-gh-release@v1
with:
draft: true
generate_release_notes: true
fail_on_unmatched_files: true
files: |
./main/dist/releases/*
pypi-publish:
if: ${{ startsWith(github.ref, 'refs/tags/') }}
name: Upload release to PyPI
needs: ["build_and_release"]
runs-on: "ubuntu-20.04"
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.x"
# https://packaging.python.org/en/latest/guides/publishing-package-distribution-releases-using-github-actions-ci-cd-workflows/
- name: Install pypa/build
run: python3 -m pip install build
- name: Build
# the default ouput dir dist/ was used by pyinstaller
run: python3 -m build --outdir pypa_dist/ .
- name: Publish package distributions to TestPyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
repository-url: https://test.pypi.org/legacy/
password: ${{ secrets.TEST_PYPI_API_TOKEN }}
packages-dir: pypa_dist/
skip-existing: true
- name: Publish package distributions to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.PYPI_API_TOKEN }}
packages-dir: pypa_dist/