-
Notifications
You must be signed in to change notification settings - Fork 272
206 lines (189 loc) · 8.21 KB
/
Copy pathrelease.yml
File metadata and controls
206 lines (189 loc) · 8.21 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
199
200
201
202
203
204
205
206
name: Build-n-Release
permissions:
contents: write
on:
workflow_dispatch:
inputs:
ref_name:
description: Release Version
required: true
releaseVersion:
description: "the release version of the build"
type: string
default: ''
required: false
release:
required: true
type: boolean
release:
types: [published]
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
goos: [linux]
goarch: [amd64, arm64]
steps:
- uses: actions/checkout@v5
with:
submodules: true
- name: Get current date
if: inputs.releaseVersion == ''
id: date
uses: Kaven-Universe/github-action-current-date-time@v1
with:
format: "YYYYMMDDHHmmss"
- name: Set release date
run: |
echo "RELEASE_DATE=${{ inputs.releaseVersion || steps.date.outputs.time }}" >> $GITHUB_ENV
- name: Install build requirements
run: |
sudo apt update && sudo apt install -y openssl ca-certificates libluajit-5.1-dev
- name: Set up Go
uses: actions/setup-go@v6
with:
go-version-file: src/go.mod
cache-dependency-path: src/go.sum
- name: Set up Node.js
uses: actions/setup-node@v5
with:
node-version: 22
- name: Build frontend
run: |
cd src/ui && npm ci && npm run build
- name: Set up cross-compilation for ${{ matrix.goarch }}
run: |
echo "GOARCH=${{ matrix.goarch }}" >> $GITHUB_ENV
echo "GOOS=${{ matrix.goos }}" >> $GITHUB_ENV
if [ "${{ matrix.goarch }}" == "arm64" ]; then
sudo dpkg --add-architecture arm64
CODENAME=$(lsb_release -cs)
# Add arm64 repos (ports.ubuntu.com)
if [ -f /etc/apt/sources.list.d/ubuntu.sources ]; then
sudo sed -i '/^Types:/i Architectures: amd64' /etc/apt/sources.list.d/ubuntu.sources
sudo tee /etc/apt/sources.list.d/arm64-ports.sources <<EOF
Types: deb
URIs: http://ports.ubuntu.com/ubuntu-ports/
Suites: ${CODENAME} ${CODENAME}-updates
Components: main restricted universe multiverse
Architectures: arm64
Signed-By: /usr/share/keyrings/ubuntu-archive-keyring.gpg
EOF
else
sudo sed -i 's/^deb /deb [arch=amd64] /' /etc/apt/sources.list
echo "deb [arch=arm64] http://ports.ubuntu.com/ubuntu-ports/ ${CODENAME} main restricted universe multiverse" | sudo tee /etc/apt/sources.list.d/arm64-ports.list
echo "deb [arch=arm64] http://ports.ubuntu.com/ubuntu-ports/ ${CODENAME}-updates main restricted universe multiverse" | sudo tee -a /etc/apt/sources.list.d/arm64-ports.list
fi
sudo apt update
sudo apt install -y gcc-aarch64-linux-gnu g++-aarch64-linux-gnu libluajit-5.1-dev:arm64
echo "CC=aarch64-linux-gnu-gcc" >> $GITHUB_ENV
echo "CXX=aarch64-linux-gnu-g++" >> $GITHUB_ENV
fi
- name: Set version
run: |
echo "VERSION=${{ (github.ref_name == 'master' && github.event_name == 'workflow_dispatch') && github.event.inputs.ref_name || github.ref_name }}" >> $GITHUB_ENV
- name: Compile homer-core ${{ matrix.goarch }}
env:
CGO_ENABLED: 1
GOARCH: ${{ matrix.goarch }}
GOOS: ${{ matrix.goos }}
run: |
echo "NOW=$(date +'%Y%m%dT%H%M%S')" >> $GITHUB_ENV
GIT_COMMIT=$(git rev-parse --short HEAD)
BUILD_DATE=$(date +%Y-%m-%d)
BUILD_TIME=$(date +%H:%M:%S)
# Static link dir: libstdc++.a (amd64 DuckDB) + libluajit-5.1.a (both arch) so
# CGO resolves archives; -Wl,-Bstatic/-Bdynamic pins only LuaJIT as static.
STATIC_LINK_DIR="$(pwd)/.static-cgo-link"
mkdir -p "${STATIC_LINK_DIR}"
if [ "${{ matrix.goarch }}" == "amd64" ]; then
LIBSTDCXX_A=$(gcc --print-file-name=libstdc++.a 2>/dev/null)
if [ -n "${LIBSTDCXX_A}" ] && [ -f "${LIBSTDCXX_A}" ]; then
ln -sf "${LIBSTDCXX_A}" "${STATIC_LINK_DIR}/libstdc++.a"
fi
LUAJIT_A=$(gcc --print-file-name=libluajit-5.1.a 2>/dev/null)
EXTLD="-extldflags '-static-libgcc -ldl'"
else
LUAJIT_A=$(aarch64-linux-gnu-gcc --print-file-name=libluajit-5.1.a 2>/dev/null)
EXTLD=""
fi
if [ -z "${LUAJIT_A}" ] || [ ! -f "${LUAJIT_A}" ]; then
echo "ERROR: libluajit-5.1.a not found for ${{ matrix.goarch }} (install libluajit-5.1-dev)" >&2
exit 1
fi
ln -sf "${LUAJIT_A}" "${STATIC_LINK_DIR}/libluajit-5.1.a"
export CGO_LDFLAGS="-L${STATIC_LINK_DIR} -Wl,-Bstatic -lluajit-5.1 -Wl,-Bdynamic"
LDFLAGS="-s -w -X main.VERSION_APPLICATION=${{ env.VERSION }} -X main.BuildDate=${BUILD_DATE} -X main.BuildTime=${BUILD_TIME} -X main.GitCommit=${GIT_COMMIT} ${EXTLD}"
cd src && go build -ldflags "${LDFLAGS}" -o ../homer && cd ..
cp homer homer-core_${{ matrix.goarch }}
if [ "${{ matrix.goarch }}" == "amd64" ]; then
if ldd homer 2>/dev/null | grep -q libluajit; then
echo "ERROR: homer still links libluajit dynamically" >&2
ldd homer || true
exit 1
fi
fi
- name: Apply glibc polyfill
if: matrix.goarch == 'amd64'
run: |
set -euo pipefail
# Image entrypoint uses "polyfill ... || echo" which masks failures; also
# needs GITHUB_OUTPUT set when not running inside GitHub's action runner.
docker run --rm \
-e GITHUB_OUTPUT=/dev/null \
-e INPUT_TARGET=/work/homer \
-e INPUT_GLIBC=2.34 \
-e INPUT_INSTALL= \
-v "${{ github.workspace }}:/work" \
ghcr.io/lmangani/polyfill-glibc-action:latest
- name: Verify glibc polyfill (amd64)
if: matrix.goarch == 'amd64'
run: |
set -euo pipefail
if objdump -T homer | grep -E '@GLIBC_2\.(3[5-9]|[4-9][0-9])'; then
echo "::error::homer still references GLIBC > 2.34 after polyfill (objdump -T)" >&2
objdump -T homer | grep GLIBC | sort -u || true
exit 1
fi
echo "OK: no GLIBC > 2.34 versioned symbols in dynamic table"
- name: Sync homer-core release binary after polyfill
if: matrix.goarch == 'amd64'
run: cp homer homer-core_${{ matrix.goarch }}
- name: get NFPM
if: ${{ github.event_name == 'release' || (github.event_name == 'workflow_dispatch' && inputs.release) }}
run: |
wget -qO- https://github.com/goreleaser/nfpm/releases/download/v2.41.1/nfpm_2.41.1_Linux_x86_64.tar.gz | tar --directory ./ -xz nfpm
chmod +x nfpm
- name: Create Packages ${{ matrix.goarch }}
if: ${{ github.event_name == 'release' || (github.event_name == 'workflow_dispatch' && inputs.release) }}
env:
VERSION: ${{ env.VERSION }}
PACKAGE: "homer-core"
RELEASE: ${{ env.VERSION }}
ARCH: ${{ matrix.goarch }}
OS: ${{ matrix.goos }}
run: |
set -euo pipefail
export VERSION="${VERSION#v}"
if [ "${{ matrix.goarch }}" = "amd64" ]; then export EXT_PLATFORM=linux_amd64; else export EXT_PLATFORM=linux_arm64; fi
export DUCKDB_VERSION=v1.5.5
./scripts/download_duckdb_extensions.sh "$EXT_PLATFORM"
sed -i 's/^arch: ".*"/arch: "${{ matrix.goarch }}"/' homer-core_workflow.yaml
DUCKDB_VERSION="$DUCKDB_VERSION" EXT_PLATFORM="$EXT_PLATFORM" VERSION="$VERSION" \
./nfpm pkg --config homer-core_workflow.yaml --target "./${PACKAGE}_${RELEASE}_${ARCH}.deb"
DUCKDB_VERSION="$DUCKDB_VERSION" EXT_PLATFORM="$EXT_PLATFORM" VERSION="$VERSION" \
./nfpm pkg --config homer-core_workflow.yaml --target "./${PACKAGE}_${RELEASE}_${ARCH}.rpm"
- name: Upload release
if: ${{ github.event_name == 'release' || (github.event_name == 'workflow_dispatch' && inputs.release) }}
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ env.VERSION }}
name: ${{ env.VERSION }}
draft: false
prerelease: false
overwrite_files: true
files: |
homer-core_${{ matrix.goarch }}
homer-core_${{ env.VERSION }}_${{ matrix.goarch }}.deb
homer-core_${{ env.VERSION }}_${{ matrix.goarch }}.rpm