Skip to content
This repository was archived by the owner on Jul 21, 2024. It is now read-only.

Commit f2fd03b

Browse files
committed
Add GitHub Actions workflows (#2)
This adds GitHub Actions workflows that automatically build and publish the executables to GitHub releases. Additionally this makes the main timer DPI aware, so that it always renders in a crisp way.
1 parent 83b6e9f commit f2fd03b

File tree

10 files changed

+794
-287
lines changed

10 files changed

+794
-287
lines changed

.github/workflows/before_deploy.sh

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
set -ex
2+
3+
main() {
4+
local tag=$(git tag --points-at HEAD)
5+
local src=$(pwd) \
6+
stage=
7+
8+
if [[ "$OS_NAME" = macOS-latest ]]; then
9+
stage=$(mktemp -d -t tmp)
10+
else
11+
stage=$(mktemp -d)
12+
fi
13+
14+
if [[ "$OS_NAME" = ubuntu-* ]]; then
15+
cp target/$TARGET/max-opt/livesplit-one $stage/LiveSplitOne
16+
elif [[ "$OS_NAME" = macOS-* ]]; then
17+
cp target/$TARGET/max-opt/livesplit-one $stage/LiveSplitOne
18+
elif [[ "$OS_NAME" = windows-* ]]; then
19+
cp target/$TARGET/max-opt/livesplit-one.exe $stage/LiveSplitOne.exe
20+
fi
21+
22+
cd $stage
23+
if [[ "$OS_NAME" = windows-* ]]; then
24+
7z a $src/livesplit-one-$tag-$RELEASE_TARGET.zip *
25+
else
26+
tar czf $src/livesplit-one-$tag-$RELEASE_TARGET.tar.gz *
27+
fi
28+
cd $src
29+
30+
rm -rf $stage
31+
}
32+
33+
main

.github/workflows/build.sh

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
set -ex
2+
3+
main() {
4+
local cargo=cross
5+
if [ "$SKIP_CROSS" = "skip" ]; then
6+
cargo=cargo
7+
fi
8+
local release_flag=""
9+
if [ "$IS_DEPLOY" = "true" ]; then
10+
release_flag="--profile max-opt"
11+
fi
12+
13+
if [ -z "$FEATURES" ]; then
14+
FEATURE_FLAGS="--no-default-features"
15+
else
16+
FEATURE_FLAGS="--no-default-features --features $FEATURES"
17+
fi
18+
19+
$cargo build --target $TARGET $release_flag $FEATURE_FLAGS
20+
}
21+
22+
main

.github/workflows/rust.yml

Lines changed: 206 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,206 @@
1+
name: Rust
2+
3+
on:
4+
pull_request:
5+
push:
6+
branches:
7+
- 'master'
8+
tags:
9+
- '*'
10+
11+
# The colors mess with the problem matcher.
12+
# env:
13+
# CARGO_TERM_COLOR: always
14+
15+
jobs:
16+
build:
17+
runs-on: ${{ matrix.os }}
18+
strategy:
19+
fail-fast: false
20+
matrix:
21+
label:
22+
- Windows aarch64
23+
- Windows i686
24+
- Windows x86_64
25+
- Windows x86_64-v3
26+
# - Linux arm Hardware Float
27+
# - Linux armv7 Hardware Float
28+
# - Linux aarch64
29+
# - Linux i686
30+
- Linux x86_64
31+
- Linux x86_64-v3
32+
- macOS aarch64
33+
- macOS x86_64
34+
- macOS x86_64-v3
35+
36+
include:
37+
- label: Windows aarch64
38+
target: aarch64-pc-windows-msvc
39+
os: windows-latest
40+
cross: skip
41+
install_target: true
42+
43+
- label: Windows i686
44+
target: i686-pc-windows-msvc
45+
os: windows-latest
46+
cross: skip
47+
install_target: true
48+
49+
- label: Windows x86_64
50+
target: x86_64-pc-windows-msvc
51+
os: windows-latest
52+
features: auto-splitting
53+
cross: skip
54+
55+
- label: Windows x86_64-v3
56+
target: x86_64-pc-windows-msvc
57+
target_rename: x86_64_v3-pc-windows-msvc
58+
rust_flags: -C target-cpu=x86-64-v3
59+
os: windows-latest
60+
features: auto-splitting
61+
cross: skip
62+
63+
# - label: Linux arm Hardware Float
64+
# target: arm-unknown-linux-gnueabihf
65+
# os: ubuntu-latest
66+
67+
# - label: Linux armv7 Hardware Float
68+
# target: armv7-unknown-linux-gnueabihf
69+
# os: ubuntu-latest
70+
71+
# - label: Linux aarch64
72+
# target: aarch64-unknown-linux-gnu
73+
# os: ubuntu-latest
74+
# features: auto-splitting
75+
76+
# - label: Linux i686
77+
# target: i686-unknown-linux-gnu
78+
# os: ubuntu-22.04
79+
# apt_arch: i386
80+
# cross: skip
81+
# install_target: true
82+
83+
- label: Linux x86_64
84+
target: x86_64-unknown-linux-gnu
85+
os: ubuntu-22.04
86+
apt_arch: amd64
87+
features: auto-splitting
88+
cross: skip
89+
90+
- label: Linux x86_64-v3
91+
target: x86_64-unknown-linux-gnu
92+
target_rename: x86_64_v3-unknown-linux-gnu
93+
rust_flags: -C target-cpu=x86-64-v3
94+
os: ubuntu-22.04
95+
apt_arch: amd64
96+
features: auto-splitting
97+
cross: skip
98+
99+
- label: macOS aarch64
100+
target: aarch64-apple-darwin
101+
os: macOS-latest
102+
features: auto-splitting
103+
cross: skip
104+
install_target: true
105+
106+
- label: macOS x86_64
107+
target: x86_64-apple-darwin
108+
os: macOS-latest
109+
features: auto-splitting
110+
cross: skip
111+
112+
- label: macOS x86_64-v3
113+
target: x86_64-apple-darwin
114+
target_rename: x86_64_v3-apple-darwin
115+
rust_flags: -C target-cpu=x86-64-v3
116+
os: macOS-latest
117+
features: auto-splitting
118+
cross: skip
119+
120+
steps:
121+
- name: Checkout Commit
122+
uses: actions/checkout@v3
123+
124+
- name: Install Rust
125+
uses: hecrj/setup-rust-action@v1
126+
with:
127+
rust-version: ${{ matrix.toolchain || 'stable' }}
128+
129+
- name: Install Target
130+
if: matrix.install_target != ''
131+
run: rustup target add ${{ matrix.target }}
132+
133+
- name: Download cross
134+
if: matrix.cross == ''
135+
uses: robinraju/[email protected]
136+
with:
137+
repository: "cross-rs/cross"
138+
latest: true
139+
fileName: "cross-x86_64-unknown-linux-gnu.tar.gz"
140+
out-file-path: "/home/runner/.cargo/bin"
141+
142+
- name: Install cross
143+
if: matrix.cross == ''
144+
run: |
145+
cd ~/.cargo/bin
146+
tar -xzf cross-x86_64-unknown-linux-gnu.tar.gz
147+
148+
- name: Install apt packages
149+
if: matrix.cross == 'skip' && startsWith(matrix.os, 'ubuntu-')
150+
run: |
151+
sudo dpkg --add-architecture ${{ matrix.apt_arch }}
152+
sudo apt-get update
153+
sudo apt-get install --assume-yes libgtk-3-dev:${{ matrix.apt_arch }}
154+
155+
- name: Build
156+
run: bash .github/workflows/build.sh
157+
env:
158+
TARGET: ${{ matrix.target }}
159+
SKIP_CROSS: ${{ matrix.cross }}
160+
IS_DEPLOY: ${{ startsWith(github.ref, 'refs/tags/') && (matrix.release_anyway != '' || !(startsWith(matrix.toolchain, 'nightly') || startsWith(matrix.toolchain, 'beta'))) }}
161+
FEATURES: ${{ matrix.features }}
162+
RUSTFLAGS: ${{ matrix.rust_flags }}
163+
164+
- name: Prepare Release
165+
if: startsWith(github.ref, 'refs/tags/') && matrix.release == ''
166+
run: bash .github/workflows/before_deploy.sh
167+
env:
168+
OS_NAME: ${{ matrix.os }}
169+
TARGET: ${{ matrix.target }}
170+
RELEASE_TARGET: ${{ matrix.target_rename || matrix.target }}
171+
172+
- name: Release
173+
if: startsWith(github.ref, 'refs/tags/') && matrix.release == ''
174+
uses: softprops/action-gh-release@v1
175+
with:
176+
files: livesplit-one-*.*
177+
env:
178+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
179+
180+
clippy:
181+
runs-on: windows-latest
182+
steps:
183+
- name: Checkout Commit
184+
uses: actions/checkout@v3
185+
186+
- name: Install Rust
187+
uses: hecrj/setup-rust-action@v1
188+
with:
189+
components: clippy
190+
191+
- name: Run Clippy
192+
run: cargo clippy --all-features
193+
194+
format:
195+
runs-on: ubuntu-latest
196+
steps:
197+
- name: Checkout Commit
198+
uses: actions/checkout@v3
199+
200+
- name: Install Rust
201+
uses: hecrj/setup-rust-action@v1
202+
with:
203+
components: rustfmt
204+
205+
- name: Run cargo fmt
206+
run: cargo fmt -- --check || true

0 commit comments

Comments
 (0)