-
-
Notifications
You must be signed in to change notification settings - Fork 1
133 lines (112 loc) · 3.54 KB
/
ci-cd.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
name: CI/CD
on:
push:
branches:
- main
paths:
- '**.rs'
- '**/Cargo.toml'
- '**/Cargo.lock'
pull_request:
branches:
- main
paths:
- '**.rs'
- '**/Cargo.toml'
- '**/Cargo.lock'
workflow_dispatch:
jobs:
lint-and-format:
name: Lint with clippy and check formatting
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
- name: Install Rust toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
components: clippy, rustfmt
override: true
- name: Check formatting
run: cargo fmt -- --check
- name: Clippy check
run: cargo clippy -p smithe_backend -p smithe_database -p smithe_lib -p startgg -- -D warnings
build:
needs: lint-and-format
strategy:
matrix:
os: [ubuntu-20.04, macos-latest, windows-latest]
include:
- os: ubuntu-20.04
target: x86_64-unknown-linux-gnu
- os: macos-latest
target: x86_64-apple-darwin
- os: windows-latest
target: x86_64-pc-windows-msvc
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v2
- name: Cache Rust dependencies
uses: Swatinem/rust-cache@v2
- name: Install Rust toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
target: ${{ matrix.target }}
- if: matrix.os == 'windows-latest'
name: Install PostgreSQL
uses: ikalnytskyi/action-setup-postgres@v4
- if: matrix.os == 'ubuntu-20.04'
name: Install cross
run: cargo install cross
# Conditional step for standard Rust build for non-arm64 targets
- if: matrix.os == 'ubuntu-20.04'
name: Cross build for arm64
run: cross build --release --target aarch64-unknown-linux-gnu
env:
SERVER_ADDRESS: 'http://127.0.0.1:8080'
- name: Build
run: cargo build --release --target ${{ matrix.target }}
env:
SERVER_ADDRESS: 'http://127.0.0.1:8080'
- if: matrix.os == 'ubuntu-20.04'
name: Upload arm64 pidgtm artifact
uses: actions/upload-artifact@v2
with:
name: pidgtm-aarch64-unknown-linux-gnu
path: target/aarch64-unknown-linux-gnu/release/pidgtm
docker-deploy:
needs: build
runs-on: ubuntu-20.04
if: >
(github.event_name == 'push' && github.ref == 'refs/heads/main') ||
github.event_name == 'workflow_dispatch'
steps:
- uses: actions/checkout@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Download artifact
uses: actions/download-artifact@v2
with:
name: pidgtm-aarch64-unknown-linux-gnu
path: target/aarch64-unknown-linux-gnu/release/
- name: Display artifact
run: ls -la target/aarch64-unknown-linux-gnu/release/pidgtm && ldd target/aarch64-unknown-linux-gnu/release/pidgtm
- name: Set Executable Permissions
run: chmod +x target/aarch64-unknown-linux-gnu/release/pidgtm
- name: Login to DockerHub
uses: docker/login-action@v3
with:
username: danstaken
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Build and push multi-architecture Docker image
uses: docker/build-push-action@v5
with:
context: .
file: Dockerfile-UserUpdater
push: true
tags: danstaken/pidgtm-user-updater:latest
platforms: linux/arm64