-
-
Notifications
You must be signed in to change notification settings - Fork 139
198 lines (176 loc) · 7.61 KB
/
Copy pathbuild-linux.yml
File metadata and controls
198 lines (176 loc) · 7.61 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
189
190
191
192
193
194
195
196
197
198
# Builds the standalone native Linux packages (.deb + .rpm) for x86_64 and
# aarch64 and attaches them to the GitHub release that triggered the run. The
# embedded PostgreSQL is sourced differently per arch (pgserver wheel on x86_64;
# a from-source build on aarch64, which has no pgserver wheel) -- see the
# `strategy` block and the per-arch build steps below.
#
# Mirrors build-macos.yml. The package bundles EVERYTHING (Python runtime,
# onnxruntime, PyAV/ffmpeg, the ONNX models, an embedded PostgreSQL via pgserver
# and an embedded Redis), so an installed package needs no Docker and no
# separately-installed database/broker. See native-build/linux/README.md for why Postgres and
# Redis are bundled rather than declared as system dependencies (pgvector +
# unaccent/pg_trgm against an exact PG minor, plus the per-distro package-name /
# version skew, make a portable single .deb/.rpm "hard dependency" infeasible).
#
# The small native build inputs (redis-server, the unaccent/pg_trgm contrib
# modules) are built from source in this workflow (native-build/linux/vendor/*) rather than
# committed, then baked into the bundle by the shared AudioMuse-AI.spec.
#
# The ~5 GB of models are NOT in git. This workflow assembles ./model from the
# same GitHub releases the Dockerfile/macOS build use, INCLUDING the HuggingFace
# cache (trimmed to just the roberta-base tokenizer the app actually loads) so
# the release assets stay under GitHub's 2 GB per-file limit.
name: Build standalone Linux packages
on:
push:
tags:
- 'v*.*.*' # Build on every version tag (same trigger as the other builds)
pull_request: # Build on PRs too, to catch bundle breakage early.
types:
- opened
- reopened
- synchronize
workflow_dispatch: # Allow manual runs for testing without a release
concurrency:
group: build-linux-${{ github.ref }}
cancel-in-progress: true
permissions:
contents: read
env:
# Releases the models live on. Bump these in lockstep with the Dockerfile.
MODEL_RELEASE: v5.0.0-model
DCLAP_RELEASE: v1
NFPM_VERSION: '2.41.1'
jobs:
build:
# Skip draft PRs and fork PRs -- the same guard the other build workflows use.
if: >-
github.event_name != 'pull_request' ||
(github.event.pull_request.draft == false &&
github.event.pull_request.head.repo.full_name == github.repository)
# Two legs. The embedded PostgreSQL differs by arch because the `pgserver`
# wheel exists for manylinux x86_64 but NOT for Linux aarch64:
# * x86_64 -> pgserver wheel (+ vendored unaccent/pg_trgm grafted in).
# * aarch64 -> a from-source PostgreSQL (server + the two contrib modules)
# built here and bundled wholesale; managed by
# native-build/linux/embedded_pg.py at runtime.
strategy:
fail-fast: false
matrix:
include:
- runner: ubuntu-22.04
arch: x86_64
- runner: ubuntu-22.04-arm
arch: aarch64
runs-on: ${{ matrix.runner }}
permissions:
contents: read
env:
ARCH: ${{ matrix.arch }}
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Python 3.12
uses: actions/setup-python@v5
with:
python-version: '3.12'
- name: Sanity-check runner architecture
run: |
set -euo pipefail
GOT="$(uname -m)"
if [ "$GOT" != "${ARCH}" ]; then
echo "::error::Expected ${ARCH} runner but uname -m reports $GOT"
exit 1
fi
echo "Building for $GOT"
- name: Install build toolchain (compilers, headers, nfpm)
run: |
set -euo pipefail
sudo apt-get update
# build-essential + zlib headers: redis and the PG contrib modules
# compile against these. bison/flex: required to build PostgreSQL from
# source (aarch64 leg). rpm: so nfpm can emit an .rpm.
sudo apt-get install -y --no-install-recommends \
build-essential curl ca-certificates pkg-config \
libreadline-dev zlib1g-dev bison flex rpm desktop-file-utils
# nfpm (builds both .deb and .rpm from one config).
case "${ARCH}" in
x86_64) NFPM_ARCH=x86_64 ;;
aarch64) NFPM_ARCH=arm64 ;;
esac
curl -fsSL "https://github.com/goreleaser/nfpm/releases/download/v${NFPM_VERSION}/nfpm_${NFPM_VERSION}_Linux_${NFPM_ARCH}.tar.gz" \
| sudo tar xz -C /usr/local/bin nfpm
nfpm --version
- name: Validate the desktop entries
run: |
set -euo pipefail
desktop-file-validate native-build/linux/packaging/AudioMuse-AI.desktop
desktop-file-validate native-build/linux/packaging/AudioMuse-AI-stop.desktop
echo "Desktop entries are valid."
- name: Install Python dependencies
run: |
set -euo pipefail
python3.12 -m venv .venv-linux
source .venv-linux/bin/activate
pip install --upgrade pip
pip install -r requirements/linux.txt
- name: Build vendored redis-server
run: bash native-build/linux/vendor/build-redis.sh
# x86_64: compile unaccent/pg_trgm against the installed pgserver's PG.
- name: Build vendored PostgreSQL contrib (x86_64, against pgserver)
if: matrix.arch == 'x86_64'
run: |
set -euo pipefail
source .venv-linux/bin/activate # pgserver must be importable
bash native-build/linux/vendor/pg-contrib/build-pg-contrib.sh
# aarch64: no pgserver wheel -> build a relocatable PostgreSQL (server +
# unaccent/pg_trgm) from source and bundle the whole tree.
- name: Build vendored PostgreSQL from source (aarch64)
if: matrix.arch == 'aarch64'
run: bash native-build/linux/vendor/postgres/build-postgres.sh
- name: Assemble ./model (mirrors the Dockerfile/macOS models stage)
env:
GH_TOKEN: ${{ github.token }}
run: python3 scripts/standalone/assemble_model.py
- name: Verify the assembled model/ is complete
run: python3 scripts/standalone/assemble_model.py --verify
- name: Build the packages (.deb + .rpm)
run: |
set -euo pipefail
source .venv-linux/bin/activate
python scripts/standalone/build.py --platform linux
- name: Upload .deb as a workflow artifact
uses: actions/upload-artifact@v4
with:
name: AudioMuse-AI-${{ env.ARCH }}-linux-deb
path: dist/AudioMuse-AI-${{ env.ARCH }}-linux.deb
if-no-files-found: error
- name: Upload .rpm as a workflow artifact
uses: actions/upload-artifact@v4
with:
name: AudioMuse-AI-${{ env.ARCH }}-linux-rpm
path: dist/AudioMuse-AI-${{ env.ARCH }}-linux.rpm
if-no-files-found: error
# NB: the PR-description "test build links" block is written by the
# dedicated `pr-test-link.yml` workflow (which runs after this build,
# verifies the artifacts exist, and posts the consolidated link block).
# Attach the packages to the release. Runs only for tag pushes.
release:
needs: build
if: startsWith(github.ref, 'refs/tags/v')
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Download built packages
uses: actions/download-artifact@v4
with:
path: artifacts
merge-multiple: true
- name: Attach packages to the release
uses: softprops/action-gh-release@v2
with:
files: |
artifacts/AudioMuse-AI-*.deb
artifacts/AudioMuse-AI-*.rpm
fail_on_unmatched_files: true