-
-
Notifications
You must be signed in to change notification settings - Fork 1
96 lines (93 loc) · 3.33 KB
/
builds.yaml
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
name: Build release binary
env:
RUST_BACKTRACE: 1
CARGO_REGISTRIES_CRATES_IO_PROTOCOL: sparse
SQLITE_BIN: /home/runner/.sqlite3/sqlite3
on:
workflow_dispatch:
push:
tags:
- v*
jobs:
build:
name: Build on ${{ matrix.build }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
build: [linux-amd64, ]
include:
- build: linux-amd64
os: ubuntu-latest
rust: stable
artifact_name: 'mailpot-linux-amd64'
target: x86_64-unknown-linux-gnu
steps:
- uses: actions/checkout@v2
- id: cache-sqlite3-bin
name: Cache sqlite3 binary
uses: actions/cache@v3
with:
path: /home/runner/.sqlite3
key: toolchain-sqlite3
- if: ${{ steps.cache-sqlite3-bin.outputs.cache-hit != 'true' }}
name: Download sqlite3 binary
run: |
set -ex
sudo apt-get install -y --quiet wget unzip
mkdir -p /home/runner/.sqlite3
cd /home/runner/.sqlite3
wget "https://sqlite.org/2023/sqlite-tools-linux-x86-3420000.zip"
unzip sqlite-tools-linux-x86-3420000.zip
mv sqlite-tools-linux-x86-3420000/* .
rm -rf sqlite-tools-linux-x86-3420000*
echo "SQLITE_BIN=$(pwd)/sqlite3" >> $GITHUB_ENV
- id: cache-rustup
name: Cache Rust toolchain
uses: actions/cache@v3
with:
path: ~/.rustup
key: toolchain-${{ matrix.os }}-${{ matrix.rust }}
- if: ${{ steps.cache-rustup.outputs.cache-hit != 'true' }}
name: Install Rust ${{ matrix.rust }}
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: ${{ matrix.rust }}
target: ${{ matrix.target }}
override: true
- name: Configure cargo data directory
# After this point, all cargo registry and crate data is stored in
# $GITHUB_WORKSPACE/.cargo_home. This allows us to cache only the files
# that are needed during the build process. Additionally, this works
# around a bug in the 'cache' action that causes directories outside of
# the workspace dir to be saved/restored incorrectly.
run: echo "CARGO_HOME=$(pwd)/.cargo_home" >> $GITHUB_ENV
- id: cache-cargo
name: Cache cargo configuration and installations
uses: actions/cache@v3
with:
path: ${{ env.CARGO_HOME }}
key: cargo-${{ matrix.os }}-${{ matrix.rust }}
- if: ${{ steps.cache-cargo.outputs.cache-hit != 'true' }} && matrix.target
name: Setup Rust target
run: |
mkdir -p "${{ env.CARGO_HOME }}"
cat << EOF > "${{ env.CARGO_HOME }}"/config.toml
[build]
target = "${{ matrix.target }}"
EOF
- name: Build binary
run: |
cargo build --release --bin mpot --bin mpot-gen --bin mpot-web -p mailpot-cli -p mailpot-archives -p mailpot-web
mkdir artifacts
mv target/*/release/* target/ || true
mv target/release/* target/ || true
mv target/mpot target/mpot-web target/mpot-gen artifacts/
- name: Upload Artifacts
uses: actions/upload-artifact@v2
with:
name: ${{ matrix.artifact_name }}
path: artifacts
if-no-files-found: error
retention-days: 7