-
Notifications
You must be signed in to change notification settings - Fork 2
154 lines (122 loc) · 4.2 KB
/
build.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
name: Build + Test
on: [ push ]
permissions:
contents: write
env:
CARGO_TERM_COLOR: always
CARGO_INCREMENTAL: 0
RUST_BACKTRACE: 1
CARGO_BUILD_TARGET: x86_64-unknown-linux-musl
jobs:
backend-check:
runs-on: ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@v4
- name: Setup Rust toolchain
run: |
sudo apt-get install musl-tools
rustup toolchain install stable --profile minimal --no-self-update -c clippy -c rustfmt -t $CARGO_BUILD_TARGET
rustup default stable
shell: bash
- name: "Print Rust toolchain version"
run: rustc --version --verbose
shell: bash
- uses: Swatinem/rust-cache@v2
- name: Fake frontend build
run: mkdir -p frontend/dist
- name: Fmt
run: cargo fmt --all -- --check
- name: Clippy
run: cargo clippy -- -D warnings
- name: Test
run: cargo test --all-features
frontend-check:
runs-on: ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@v4
- name: Install deps
run: npm install
working-directory: frontend
- name: Lint
run: npm run lint
working-directory: frontend
- name: Prettier
run: npm run prettier
working-directory: frontend
- name: Svelte check
run: npm run check
working-directory: frontend
build:
runs-on: ubuntu-latest
needs:
- backend-check
- frontend-check
steps:
- name: Checkout sources
uses: actions/checkout@v4
- name: Build frontend
run: npm install && npm run build
working-directory: frontend
- name: Setup Rust toolchain
run: |
sudo apt-get install musl-tools
rustup toolchain install stable --profile minimal --no-self-update -t $CARGO_BUILD_TARGET
rustup default stable
shell: bash
- name: "Print Rust toolchain version"
run: rustc --version --verbose
shell: bash
- name: "Set version"
id: version
run: |
REF="${{ github.ref }}"
if [[ "$REF" =~ ^refs/tags/v ]] ; then
version=${REF#refs/tags/v}
# checks
grep "version = \"$version\"" Cargo.toml > /dev/null
grep "\"version\": \"$version\"" frontend/package.json > /dev/null
else
version=unreleased
fi
echo "version=$version" >> $GITHUB_OUTPUT
echo "Found version: $version"
shell: bash
- uses: Swatinem/rust-cache@v2
- name: Build backend
run: cargo build --release --target $CARGO_BUILD_TARGET
- name: Package binary
run: |
cp LICENSE.txt README.md target/x86_64-unknown-linux-musl/release
tar -C target/x86_64-unknown-linux-musl/release \
-cvaf game-of-estimates_${{ steps.version.outputs.version }}_$CARGO_BUILD_TARGET.tar.bz2 \
game-of-estimates LICENSE.txt README.md
shell: bash
- name: Upload binary package
uses: actions/upload-artifact@v3
with:
name: binary
path: game-of-estimates_${{ steps.version.outputs.version }}_${{ env.CARGO_BUILD_TARGET }}.tar.bz2
if-no-files-found: error
- name: Login to Docker Hub
if: github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/v')
uses: docker/login-action@v2
with:
username: ${{ secrets.DH_USER }}
password: ${{ secrets.DH_PAT }}
- name: Build and push container image
if: github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/v')
uses: docker/build-push-action@v3
with:
context: .
push: true
tags: r1tschy/game-of-estimates:${{ steps.version.outputs.version }}
- name: Create Release
uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/v')
with:
name: Release ${{ steps.version.outputs.version }}
draft: true
fail_on_unmatched_files: true
files: game-of-estimates_${{ steps.version.outputs.version }}_${{ env.CARGO_BUILD_TARGET }}.tar.bz2