-
Notifications
You must be signed in to change notification settings - Fork 0
93 lines (90 loc) · 2.58 KB
/
build-and-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
name: Build and Release
on:
workflow_call:
workflow_dispatch:
env:
RUSTFLAGS: -Dwarnings
CARGO_TERM_COLOR: always
jobs:
lint:
name: Run ${{ matrix.tool.name }}
strategy:
matrix:
tool:
- { name: rustfmt, args: fmt --all --check }
- { name: clippy, args: clippy }
runs-on: ubuntu-24.04
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup Rust toolchain
uses: ./.github/actions/setup-rust
- name: Run ${{ matrix.tool.name }}
run: cargo ${{ matrix.tool.args }}
test:
name: Build and test
runs-on: ubuntu-24.04
needs: [lint]
services:
postgres:
image: postgres:17.0
ports:
- 5432:5432
env:
POSTGRES_USER: moam
POSTGRES_PASSWORD: password
POSTGRES_DB: moam
env:
DATABASE_URL: postgres://moam:password@localhost:5432/moam
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup Rust toolchain
uses: ./.github/actions/setup-rust
- name: Check if .sqlx directory is up to date
run: cargo sqlx prepare --check
- name: Build project
run: cargo build --verbose
- name: Test project
run: cargo test --verbose
release:
name: Release
runs-on: ubuntu-24.04
needs: [test]
if: github.event_name != 'pull_request' && github.ref == 'refs/heads/main'
env:
SQLX_OFFLINE: true
steps:
- name: Get the privileged API key
id: atedeg-bot
uses: tibdex/[email protected]
with:
app_id: ${{ secrets.ATEDEG_BOT_APP_ID }}
private_key: ${{ secrets.ATEDEG_BOT_PRIVATE_KEY }}
- name: Checkout
uses: actions/checkout@v4
with:
token: ${{ steps.atedeg-bot.outputs.token }}
fetch-depth: 0
- name: Setup Rust toolchain
uses: ./.github/actions/setup-rust
- name: Setup Node toolchain
uses: ./.github/actions/setup-node
- name: Build project with release profile
run: cargo build --verbose --release
- name: Release
run: npx semantic-release
env:
GITHUB_TOKEN: ${{ steps.atedeg-bot.outputs.token }}
outcome:
name: Build and release outcome
runs-on: ubuntu-24.04
needs: [lint, test, release]
if: always()
steps:
- name: Verify there are no failed or cancelled jobs
run: jq --exit-status 'all(.result == "success" or .result == "skipped")' <<< '${{ toJson(needs) }}'