forked from fodfodfod/Email-Generator
-
Notifications
You must be signed in to change notification settings - Fork 0
102 lines (97 loc) · 2.95 KB
/
python-build.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
# Builds the package, and, if the commit has a tag assigned to it, create a release for it and publish it to PyPI
name: Build CI/CD
on:
push:
pull_request:
jobs:
# Builds the package and uploads a build artifiact
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/[email protected]
with:
python-version: '3.12'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install build
- name: Build package
run: python -m build
- name: Upload a Build Artifact
uses: actions/[email protected]
with:
name: distribution-archives
path: dist/*
# Builds binaries with pyinstaller
pyinstaller:
strategy:
matrix:
os: ['ubuntu', 'windows', 'macos']
runs-on: ${{ matrix.os }}-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/[email protected]
with:
python-version: '3.12'
- name: Install dependencies
run: pip install .[packaging]
- name: Build executable
run: pyinstaller --noconfirm pyinstaller.spec
- name: Create DMG
if: runner.os == 'macOS'
run: |
brew update
brew install create-dmg
mkdir -p dist/dmg
mv dist/*.app dist/dmg
create-dmg \
--volname "E-mail Draft Generator" \
--volicon "assets/icon.png" \
--window-pos 200 120 \
--window-size 600 300 \
--icon-size 100 \
--icon "E-mail Draft Generator.app" 175 120 \
--hide-extension "E-mail Draft Generator.app" \
--app-drop-link 425 120 \
"dist/E-mail Draft Generator.dmg" \
"dist/dmg/"
rm -r "dist/E-mail Draft Generator" "dist/dmg"
- name: Upload a Build Artifact
uses: actions/[email protected]
with:
name: package-${{ matrix.os }}
path: dist/*
# Creates a release if the commit has a tag associated with it
release:
needs: build
if: startsWith(github.ref, 'refs/tags/')
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Download build
uses: actions/[email protected]
with:
name: distribution-archives
path: dist
- name: Create release
uses: softprops/action-gh-release@v2
if: startsWith(github.ref, 'refs/tags/')
with:
files: dist/*
# Publish to PyPI if the commit has a tag associated with it
publish:
needs: build
if: startsWith(github.ref, 'refs/tags/')
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Download build
uses: actions/[email protected]
with:
name: distribution-archives
path: dist
- name: Publish package
uses: pypa/gh-action-pypi-publish@81e9d935c883d0b210363ab89cf05f3894778450