-
Notifications
You must be signed in to change notification settings - Fork 102
150 lines (136 loc) · 4.81 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
name: release
on:
push:
tags: [ v*.*.* ]
jobs:
test:
name: Test
runs-on: ${{ matrix.job.os }}
timeout-minutes: 15
strategy:
matrix:
job:
- target: x86_64-unknown-linux-gnu
os: ubuntu-latest
flags: --features=native-tls
- target: x86_64-unknown-linux-gnu
os: ubuntu-latest
flags: --no-default-features --features=native-tls,online-tests # disables rustls
- target: x86_64-apple-darwin
os: macos-13
flags: --features=native-tls
- target: aarch64-apple-darwin
os: macos-14
flags: --features=native-tls
- target: x86_64-pc-windows-msvc
os: windows-latest
flags: --features=native-tls
- target: x86_64-unknown-linux-musl
os: ubuntu-latest
use-cross: true
- target: aarch64-unknown-linux-musl
os: ubuntu-latest
use-cross: true
flags: -- --test-threads=4
- target: arm-unknown-linux-gnueabihf
os: ubuntu-latest
use-cross: true
flags: -- --test-threads=4
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@master
with:
toolchain: 1.74.0 # minimum supported rust version
targets: ${{ matrix.job.target }}
- uses: ClementTsang/[email protected]
with:
use-cross: ${{ !!matrix.job.use-cross }}
command: test
args: --target ${{ matrix.job.target }} ${{ matrix.job.flags }}
deploy:
name: Deploy
needs: [ test ]
runs-on: ${{ matrix.job.os }}
strategy:
matrix:
job:
- os: ubuntu-latest
target: aarch64-unknown-linux-musl
binutils: aarch64-linux-gnu
use-cross: true
- os: ubuntu-latest
target: arm-unknown-linux-gnueabihf
binutils: arm-linux-gnueabihf
use-cross: true
- os: ubuntu-latest
target: x86_64-unknown-linux-musl
use-cross: true
- os: macos-13
target: x86_64-apple-darwin
flags: --features=native-tls
- os: macos-14
target: aarch64-apple-darwin
flags: --features=native-tls
- os: windows-latest
target: x86_64-pc-windows-msvc
flags: --features=native-tls
rustflags: -C target-feature=+crt-static
steps:
- uses: actions/checkout@v4
- name: Set RUSTFLAGS env variable
if: matrix.job.rustflags
shell: bash
run: echo "RUSTFLAGS=${{ matrix.job.rustflags }}" >> $GITHUB_ENV
- name: Build target
uses: ClementTsang/[email protected]
with:
use-cross: ${{ !!matrix.job.use-cross }}
command: build
args: --release --target ${{ matrix.job.target }} ${{ matrix.job.flags }}
env:
CARGO_PROFILE_RELEASE_LTO: true
- name: Strip release binary (linux and macOS)
if: matrix.job.os != 'windows-latest'
run: |
if [ "${{ matrix.job.binutils }}" != "" ]; then
sudo apt -y install "binutils-${{ matrix.job.binutils }}"
"${{ matrix.job.binutils }}-strip" "target/${{ matrix.job.target }}/release/xh"
else
strip "target/${{ matrix.job.target }}/release/xh"
fi
- id: get_version
uses: battila7/get-version-action@v2
- name: Package
shell: bash
run: |
if [ "${{ matrix.job.os }}" = "windows-latest" ]; then
bin="target/${{ matrix.job.target }}/release/xh.exe"
else
bin="target/${{ matrix.job.target }}/release/xh"
fi
staging="xh-${{ steps.get_version.outputs.version }}-${{ matrix.job.target }}"
mkdir -p "$staging"/{doc,completions}
cp LICENSE README.md $bin $staging
cp CHANGELOG.md doc/xh.1 "$staging"/doc
cp completions/* "$staging"/completions
if [ "${{ matrix.job.os }}" = "windows-latest" ]; then
7z a "$staging.zip" $staging
elif [[ "${{ matrix.job.os }}" =~ "macos" ]]; then
gtar czvf "$staging.tar.gz" $staging
else
tar czvf "$staging.tar.gz" $staging
fi
- name: Package (debian)
if: matrix.job.target == 'x86_64-unknown-linux-musl'
shell: bash
run: |
cargo install --git https://github.com/blyxxyz/cargo-deb --locked --branch xh-patches cargo-deb
cargo deb --no-build --target ${{ matrix.job.target }}
cp "target/${{ matrix.job.target }}/debian"/*.deb ./
- name: Publish
uses: softprops/action-gh-release@v1
with:
files: 'xh*'
draft: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}