-
-
Notifications
You must be signed in to change notification settings - Fork 6
185 lines (158 loc) · 5.51 KB
/
ci-rs.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
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
name: Build & Test & publich Rust package "x-win"
env:
APP_NAME: x-win
MACOSX_DEPLOYMENT_TARGET: "10.13"
on:
push:
branches:
- main
tags-ignore:
- "**"
paths-ignore:
- "**/*.md"
- LICENSE
- "**/*.gitignore"
- .editorconfig
- docs/**
pull_request: null
release:
types: [published]
jobs:
build-n-test:
defaults:
run:
working-directory: ${{ github.workspace }}/x-win-rs
strategy:
fail-fast: false
matrix:
settings:
# Build matrix for MacOS (x64)
- host: macos-latest
target: x86_64-apple-darwin
# Build matrix for MacOS (arm64)
- host: macos-latest
target: aarch64-apple-darwin
# Build matrix for Windows (x64)
- host: windows-latest
target: x86_64-pc-windows-msvc
# Build matrix for Windows (x32)
- host: windows-latest
target: i686-pc-windows-msvc
architecture: "x86"
# Build matrix for Windows (arm64)
- host: windows-latest
target: aarch64-pc-windows-msvc
# Build for linux (using Ubuntu) (x64)
- host: ubuntu-latest
target: x86_64-unknown-linux-gnu
image: miniben90/ubuntu-dummy-desktop:latest
# Build for linux (using Ubuntu) (x64)
- host: ubuntu-latest
target: x86_64-unknown-linux-musl
image: miniben90/ubuntu-dummy-desktop:latest
name: stable - ${{ matrix.settings.target }}
runs-on: ${{ matrix.settings.host }}
steps:
# Add actions/checkout
- uses: actions/checkout@v4
# Install lib dev required for compilation of the project
- name: (Linux) Install libx11 & libxcb for building
if: ${{ matrix.settings.host == 'ubuntu-latest' }}
run: |
sudo apt-get update
sudo apt-get install -y libx11-dev libxcb-ewmh-dev libxcb-randr0-dev
# Install Rust version
- name: Install Rust
if: ${{ !matrix.settings.docker }}
uses: dtolnay/rust-toolchain@stable
with:
toolchain: stable
targets: ${{ matrix.settings.target }}
# Set Cache cargo
- name: Cache cargo
uses: actions/cache@v4
with:
path: |
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
.cargo-cache
target/
key: ${{ matrix.settings.target }}-cargo-${{ matrix.settings.host }}
# Lint Rust code
- name: Lint
run: cargo fmt -- --check
# Check clippy code
- name: Clippy
run: cargo clippy -- -D warnings
- name: Open finder to have an active window (MacOS)
if: ${{ matrix.settings.host == 'macos-latest' }}
run: open .
- name: Open explorer to have an active window (windows)
if: ${{ matrix.settings.host == 'windows-latest' }}
run: explorer .
- name: Test
if: ${{ matrix.settings.host != 'ubuntu-latest' }}
run: cargo test
- name: Test (x86_64-unknown-linux-gnu & x86_64-unknown-linux-musl)
if: ${{ matrix.settings.target == 'x86_64-unknown-linux-gnu' || matrix.settings.target == 'x86_64-unknown-linux-musl' }}
uses: addnab/docker-run-action@v3
with:
image: ${{ matrix.settings.image }}
options: --user 0:0 -v ${{ github.workspace }}/.github/docker-ubuntu-rust-install.sh:/usr/local/docker-ubuntu-rust-install.sh -v ${{ github.workspace }}/x-win-rs:/work -w /work
run: |
Xvfb :0 &
sleep 1
gpg-agent --daemon
sleep 1
xfce4-session &
sleep 1
sh /usr/local/docker-ubuntu-rust-install.sh ${{ matrix.settings.target }}
cd /work
cargo test --target ${{ matrix.settings.target }}
- name: Build
run: cargo build --release --target ${{ matrix.settings.target }}
# Upload artifact for the next steps (test and publish)
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: build-rs-${{ matrix.settings.host }}-${{ matrix.settings.target }}
path: ${{ github.workspace }}/x-win-rs/target/${{ matrix.settings.target }}
if-no-files-found: error
publish:
defaults:
run:
working-directory: ${{ github.workspace }}/x-win-rs
if: ${{ github.event_name == 'release' && github.ref_type == 'tag' }}
name: Publish ${{ github.ref_name }} (${{ github.ref }})
runs-on: ubuntu-latest
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
TAG: ${{ github.ref_name }}
needs:
- build-n-test
steps:
- uses: actions/checkout@v4
# Download artifacts from build part
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: ${{ github.workspace }}/x-win-rs/target
# Setup node version from matrix.node and install deps
- name: Setup node
uses: actions/setup-node@v4
with:
node-version: 20
check-latest: true
cache: yarn
# Install Rust version
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
toolchain: stable
# Update Cargo.toml version
- name: Set version to package.json
run: node ${{ github.workspace }}/.scripts/before-publish.cjs x-win-rs
- name: Publish package
run: cargo publish