-
Notifications
You must be signed in to change notification settings - Fork 0
141 lines (121 loc) · 4.6 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
name: Build
on:
push:
branches:
- main
tags:
- '*'
jobs:
build:
name: ${{ matrix.job.target }} (${{ matrix.job.os }})
runs-on: ${{ matrix.job.os }}
strategy:
fail-fast: false
matrix:
job:
- { target: aarch64-apple-darwin , os: macos-latest }
- { target: x86_64-apple-darwin , os: macos-13 }
- { target: x86_64-pc-windows , os: windows-latest }
- { target: x86_64-unknown-linux-gnu , os: ubuntu-latest }
steps:
- name: Checkout source code
uses: actions/checkout@v4
- name: Extract pyproject infos
shell: bash
run: |
echo "PROJECT_NAME=$(sed -n 's/^name = "\(.*\)"/\1/p' pyproject.toml| head -n 1)" >> $GITHUB_ENV
echo "PROJECT_VERSION=$(sed -n 's/^version = "\(.*\)"/\1/p' pyproject.toml| head -n 1)" >> $GITHUB_ENV
- name: Generate project data
shell: bash
run: |
EXE_suffix=""
case ${{ matrix.job.target }} in
*-windows-*) EXE_suffix=".exe" ;;
esac
BIN_NAME="alwaysdata${EXE_suffix}"
COMPILER_OPTS="--disable-ccache"
case ${{ matrix.job.target }} in
*-linux-* | *-apple-*) COMPILER_OPTS="${COMPILER_OPTS} --clang --lto=yes" ;;
*-apple-*) COMPILER_OPTS="${COMPILER_OPTS} --clang" ;;
x86_64-*-windows-*) COMPILER_OPTS="${COMPILER_OPTS} --mingw64" ;;
esac
PLUGINS_OPTS=""
case ${{ matrix.job.target }} in
x86_64-*-windows-* | x86_64-apple-*) PLUGINS_OPTS="${PLUGINS_OPTS} --enable-plugin=upx" ;;
esac
PLATFORM="x64"
case ${{ matrix.job.target }} in
i686-*) PLATFORM="x86" ;;
esac
BASENAME=${PROJECT_NAME}-v${PROJECT_VERSION}-${{ matrix.job.target }}
mkdir -p ${BASENAME}
echo "BASENAME=${BASENAME}" >> $GITHUB_ENV
echo "BIN_NAME=${BIN_NAME}" >> $GITHUB_ENV
echo "COMPILER_OPTS=${COMPILER_OPTS}" >> $GITHUB_ENV
echo "PLUGINS_OPTS=${PLUGINS_OPTS}" >> $GITHUB_ENV
echo "PLATFORM=${PLATFORM}" >> $GITHUB_ENV
- name: Install Python 3.11
uses: actions/setup-python@v5
with:
python-version: "3.11"
architecture: ${{ env.PLATFORM }}
- name: Install Poetry
uses: abatilo/actions-poetry@v2
with:
poetry-version: 1.8.2
- name: Install dependencies
shell: bash
run: poetry install --with build
- name: Run Nuitka build
shell: bash
run: |
poetry run python -m nuitka \
--company-name=alwaysdata --product-name=${{ env.PROJECT_NAME }} \
--product-version=${{ env.PROJECT_VERSION }} \
--standalone \
--onefile \
--onefile-tempdir-spec='%CACHE_DIR%/%COMPANY%/%PRODUCT%/%VERSION%' \
--python-flag=-m \
--follow-import-to=src \
--assume-yes-for-downloads \
--enable-plugin=no-qt ${{ env.PLUGINS_OPTS }} \
--noinclude-default-mode=nofollow \
--show-anti-bloat-changes \
--report=${{ env.BASENAME }}/report-${{ env.BASENAME }}.xml \
--output-dir=${{ env.BASENAME }} \
--output-filename=${{ env.BIN_NAME }} \
--no-progressbar \
${{ env.COMPILER_OPTS }} \
src
- name: "Report upload"
uses: actions/upload-artifact@master
with:
name: report-${{ env.BASENAME }}.xml
path: ${{ env.BASENAME }}/report-${{ env.BASENAME }}.xml
- name: Package
shell: bash
run: |
PKG_suffix=".tar.gz"
case ${{ matrix.job.target }} in
*-windows-*) PKG_suffix=".zip" ;;
esac
PKG_NAME=${BASENAME}${PKG_suffix}
PKG_DIR=${BASENAME}/packages
mkdir -p ${PKG_DIR}/${BASENAME}
case ${{ matrix.job.target }} in
*-apple-* | *-linux-*) chmod +x ${BASENAME}/${BIN_NAME} ;;
esac
cp ${BASENAME}/${BIN_NAME} ${PKG_DIR}/${BASENAME}
pushd "${PKG_DIR}/" >/dev/null
case ${{ matrix.job.target }} in
*-windows-*) 7z -y a "${PKG_NAME}" "${BASENAME}" | tail -2 ;;
*) tar czf "${PKG_NAME}" "${BASENAME}" ;;
esac
popd > /dev/null
echo "PKG_NAME=${PKG_NAME}" >> $GITHUB_ENV
echo "PKG_PATH=${PKG_DIR}/${PKG_NAME}" >> $GITHUB_ENV
- name: "Artifact upload"
uses: actions/upload-artifact@master
with:
name: ${{ env.PKG_NAME }}
path: ${{ env.PKG_PATH }}