-
Notifications
You must be signed in to change notification settings - Fork 0
123 lines (103 loc) · 3.75 KB
/
release.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
name: Build and upload release binaries
run-name: Build release @ ${{ github.event.release.tag_name }}
on:
release:
types:
- released
env:
APP: bin-cpuflags-x86
VERSION: ${{ github.event.release.tag_name }}
UPLOAD_URL: ${{ github.event.release.upload_url }}
RUSTUP_TOOLCHAIN: stable
CARGO_TERM_COLOR: always
jobs:
release-linux:
runs-on: ubuntu-latest
env:
CARGO_BUILD_TARGET: x86_64-unknown-linux-musl
steps:
- uses: actions/checkout@v4
- name: Prepare
run: |
mkdir ".cargo"
cp -pv ".github/workflows/config.toml" -t ".cargo"
rustup target add "${CARGO_BUILD_TARGET}"
cargo fetch -v --locked
# - name: Run tests
# run: cargo test -v --frozen
- name: Build
run: cargo build -v --frozen --release
- name: Upload archive
run: |
cd "target/${CARGO_BUILD_TARGET}/release"
ARCHIVE="${APP}-${VERSION}-linux-x86_64.tar.xz"
tar -cv "${APP}" | xz -cz -9e -T1 - > "${ARCHIVE}"
URL="${UPLOAD_URL%'{'*}"
curl -L -X POST \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
-H "X-GitHub-Api-Version: 2022-11-28" \
-H "Content-Type: application/x-tar" \
--fail-with-body --connect-timeout 10 --retry 3 \
--data-binary "@${ARCHIVE}" \
"${URL}?name=${ARCHIVE}"
release-windows:
runs-on: windows-latest
env:
CARGO_BUILD_TARGET: x86_64-pc-windows-msvc
steps:
- uses: actions/checkout@v4
- name: Prepare
run: |
New-Item -Name ".cargo" -ItemType "directory"
Copy-Item ".github\workflows\config.toml" -Destination ".cargo\"
rustup target add "${Env:CARGO_BUILD_TARGET}"
cargo fetch -v --locked
# - name: Run tests
# run: cargo test -v --frozen
- name: Build
run: cargo build -v --frozen --release
- name: Upload archive
run: |
cd "target\${Env:CARGO_BUILD_TARGET}\release"
$Archive = "${Env:APP}-${Env:VERSION}-windows-x64.zip"
7z a -tzip -mx=9 -sse -ssp -- "${Archive}" "${Env:APP}.exe"
$Url = ${Env:UPLOAD_URL} -replace '{.*',''
curl -L -X POST `
-H "Accept: application/vnd.github+json" `
-H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" `
-H "X-GitHub-Api-Version: 2022-11-28" `
-H "Content-Type: application/zip" `
--fail-with-body --connect-timeout 10 --retry 3 `
--data-binary "@${Archive}" `
"${Url}?name=${Archive}"
release-macos:
runs-on: macos-latest
env:
CARGO_BUILD_TARGET: x86_64-apple-darwin
steps:
- uses: actions/checkout@v4
- name: Prepare
run: |
mkdir ".cargo"
cp -pv ".github/workflows/config.toml" ".cargo/"
rustup target add "${CARGO_BUILD_TARGET}"
cargo fetch -v --locked
# - name: Run tests
# run: cargo test -v --frozen
- name: Build
run: cargo build -v --frozen --release
- name: Upload archive
run: |
cd "target/${CARGO_BUILD_TARGET}/release"
ARCHIVE="${APP}-${VERSION}-macos-x86_64.tar.xz"
bsdtar -cv "${APP}" | xz -cz -9e -T1 - > "${ARCHIVE}"
URL="${UPLOAD_URL%'{'*}"
curl -L -X POST \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
-H "X-GitHub-Api-Version: 2022-11-28" \
-H "Content-Type: application/x-tar" \
--fail-with-body --connect-timeout 10 --retry 3 \
--data-binary "@${ARCHIVE}" \
"${URL}?name=${ARCHIVE}"