Skip to content

Commit d3de1e0

Browse files
committed
[IMP] Use github actions to build release instead of cross
1 parent d18fae3 commit d3de1e0

File tree

2 files changed

+204
-0
lines changed

2 files changed

+204
-0
lines changed
Lines changed: 199 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,199 @@
1+
name: Build Release
2+
3+
on:
4+
push:
5+
tags:
6+
- '[0-9]+.[0-9]+.[0-9]+'
7+
8+
env:
9+
CARGO_TERM_COLOR: always
10+
11+
jobs:
12+
build:
13+
name: Build for ${{ matrix.os }} ${{ matrix.arch }}
14+
runs-on: ${{ matrix.os }}
15+
strategy:
16+
matrix:
17+
include:
18+
- os: ubuntu-22.04
19+
arch: x86_64
20+
name: linux-x86_64
21+
target: x86_64-unknown-linux-gnu
22+
- os: ubuntu-22.04
23+
arch: aarch64
24+
name: linux-aarch64
25+
target: aarch64-unknown-linux-gnu
26+
- os: ubuntu-22.04
27+
arch: x86_64
28+
name: alpine-x86_64
29+
target: x86_64-unknown-linux-musl
30+
- os: ubuntu-22.04
31+
arch: aarch64
32+
name: alpine-aarch64
33+
target: aarch64-unknown-linux-musl
34+
- os: macos-latest
35+
arch: x86_64
36+
name: darwin-x86_64
37+
target: x86_64-apple-darwin
38+
- os: macos-latest
39+
arch: aarch64
40+
name: darwin-aarch64
41+
target: aarch64-apple-darwin
42+
- os: windows-latest
43+
arch: x86_64
44+
name: win32-x86_64
45+
target: x86_64-pc-windows-msvc
46+
- os: windows-latest
47+
arch: aarch64
48+
name: win32-aarch64
49+
target: aarch64-pc-windows-msvc
50+
51+
steps:
52+
- name: Checkout repository
53+
uses: actions/checkout@v4
54+
55+
- name: Install Rust
56+
uses: actions-rs/toolchain@v1
57+
with:
58+
toolchain: stable
59+
override: true
60+
target: ${{ matrix.target }}
61+
62+
- name: Install AArch64 cross-linker
63+
if: matrix.target == 'aarch64-unknown-linux-gnu'
64+
run: |
65+
sudo apt-get update
66+
sudo apt-get install -y gcc-aarch64-linux-gnu
67+
68+
- name: Install dependencies (Linux MUSL)
69+
if: matrix.target == 'x86_64-unknown-linux-musl'
70+
run: |
71+
sudo apt-get update
72+
sudo apt-get install -y musl-tools
73+
74+
- name: Install dependencies (Linux MUSL ARM64)
75+
if: matrix.target == 'aarch64-unknown-linux-musl'
76+
run: |
77+
sudo apt-get update
78+
sudo apt-get install -y musl-tools gcc-aarch64-linux-gnu
79+
80+
- name: Build
81+
working-directory: server
82+
run: cargo build --bin odoo_ls_server --release --target ${{ matrix.target }}
83+
84+
- name: Build schema
85+
if: matrix.target == 'x86_64-unknown-linux-gnu'
86+
working-directory: server
87+
run: cargo run --bin print_config_schema --release --target ${{ matrix.target }}
88+
89+
- name: Upload binary
90+
shell: bash
91+
run: |
92+
mkdir -p artifacts/${{ matrix.name }}
93+
BIN_NAME=odoo_ls_server
94+
if [[ "${{ matrix.os }}" == "windows-latest" ]]; then
95+
cp server/target/${{ matrix.target }}/release/${BIN_NAME}.exe artifacts/${{ matrix.name }}/
96+
cp server/target/${{ matrix.target }}/release/${BIN_NAME}.pdb artifacts/${{ matrix.name }}/ || true
97+
else
98+
cp -p server/target/${{ matrix.target }}/release/${BIN_NAME} artifacts/${{ matrix.name }}/
99+
fi
100+
if [[ "${{ matrix.target }}" == "x86_64-unknown-linux-gnu" ]]; then
101+
cp server/config_schema.json artifacts/
102+
fi
103+
continue-on-error: false
104+
105+
- name: Upload binaries
106+
uses: actions/upload-artifact@v4
107+
with:
108+
name: ${{ matrix.name }}
109+
path: artifacts/${{ matrix.name }}
110+
111+
- name: Upload config schema
112+
if: matrix.target == 'x86_64-unknown-linux-gnu'
113+
uses: actions/upload-artifact@v4
114+
with:
115+
name: config_schema
116+
path: artifacts/config_schema.json
117+
118+
release:
119+
name: Create GitHub Release
120+
needs: build
121+
runs-on: ubuntu-latest
122+
steps:
123+
- name: Checkout repository
124+
uses: actions/checkout@v4
125+
126+
- name: Download all artifacts
127+
uses: actions/download-artifact@v4
128+
with:
129+
path: ./artifacts
130+
131+
- name: Extract version info
132+
id: version
133+
run: |
134+
TAG="${GITHUB_REF#refs/tags/}"
135+
MINOR=$(echo "$TAG" | cut -d. -f2)
136+
if [ $((MINOR % 2)) -eq 1 ]; then
137+
echo "prerelease=true" >> $GITHUB_OUTPUT
138+
echo "title=$TAG - Beta" >> $GITHUB_OUTPUT
139+
else
140+
echo "prerelease=false" >> $GITHUB_OUTPUT
141+
echo "title=$TAG" >> $GITHUB_OUTPUT
142+
fi
143+
144+
- name: Extract changelog entry
145+
id: changelog
146+
run: |
147+
TAG="${GITHUB_REF_NAME}"
148+
awk "/^## \\[$TAG\\]/ {flag=1; next} /^## \\[/ {flag=0} flag {print}" changelog.md > RELEASE_NOTES.md
149+
150+
- name: Ensure executables have +x
151+
shell: bash
152+
run: |
153+
for dir in artifacts/*; do
154+
[ -d "$dir" ] || continue
155+
for file in "$dir"/*; do
156+
case "$file" in
157+
*.exe|*.pdb|*.json|*.zip)
158+
;;
159+
*)
160+
chmod +x "$file"
161+
;;
162+
esac
163+
done
164+
done
165+
166+
- name: Zip all artifacts
167+
shell: bash
168+
run: |
169+
for dir in artifacts/*; do
170+
[ -d "$dir" ] || continue
171+
name=$(basename "$dir")
172+
if [ "$name" = "config_schema" ]; then
173+
continue
174+
fi
175+
TAG="${GITHUB_REF_NAME}"
176+
case "$name" in
177+
win32-*)
178+
zip -j artifacts/odoo-${name}-${TAG}.zip "$dir"/*
179+
;;
180+
*) # tar.gz to keep permissions
181+
tar -czf artifacts/odoo-${name}-${TAG}.tar.gz -C "$dir" .
182+
;;
183+
esac
184+
done
185+
186+
- name: Create Release
187+
uses: softprops/action-gh-release@v2
188+
with:
189+
name: ${{ steps.version.outputs.title }}
190+
tag_name: ${{ github.ref_name }}
191+
prerelease: ${{ steps.version.outputs.prerelease }}
192+
body_path: RELEASE_NOTES.md
193+
files: |
194+
./artifacts/*.zip
195+
./artifacts/*.tar.gz
196+
./artifacts/config_schema/config_schema.json
197+
env:
198+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
199+

server/.cargo/config.toml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
[target.aarch64-unknown-linux-gnu]
2+
linker = "aarch64-linux-gnu-gcc"
3+
4+
[target.aarch64-unknown-linux-musl]
5+
linker = "aarch64-linux-gnu-gcc"

0 commit comments

Comments
 (0)