-
Notifications
You must be signed in to change notification settings - Fork 136
175 lines (163 loc) · 6.64 KB
/
pre_release.yml
File metadata and controls
175 lines (163 loc) · 6.64 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
name: pre release
on:
push:
branches:
- ignore
workflow_dispatch:
permissions:
contents: read
jobs:
build:
name: Build ${{ matrix.target }}
strategy:
fail-fast: false
matrix:
target:
- x86_64-unknown-linux-musl
- x86_64-unknown-linux-gnu
- x86_64-apple-darwin
- x86_64-pc-windows-msvc
- i686-pc-windows-msvc
- aarch64-pc-windows-msvc
- aarch64-apple-darwin
allocator: [null]
include:
- target: x86_64-unknown-linux-musl
os: ubuntu-latest
name: rnacos-x86_64-unknown-linux-musl-${GITHUB_REF#refs/*/}.tar.gz
- target: x86_64-unknown-linux-gnu
os: ubuntu-latest
name: rnacos-x86_64-unknown-linux-gnu-${GITHUB_REF#refs/*/}.tar.gz
- target: x86_64-apple-darwin
os: macos-13
name: rnacos-x86_64-apple-darwin-${GITHUB_REF#refs/*/}.tar.gz
- target: x86_64-pc-windows-msvc
os: windows-latest
name: rnacos-x86_64-pc-windows-msvc-${GITHUB_REF#refs/*/}.zip
- target: i686-pc-windows-msvc
os: windows-latest
name: rnacos-i686-pc-windows-msvc-${GITHUB_REF#refs/*/}.zip
- target: aarch64-pc-windows-msvc
os: windows-latest
name: rnacos-aarch64-pc-windows-msvc-${GITHUB_REF#refs/*/}.zip
- target: aarch64-apple-darwin
os: macos-latest
name: rnacos-aarch64-apple-darwin-${GITHUB_REF#refs/*/}.tar.gz
- target: x86_64-unknown-linux-musl
allocator: mimalloc
os: ubuntu-latest
name: rnacos-x86_64-unknown-linux-musl-mimalloc-${GITHUB_REF#refs/*/}.tar.gz
runs-on: ${{ matrix.os }}
steps:
# Largely inspired by https://github.com/starship/starship/blob/35a0a20f5c4fea6a08e1b91ff631b089eef8fc50/.github/workflows/deploy.yml
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
- name: Install musl tools
if: matrix.target == 'x86_64-unknown-linux-musl'
run: sudo apt-get install -y musl-tools
# Install gnu-tar because BSD tar is buggy
# https://github.com/actions/cache/issues/403
- name: Install GNU tar (macOS)
if: matrix.os == 'macos-latest'
run: |
brew install gnu-tar
echo "/usr/local/opt/gnu-tar/libexec/gnubin" >> $GITHUB_PATH
- name: Build default allocator
if: ${{ matrix.allocator != 'mimalloc' && matrix.target !='x86_64-unknown-linux-musl' }}
run: |
cargo build --release
- name: Build default musl
if: ${{ matrix.allocator != 'mimalloc' && matrix.target =='x86_64-unknown-linux-musl' }}
run: |
cargo build --release --target ${{ matrix.target }}
- name: Build with mimalloc
if: matrix.allocator == 'mimalloc'
run: |
cargo build --release --target ${{ matrix.target }} --features mimalloc
- name: Archive binary (windows)
if: matrix.os == 'windows-latest'
run: |
cd target/release
cp ../../doc/conf/.env.example .env
7z a ../../${{ matrix.name }} rnacos.exe .env
cd -
- name: Archive binary (linux and macOS)
if: ${{ matrix.os != 'windows-latest' && matrix.target !='x86_64-unknown-linux-musl' }}
run: |
cd target/release
cp ../../doc/conf/.env.example .env
tar czvf ../../${{ matrix.name }} rnacos .env
cd -
echo ${{ matrix.name }}
echo ${GITHUB_REF#refs/*/}
- name: Archive binary (linux-musl)
if: matrix.target =='x86_64-unknown-linux-musl'
run: |
# 注意,下面进入了三级目录,与上面两个打包操作路径不同
cd target/x86_64-unknown-linux-musl/release
cp ../../../doc/conf/.env.example .env
tar czvf ../../../${{ matrix.name }} rnacos .env
cd -
echo ${{ matrix.name }}
echo ${GITHUB_REF#refs/*/}
- name: Upload binary artifacts
uses: actions/upload-artifact@v4
with:
name: binaries-${{ matrix.target }}${{ matrix.allocator && format('-{0}', matrix.allocator) || '' }}
path: |
*.tar.gz
*.zip
cross-build:
name: Build ${{ matrix.platform.target }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
platform:
- target: "aarch64-unknown-linux-musl"
image: "rust-musl-cross:aarch64-musl"
name: rnacos-aarch64-unknown-linux-musl-${GITHUB_REF#refs/*/}.tar.gz
allocator: ""
- target: "aarch64-unknown-linux-musl"
image: "rust-musl-cross:aarch64-musl"
name: rnacos-aarch64-unknown-linux-musl-mimalloc-${GITHUB_REF#refs/*/}.tar.gz
allocator: "mimalloc"
- target: "loongarch64-unknown-linux-musl"
image: "rust-musl-cross:loongarch64-musl"
name: rnacos-loongarch64-unknown-linux-musl-${GITHUB_REF#refs/*/}.tar.gz
allocator: ""
- target: "loongarch64-unknown-linux-musl"
image: "rust-musl-cross:loongarch64-musl"
name: rnacos-loongarch64-unknown-linux-musl-mimalloc-${GITHUB_REF#refs/*/}.tar.gz
allocator: "mimalloc"
container:
image: docker://ghcr.io/rust-cross/${{ matrix.platform.image }}
env:
RUSTUP_HOME: /root/.rustup
CARGO_HOME: /root/.cargo
steps:
- uses: actions/checkout@v4
- run: rustup target add --toolchain stable ${{ matrix.platform.target }}
if: matrix.platform.target != 'powerpc64le-unknown-linux-musl' && matrix.platform.target != 's390x-unknown-linux-gnu'
- name: Build default
if: matrix.platform.allocator != 'mimalloc'
run: |
cargo build --release --target ${{ matrix.platform.target }}
- name: Build with mimalloc
if: matrix.platform.allocator == 'mimalloc'
run: |
cargo build --release --target ${{ matrix.platform.target }} --features mimalloc
- name: Archive binary
run: |
cp doc/conf/.env.example target/${{ matrix.platform.target }}/release/.env
tar czvf ${{ matrix.platform.name }} -C target/${{ matrix.platform.target }}/release rnacos .env
echo ${{ matrix.platform.name }}
echo ${GITHUB_REF#refs/*/}
- name: Upload binary artifacts
uses: actions/upload-artifact@v4
with:
name: binaries-${{ matrix.platform.target}}-${{ matrix.platform.allocator && format('-{0}', matrix.platform.allocator) || '' }}
path: |
*.tar.gz