-
Notifications
You must be signed in to change notification settings - Fork 4
185 lines (166 loc) · 6.06 KB
/
deploy.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
name: Deploy
on:
push:
tags: ['v*']
workflow_dispatch:
inputs:
pre-release-suffix:
description: 'Version suffix for pre-release package ("a", "b", "rc", etc.)'
required: false
default: ''
pre-release-version:
description: 'Version number for pre-release package (defaults to build number)'
required: false
default: ''
publish:
description: 'Publish package to PyPI'
required: false
default: 'true'
env:
LATEST_PY_VERSION: '3.12'
# Required for creating a new release
permissions:
contents: write
jobs:
build-app-packages:
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
fail-fast: false
defaults:
run:
shell: bash
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: ${{ env.LATEST_PY_VERSION }}
- uses: snok/[email protected]
with:
virtualenvs-in-project: true
# Install binary + python dependencies
- name: Install system packages
if: startsWith(matrix.os, 'ubuntu')
run: sudo apt-get install -y '^libxcb.*-dev' libegl-dev libwebp-dev libpng16-16 libx11-xcb-dev rpm
- name: Cache python packages
id: cache
uses: actions/cache@v4
with:
path: .venv
key: venv-${{ env.LATEST_PY_VERSION }}-pyinstaller-${{ matrix.os }}-${{ hashFiles('poetry.lock') }}
- name: Install python packages
if: steps.cache.outputs.cache-hit != 'true'
run: |
poetry install -v --only main
poetry run pip install -U pyinstaller setuptools
- name: Build pyinstaller package
run: poetry run pyinstaller -y packaging/naturtag.spec
# Include taxon FTS db, compress, and set platform name
- name: Finish pyinstaller package (Linux)
if: startsWith(matrix.os, 'ubuntu')
run: |
ASSETS=dist/naturtag/_internal/assets/data
tar -xvzf $ASSETS/taxonomy.tar.gz --directory $ASSETS/
rm $ASSETS/taxonomy.tar.gz
tar -C dist/naturtag/ -czvf naturtag-linux.tar.gz .
echo "DIST_NAME=linux" >> $GITHUB_ENV
- name: Finish pyinstaller package (macOS)
if: startsWith(matrix.os, 'macos')
run: |
ASSETS=dist/naturtag.app/Contents/Resources/assets/data
tar -xvzf $ASSETS/taxonomy.tar.gz --directory $ASSETS/
rm $ASSETS/taxonomy.tar.gz
tar -C dist/naturtag/ -czvf naturtag-macos.tar.gz .
echo "DIST_NAME=macos" >> $GITHUB_ENV
- name: Finish pyinstaller package (Windows)
if: startsWith(matrix.os, 'windows')
run: |
ASSETS=dist/naturtag/_internal/assets/data
tar -xvzf $ASSETS/taxonomy.tar.gz --directory $ASSETS/
rm $ASSETS/taxonomy.tar.gz
tar -C dist/naturtag/ -czvf naturtag-windows.tar.gz .
echo "DIST_NAME=windows" >> $GITHUB_ENV
# Build deb, snap, and rpm packages
- name: Build Linux packages with FPM
if : startsWith(matrix.os, 'ubuntu')
run: |
export GEM_HOME="$(ruby -e 'puts Gem.user_dir')"
export PATH="$PATH:$GEM_HOME/bin"
gem install fpm --user-install
cd packaging
./build_fpm.sh
# Build dmg package
- name: Build disk image (macOS)
if: startsWith(matrix.os, 'macos')
run: |
brew install create-dmg
cd packaging
./build_dmg.sh
# Upload workflow artifacts
- name: Upload pyinstaller package
uses: actions/upload-artifact@v4
with:
name: naturtag-${{ env.DIST_NAME }}.tar.gz
path: naturtag-${{ env.DIST_NAME }}.tar.gz
- name: Upload disk image (macOS)
if: startsWith(matrix.os, 'macos')
uses: actions/upload-artifact@v4
with:
name: naturtag.dmg
path: dist/naturtag.dmg
- name: Upload FPM workflow artifacts (Linux)
if : startsWith(matrix.os, 'ubuntu')
uses: actions/upload-artifact@v4
with:
name: naturtag-fpm
path: dist/naturtag.*
# Create a release with all workflow artifacts attached
release-app-packages:
if: startsWith(github.ref, 'refs/tags/')
runs-on: ubuntu-latest
needs: build-app-packages
steps:
- uses: actions/download-artifact@v4
- name: Collect artifacts from workflow subdirs
run: |
find . -type d -depth -name 'naturtag*' -exec mv {} {}_dir \;
find . -type f -mindepth 2 -exec mv -- {} . \;
rmdir *_dir
ls -ARl
- name: Create release
uses: softprops/action-gh-release@v2
with:
files: 'naturtag*'
body: |
See changelog for release details: https://github.com/pyinat/naturtag/blob/main/HISTORY.md
See docs for installation instructions: https://naturtag.readthedocs.io/en/stable/installation.html
draft: true
# Publish python package to PyPI
release-pypi-package:
if: |
github.event.inputs.publish != 'false'
&& (startsWith(github.ref, 'refs/tags/v') || github.event.inputs.pre-release-suffix)
runs-on: ubuntu-latest
permissions:
id-token: write
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: ${{ env.LATEST_PY_VERSION }}
- uses: snok/[email protected]
with:
virtualenvs-in-project: true
- name: Set pre-release version
if: github.event.inputs.pre-release-suffix
env:
pre-release-suffix: ${{ github.event.inputs.pre-release-suffix }}
pre-release-version: ${{ github.event.inputs.pre-release-version || github.run_number }}
run: |
poetry version $(poetry version -s).${{ env.pre-release-suffix }}${{ env.pre-release-version }}
poetry version
- name: Build package distributions
run: poetry build
- name: Publish package distributions to PyPI
uses: pypa/gh-action-pypi-publish@release/v1