-
Notifications
You must be signed in to change notification settings - Fork 0
213 lines (184 loc) · 7.61 KB
/
release.yml
File metadata and controls
213 lines (184 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
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
name: Release
on:
push:
branches:
- main
- development
tags:
- 'v*'
workflow_dispatch:
jobs:
build:
name: Build ${{ matrix.target }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
# macOS native builds
- os: macos-13
target: x86_64-apple-darwin
name: macos-x64
- os: macos-latest
target: aarch64-apple-darwin
name: macos-arm64
# Linux native builds
- os: ubuntu-latest
target: x86_64-unknown-linux-gnu
name: linux-x64
- os: ubuntu-latest
target: aarch64-unknown-linux-gnu
name: linux-arm64
use_cross: true
# Windows native build
- os: windows-latest
target: x86_64-pc-windows-msvc
name: windows-x64
# ARM Linux build (Raspberry Pi)
- os: ubuntu-latest
target: armv7-unknown-linux-gnueabihf
name: pi-armv7
use_cross: true
# Embedded build (only embedded crate)
- os: ubuntu-latest
target: thumbv7m-none-eabi
name: embedded-arm
use_cross: true
embedded_only: true
steps:
- uses: actions/checkout@v4
- name: Read version from VERSION file
id: version
run: |
if [ -f VERSION ]; then
VERSION=$(cat VERSION | tr -d '\n\r')
echo "version=$VERSION" >> $GITHUB_OUTPUT
else
echo "version=0.1.0" >> $GITHUB_OUTPUT
fi
shell: bash
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
- name: Install dependencies (macOS)
if: matrix.os == 'macos-latest' || matrix.os == 'macos-13'
run: brew install protobuf pkg-config
- name: Install dependencies (Linux x64 with D-Bus BLE)
if: matrix.os == 'ubuntu-latest' && matrix.target == 'x86_64-unknown-linux-gnu'
run: |
sudo apt update
sudo apt install -y \
build-essential \
pkg-config \
protobuf-compiler \
libbluetooth-dev \
libdbus-1-dev \
libdbus-glib-1-dev \
libudev-dev
- name: Install dependencies (ARM Linux with direct HCI BLE)
if: matrix.os == 'ubuntu-latest' && matrix.use_cross == true && matrix.embedded_only != true
run: |
sudo apt update
sudo apt install -y \
build-essential \
pkg-config \
protobuf-compiler
- name: Install basic dependencies (Embedded)
if: matrix.embedded_only == true
run: |
sudo apt update
sudo apt install -y build-essential
- name: Install dependencies (Windows)
if: matrix.os == 'windows-latest'
run: choco install protoc
- name: Install cross
if: matrix.use_cross == true
run: cargo install cross --git https://github.com/cross-rs/cross
- name: Set up environment for cross-compilation
if: matrix.use_cross == true && matrix.embedded_only != true
run: |
# Download and install protoc for cross-compilation
PROTOC_VERSION=21.12
curl -LO https://github.com/protocolbuffers/protobuf/releases/download/v${PROTOC_VERSION}/protoc-${PROTOC_VERSION}-linux-x86_64.zip
unzip protoc-${PROTOC_VERSION}-linux-x86_64.zip -d protoc
sudo cp protoc/bin/protoc /usr/local/bin/
sudo chmod +x /usr/local/bin/protoc
# Set environment variables for cross-compilation
echo "PROTOC=/usr/local/bin/protoc" >> $GITHUB_ENV
echo "PKG_CONFIG_ALLOW_CROSS=1" >> $GITHUB_ENV
- name: Build embedded only
if: matrix.embedded_only == true
run: cross build --release --target ${{ matrix.target }} -p metamesh-embedded
- name: Build with cross
if: matrix.use_cross == true && matrix.embedded_only != true
env:
PROTOC: /usr/local/bin/protoc
PKG_CONFIG_ALLOW_CROSS: 1
run: cross build --release --target ${{ matrix.target }}
- name: Build with cargo
if: matrix.use_cross != true
run: cargo build --release --target ${{ matrix.target }}
- name: Package (Unix)
if: matrix.os != 'windows-latest'
run: |
mkdir -p dist
if [ "${{ matrix.embedded_only }}" = "true" ]; then
cp target/${{ matrix.target }}/release/libmetamesh_embedded.rlib dist/ 2>/dev/null || echo "embedded lib not found"
echo "Embedded library for ${{ matrix.target }}" > dist/README.txt
else
cp target/${{ matrix.target }}/release/metamesh-daemon dist/ 2>/dev/null || echo "daemon not found"
cp target/${{ matrix.target }}/release/metamesh-client dist/ 2>/dev/null || echo "client not found"
fi
tar -czf metamesh-${{ matrix.name }}-v${{ steps.version.outputs.version }}.tar.gz -C dist .
- name: Package (Windows)
if: matrix.os == 'windows-latest'
run: |
mkdir dist
copy target\${{ matrix.target }}\release\metamesh-daemon.exe dist\ 2>nul || echo "daemon not found"
copy target\${{ matrix.target }}\release\metamesh-client.exe dist\ 2>nul || echo "client not found"
Compress-Archive -Path dist\* -DestinationPath metamesh-${{ matrix.name }}-v${{ steps.version.outputs.version }}.zip
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: metamesh-${{ matrix.name }}-v${{ steps.version.outputs.version }}
path: metamesh-${{ matrix.name }}-v${{ steps.version.outputs.version }}.*
release:
needs: build
runs-on: ubuntu-latest
if: ${{ !contains(needs.build.result, 'failure') }}
steps:
- uses: actions/checkout@v4
- name: Read version from VERSION file
id: version
run: |
if [ -f VERSION ]; then
VERSION=$(cat VERSION | tr -d '\n\r')
echo "version=$VERSION" >> $GITHUB_OUTPUT
else
echo "version=0.1.0" >> $GITHUB_OUTPUT
fi
- name: Download all artifacts
uses: actions/download-artifact@v4
- name: Delete existing release (if exists)
run: |
gh release delete v${{ steps.version.outputs.version }} --yes || echo "Release doesn't exist"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Create Release
uses: softprops/action-gh-release@v1
with:
tag_name: v${{ steps.version.outputs.version }}
name: MetaMesh v${{ steps.version.outputs.version }}
files: |
metamesh-macos-x64-v${{ steps.version.outputs.version }}/metamesh-macos-x64-v${{ steps.version.outputs.version }}.tar.gz
metamesh-macos-arm64-v${{ steps.version.outputs.version }}/metamesh-macos-arm64-v${{ steps.version.outputs.version }}.tar.gz
metamesh-linux-x64-v${{ steps.version.outputs.version }}/metamesh-linux-x64-v${{ steps.version.outputs.version }}.tar.gz
metamesh-linux-arm64-v${{ steps.version.outputs.version }}/metamesh-linux-arm64-v${{ steps.version.outputs.version }}.tar.gz
metamesh-windows-x64-v${{ steps.version.outputs.version }}/metamesh-windows-x64-v${{ steps.version.outputs.version }}.zip
metamesh-pi-armv7-v${{ steps.version.outputs.version }}/metamesh-pi-armv7-v${{ steps.version.outputs.version }}.tar.gz
metamesh-embedded-arm-v${{ steps.version.outputs.version }}/metamesh-embedded-arm-v${{ steps.version.outputs.version }}.tar.gz
generate_release_notes: true
prerelease: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}