-
Notifications
You must be signed in to change notification settings - Fork 8
172 lines (152 loc) · 5.07 KB
/
Copy pathrelease.yml
File metadata and controls
172 lines (152 loc) · 5.07 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
name: Release
on:
push:
branches:
- main
tags:
- 'v*.*.*'
workflow_dispatch:
env:
CARGO_TERM_COLOR: always
jobs:
build:
name: Build ${{ matrix.target }}
runs-on: ${{ matrix.os }}
continue-on-error: ${{ matrix.continue-on-error || false }}
permissions:
contents: read
strategy:
fail-fast: false
matrix:
include:
# Linux
- target: x86_64-unknown-linux-gnu
os: ubuntu-latest
binary_name: surreal-sync
- target: aarch64-unknown-linux-gnu
os: ubuntu-24.04-arm
binary_name: surreal-sync
- target: x86_64-unknown-linux-musl
os: ubuntu-latest
binary_name: surreal-sync
continue-on-error: true
# - target: aarch64-unknown-linux-musl
# os: ubuntu-latest
# binary_name: surreal-sync
# macOS
- target: aarch64-apple-darwin
os: macos-latest
binary_name: surreal-sync
continue-on-error: true
steps:
- name: Checkout repository
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
- name: Install Rust toolchain
run: |
rustup toolchain install
rustup target add ${{ matrix.target }}
- name: Install system build dependencies
if: contains(matrix.target, 'linux')
run: |
sudo apt-get update
sudo apt-get install -y --no-install-recommends \
build-essential cmake libssl-dev libsasl2-dev pkg-config protobuf-compiler
- name: Install cross-compilation tools
if: matrix.os == 'ubuntu-latest'
run: |
case "${{ matrix.target }}" in
x86_64-unknown-linux-musl)
sudo apt-get update
sudo apt-get install -y musl-tools
;;
aarch64-unknown-linux-musl)
sudo dpkg --add-architecture arm64
sudo apt-get update
sudo apt-get install -y musl-tools:arm64
;;
esac
- name: Build binary
run: |
FEATURES=""
case "${{ matrix.target }}" in
*-musl)
FEATURES="--features vendored-openssl"
export CC=musl-gcc
;;
esac
cargo build --release --target ${{ matrix.target }} $FEATURES
- name: Create archive
shell: bash
run: |
mkdir -p dist
if [ "${{ matrix.os }}" = "windows-latest" ]; then
# Windows
cp "target/${{ matrix.target }}/release/${{ matrix.binary_name }}" dist/
cd dist
7z a "../surreal-sync-${{ matrix.target }}.zip" "${{ matrix.binary_name }}"
cd ..
else
# Unix
cp "target/${{ matrix.target }}/release/${{ matrix.binary_name }}" dist/
cd dist
tar czf "../surreal-sync-${{ matrix.target }}.tar.gz" "${{ matrix.binary_name }}"
cd ..
fi
- name: Upload artifacts
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: surreal-sync-${{ matrix.target }}
path: |
surreal-sync-${{ matrix.target }}.tar.gz
surreal-sync-${{ matrix.target }}.zip
if-no-files-found: error
retention-days: 7
publish:
name: Publish Release
needs: build
runs-on: ubuntu-latest
if: ${{ !cancelled() && startsWith(github.ref, 'refs/tags/') }}
permissions:
contents: write
steps:
- name: Checkout repository
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
- name: Download artifacts
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
pattern: surreal-sync-*
merge-multiple: true
- name: Generate checksums
run: |
# Generate checksums only for files that exist
for file in surreal-sync-*.tar.gz surreal-sync-*.zip; do
if [ -e "$file" ]; then
sha256sum "$file" >> checksums.txt
fi
done
# Ensure at least one archive exists
if [ ! -s checksums.txt ]; then
echo "Error: No archives found to generate checksums"
exit 1
fi
echo "Generated checksums for:"
cat checksums.txt
- name: Create GitHub Release
if: startsWith(github.ref, 'refs/tags/')
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
TAG="${GITHUB_REF#refs/tags/}"
# Collect all available archives
ARCHIVES=""
for file in surreal-sync-*.tar.gz surreal-sync-*.zip checksums.txt; do
if [ -e "$file" ]; then
ARCHIVES="$ARCHIVES $file"
fi
done
echo "Publishing release $TAG with artifacts:"
echo "$ARCHIVES"
gh release create "$TAG" \
--title "Release $TAG" \
--notes "Release $TAG" \
$ARCHIVES