-
Notifications
You must be signed in to change notification settings - Fork 53
255 lines (217 loc) · 8.12 KB
/
release.yaml
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
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
name: Release
on:
push:
branches:
- main
tags:
- 'v*.*.*'
env:
TMP_LOCAL_IMAGE: localhost:5000/exein-io/pulsar
REGISTRY_IMAGE: ghcr.io/exein-io/pulsar
REGISTRY_TAG: ${{ github.ref_type == 'tag' && github.ref_name || 'dev' }}
jobs:
vendored_archive:
name: Vendored archive
runs-on: ubuntu-latest
steps:
- name: Code checkout
uses: actions/checkout@v4
- name: Create release directory
run: rsync -rv --exclude=.git . ../pulsar-${{ env.REGISTRY_TAG }}
- name: Cargo vendor
working-directory: ../pulsar-${{ env.REGISTRY_TAG }}
run: |
mkdir ../vendor-cargo-home
export CARGO_HOME=$(realpath ../vendor-cargo-home)
mkdir -p .cargo
cargo vendor >> .cargo/config.toml
- name: Create vendored source archive
working-directory: ../
id: create-archive
run: |
tar cJf pulsar-vendored-${{ env.REGISTRY_TAG }}.tar.xz pulsar-${{ env.REGISTRY_TAG }}
echo "archive_file_name=$(realpath ./pulsar-vendored-${{ env.REGISTRY_TAG }}.tar.xz)" >> $GITHUB_OUTPUT
- name: Upload archive
uses: actions/upload-artifact@v3
with:
name: binaries-${{ env.REGISTRY_TAG }}
path: ${{ steps.create-archive.outputs.archive_file_name }}
if-no-files-found: error
retention-days: 1
build:
name: Create binary
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
platform:
- target: x86_64-unknown-linux-gnu
args: "--features full --features openssl-vendored"
docker:
base-image: debian:bookworm
platform: linux/amd64
- target: x86_64-unknown-linux-musl
args: "--no-default-features --features full --features all-vendored --features tls-rustls"
- target: aarch64-unknown-linux-gnu
args: "--features full --features openssl-vendored"
docker:
base-image: debian:bookworm
platform: linux/arm64
- target: aarch64-unknown-linux-musl
args: "--no-default-features --features full --features all-vendored --features tls-rustls"
- target: riscv64gc-unknown-linux-gnu
args: "--features full --features openssl-vendored"
docker:
base-image: debian:sid
platform: linux/riscv64
steps:
- name: Code checkout
uses: actions/checkout@v4
- name: Install Rust toolchain (stable)
uses: dtolnay/rust-toolchain@stable
with:
target: ${{ matrix.platform.target }}
- name: Install cross
uses: ./.github/actions/install-cross
- name: Build Release
run: cross build --locked --target=${{ matrix.platform.target }} --bin pulsar-exec ${{ matrix.platform.args }} --release
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
if: ${{ matrix.platform.docker != null }}
- name: Prepare Docker image directory
if: ${{ matrix.platform.docker != null }}
run: |
mkdir -p /tmp/images
platform=${{ matrix.platform.target }}
echo "TARFILE=${platform//\//-}.tar" >> $GITHUB_ENV
echo "TAG=${{ env.TMP_LOCAL_IMAGE }}:${platform//\//-}" >> $GITHUB_ENV
- name: Create Docker image
uses: docker/build-push-action@v5
if: ${{ matrix.platform.docker != null }}
with:
context: "."
file: .github/docker/Dockerfile
build-args: |
BASE_IMAGE=${{ matrix.platform.docker.base-image }}
ARCH=${{ matrix.platform.target }}
platforms: ${{ matrix.platform.docker.platform }}
tags: ${{ env.TAG }}
outputs: type=docker,dest=/tmp/images/${{ env.TARFILE }}
- name: Upload Docker image
uses: actions/upload-artifact@v3
if: ${{ matrix.platform.docker != null }}
with:
name: images-${{ env.REGISTRY_TAG }}
path: /tmp/images/${{ env.TARFILE }}
if-no-files-found: error
retention-days: 1
- name: Rename binary
shell: bash
id: rename_binary
run: |
IFS='-' read -a arch <<< ${{ matrix.platform.target }}
suffix=""
if [[ "${{ matrix.platform.target }}" == *"musl"* ]]; then suffix="-static"; fi
binary_name=./target/${{ matrix.platform.target }}/release/pulsar-exec-${arch}${suffix}
mv ./target/${{ matrix.platform.target }}/release/pulsar-exec ${binary_name}
echo "binary_name=${binary_name}" >> $GITHUB_OUTPUT
- name: Upload binary
uses: actions/upload-artifact@v3
with:
name: binaries-${{ env.REGISTRY_TAG }}
path: ${{ steps.rename_binary.outputs.binary_name }}
if-no-files-found: error
retention-days: 1
create-release:
name: Create release
runs-on: ubuntu-latest
needs:
- build
- vendored_archive
steps:
- name: Download binaries
uses: actions/download-artifact@v3
with:
name: binaries-${{ env.REGISTRY_TAG }}
path: /tmp/binaries
- name: Code checkout
uses: actions/checkout@v4
- name: Create installer
run: |
installer_blueprint=.github/release-assets/pulsar-install.sh
sed "s/^PULSAR_VERSION=$/PULSAR_VERSION=${{ env.REGISTRY_TAG }}/" "$installer_blueprint" > /tmp/pulsar-install.sh
- name: Check dev release and tag existence
if: github.ref_type == 'branch'
env:
GH_TOKEN: ${{ github.token }}
run: |
export GH_PAGER=
git push origin :refs/tags/dev
if gh release view dev > /dev/null 2>&1; then
gh release delete dev -y
fi
- name: Dev release
if: github.ref_type == 'branch'
uses: ncipollo/release-action@v1
with:
name: ${{ env.REGISTRY_TAG }}
tag: ${{ env.REGISTRY_TAG }}
makeLatest: false
prerelease: true
artifacts: "/tmp/binaries/*,/tmp/pulsar-install.sh"
body: 'This is a nightly release based on main branch. Do not use for production'
- name: Release
if: github.ref_type == 'tag'
uses: ncipollo/release-action@v1
with:
name: ${{ env.REGISTRY_TAG }}
draft: true
tag: ${{ env.REGISTRY_TAG }}
artifacts: "/tmp/binaries/*"
body: |
<hr>
Check out the [changelog](https://github.com/exein-io/pulsar/blob/main/CHANGELOG.md) for details on all the changes and fixes.
docker-push:
name: Push docker multi-arch image
runs-on: ubuntu-latest
needs:
- build
services:
registry:
image: registry:2
ports:
- 5000:5000
steps:
- name: Download images
uses: actions/download-artifact@v3
with:
name: images-${{ env.REGISTRY_TAG }}
path: /tmp/images
- name: Load images
run: |
for image in /tmp/images/*.tar; do
docker load -i $image
done
- name: Push images to local registry
run: |
docker push -a ${{ env.TMP_LOCAL_IMAGE }}
- name: Log in to the Container registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Create manifest list and push
run: |
docker buildx imagetools create -t ${{ env.REGISTRY_IMAGE }}:${{ env.REGISTRY_TAG }} \
$(docker image ls --format '{{.Repository}}:{{.Tag}}' '${{ env.TMP_LOCAL_IMAGE }}' | tr '\n' ' ')
- name: Push to latest
if: github.ref_type == 'tag'
run: |
docker buildx imagetools create -t ${{ env.REGISTRY_IMAGE }}:latest \
$(docker image ls --format '{{.Repository}}:{{.Tag}}' '${{ env.TMP_LOCAL_IMAGE }}' | tr '\n' ' ')
- name: Inspect image
run: |
docker buildx imagetools inspect ${{ env.REGISTRY_IMAGE }}:${{ env.REGISTRY_TAG }}