-
Notifications
You must be signed in to change notification settings - Fork 5
146 lines (123 loc) · 3.91 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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
name: Release
on:
push:
tags:
- 'v[0-9]+.[0-9]+'
- 'v[0-9]+.[0-9]+.[0-9]+'
pull_request:
branches:
- main
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
env:
# whether artifacts should be published to ci-job (previewed) or as release
preview: ${{ !startsWith(github.ref, 'refs/tags/') }}
jobs:
build:
name: Build
env:
CARGO: cargo # 'cross' used for 32-bit and big-endian systems
RUST_BACKTRACE: 1 # emit backtrace on panics
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false # don't fail other jobs if one fails
matrix:
build: [x86_64-linux, x86_64-macos, x86_64-windows]
include:
- build: x86_64-linux
os: ubuntu-latest
rust: stable
target: x86_64-unknown-linux-musl
cross: false
- build: aarch64-linux
os: ubuntu-latest
rust: stable
target: aarch64-unknown-linux-musl
cross: true
- build: riscv64-linux
os: ubuntu-latest
rust: stable
target: riscv64gc-unknown-linux-gnu
cross: true
- build: x86_64-macos
os: macos-latest
rust: stable
target: x86_64-apple-darwin
cross: false
- build: x86_64-windows
os: windows-latest
rust: stable
target: x86_64-pc-windows-msvc
cross: false
steps:
- name: Checkout sources
uses: actions/checkout@v4
- name: Download grammars
uses: actions/download-artifact@v3
# The rust-toolchain action ignores rust-toolchain.toml files.
# Removing this before building with cargo ensures that the rust-toolchain
# is considered the same between installation and usage.
- name: Remove the rust-toolchain.toml file
run: |
touch rust-toolchain.toml # create if it doesn't exist
rm rust-toolchain.toml
- name: Install ${{ matrix.rust }} toolchain
uses: dtolnay/rust-toolchain@stable
with:
toolchain: ${{ matrix.rust }}
target: ${{ matrix.target }}
- name: Install Cross
if: "matrix.cross"
run: |
cargo install cross
echo "CARGO=cross" >> $GITHUB_ENV
- name: Show command used for Cargo
run: |
echo "build command: ${{ env.CARGO }} build --release --locked --target ${{ matrix.target }}"
- name: Run cargo test
if: "!matrix.skip_tests"
run: ${{ env.CARGO }} test --release --locked --target ${{ matrix.target }} --workspace
- name: Set profile.release.strip = true
shell: bash
run: |
mkdir -p .cargo
cat >> .cargo/config.toml <<EOF
[profile.release]
strip = true
EOF
- name: Build release binary
run: ${{ env.CARGO }} build --release --locked --target ${{ matrix.target }}
- name: Build archive
shell: bash
run: |
mkdir -p dist
ls ./target/${{ matrix.target }}/release/r*
cp ./target/${{ matrix.target }}/release/r dist/
- uses: actions/upload-artifact@v3
with:
name: r-${{ matrix.build }}
path: dist
publish:
name: Publish
needs: [build]
runs-on: ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@v4
- uses: actions/download-artifact@v3
- name: Check Artifacts
shell: bash
run: |
ls .
- name: Upload binaries to release
uses: softprops/action-gh-release@v1
if: env.preview == 'false'
with:
files: r-*
- name: Upload binaries as artifact
uses: actions/upload-artifact@v3
if: env.preview == 'true'
with:
name: release
path: r-*