-
Notifications
You must be signed in to change notification settings - Fork 143
188 lines (162 loc) · 6.92 KB
/
release.yml
File metadata and controls
188 lines (162 loc) · 6.92 KB
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
187
188
# Copyright (c) Meta Platforms, Inc. and affiliates.
#
# This source code is licensed under the BSD license found in the
# LICENSE file in the root directory of this source tree.
# 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:
include:
# macOS builds
- platform: macos-latest # M1/M2
os: macos
architecture: arm64
- platform: macos-15-intel # Intel
os: macos
architecture: x64
# Windows builds
- platform: windows-latest
os: windows
architecture: x64
- platform: windows-latest
os: windows
architecture: x86 # 32-bit
# NOT SUPPORTED YET
# - platform: windows-2025
# os: windows
# architecture: arm64 # Windows ARM
# Linux builds
# When building with ubunutu-latest (24.04), we still see the following runtime error:
# [PYI-4568:ERROR] Failed to load Python shared library '/tmp/_MEI3FR8Jx/libpython3.11.so.1.0': dlopen: /lib64/libm.so.6: version `GLIBC_2.38' not found (required by /tmp/_MEI3FR8Jx/libpython3.11.so.1.0)
#
# Update on 2025-04-01: Have to upgrade from 20.04 because:
# This is a scheduled Ubuntu 20.04 brownout. Ubuntu 20.04 LTS runner will be removed on 2025-04-15. For more details, see https://github.com/actions/runner-images/issues/11101
- platform: ubuntu-22.04
os: linux
architecture: x64
- platform: 2-core-ubuntu-arm # or ubuntu-latest-arm
# Check other options in https://github.com/mapillary/mapillary_tools/actions/runners
os: linux
architecture: arm64 # Linux ARM
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
- name: Set up Python 3.13
uses: actions/setup-python@v5
with:
python-version: "3.13"
architecture: ${{ matrix.architecture }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install .
python -m pip install --group dev
- 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'
# 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.architecture == 'x64'
# Allow this step to fail (it frequently fails)
continue-on-error: true
- name: Build and test with Pyinstaller on MacOS
# Enable for Python3.13 only because it often fails at codesign (subprocess timeout)
if: startsWith(matrix.platform, 'macos')
run: |
./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: contains(matrix.platform, 'ubuntu')
run: |
./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: startsWith(matrix.platform, 'windows')
run: |
./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-latest"
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/