-
Notifications
You must be signed in to change notification settings - Fork 1
182 lines (159 loc) · 5.23 KB
/
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
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
name: Build Executables
on:
push:
tags:
- 'v*'
jobs:
build:
name: Build on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- os: windows-latest
platform: windows
arch: amd64
- os: macos-13
platform: macos
arch: amd64
- os: macos-14
platform: macos
arch: arm64
- os: ubuntu-latest
platform: linux
arch: amd64
- os: ubuntu-latest
platform: linux
arch: arm64
qemu: true
steps:
- uses: actions/checkout@v4
- name: Set up QEMU
if: matrix.qemu
uses: docker/setup-qemu-action@v3
with:
platforms: arm64
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Install PDM
run: |
python -m pip install --upgrade pip
pip install pdm
- name: Install dependencies
run: pdm install
- name: Install Nuitka
run: pdm add nuitka
- name: Build with Nuitka (Windows)
if: matrix.platform == 'windows'
run: |
pdm run nuitka `
--standalone `
--onefile `
--nofollow-imports `
--include-module=typer `
--include-module=requests `
--include-module=git `
--include-module=prompt_toolkit `
--include-module=rich `
--include-package=gptcomet `
--disable-console `
--output-dir=dist `
--output-filename=gptcomet-${{ matrix.platform }}-${{ matrix.arch }}-${GITHUB_REF#refs/tags/} `
--noinclude-setuptools-mode=allow `
--noinclude-pytest-mode=allow `
--no-pyi-file `
--no-debug `
--lto=yes `
gptcomet/__main__.py
- name: Test built executable (Windows)
if: matrix.platform == 'windows'
run: |
./dist/gptcomet-${{ matrix.platform }}-${{ matrix.arch }}-${GITHUB_REF#refs/tags/}.exe --version
- name: Build with Nuitka (Unix)
if: matrix.platform != 'windows'
run: |
pdm run nuitka \
--standalone \
--onefile \
--nofollow-imports \
--include-module=typer \
--include-module=requests \
--include-module=git \
--include-module=prompt_toolkit \
--include-module=rich \
--include-package=gptcomet \
--disable-console \
--output-dir=dist \
--output-filename=gptcomet-${{ matrix.platform }}-${{ matrix.arch }}-${GITHUB_REF#refs/tags/} \
--noinclude-setuptools-mode=allow \
--noinclude-pytest-mode=allow \
--no-pyi-file \
--no-debug \
--lto=yes \
gptcomet/__main__.py
- name: Test built executable (Unix)
if: matrix.platform != 'windows'
run: |
chmod +x ./dist/gptcomet-${{ matrix.platform }}-${{ matrix.arch }}-${GITHUB_REF#refs/tags/}
./dist/gptcomet-${{ matrix.platform }}-${{ matrix.arch }}-${GITHUB_REF#refs/tags/} --version
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: gptcomet-${{ matrix.platform }}-${{ matrix.arch }}-${GITHUB_REF#refs/tags/}
path: dist/gptcomet-${{ matrix.platform }}-${{ matrix.arch }}-${GITHUB_REF#refs/tags/}*
release:
needs: build
runs-on: ubuntu-latest
permissions:
contents: write
steps:
# download all artifacts
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: dist
merge-multiple: true
# list contents
- name: List contents of dist
run: ls -al dist/
# get version
- name: Get version
id: get_version
run: echo "VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT
# checkout code for git-cliff
- uses: actions/checkout@v4
with:
fetch-depth: 0
# install git-cliff
- name: Install git-cliff
uses: kenji-miyake/setup-git-cliff@v1
# generate release notes
- name: Generate Release Notes
run: |
# Generate changelog for the current tag
git cliff --current > release_notes.md
# Append artifacts information
echo "" >> release_notes.md
echo "## Artifacts" >> release_notes.md
echo "* Windows (x64)" >> release_notes.md
echo "* macOS (x64, arm64)" >> release_notes.md
echo "* Linux (x64, arm64)" >> release_notes.md
# create GitHub Release
- name: Create Release
uses: softprops/action-gh-release@v1
with:
files: dist/gptcomet-*
body_path: release_notes.md
draft: false # no draft
prerelease: false # no prerelease
generate_release_notes: true # generate release notes
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# notification
- name: Notification
if: success()
run: |
echo "Release ${{ steps.get_version.outputs.VERSION }} has been published successfully!"