-
Notifications
You must be signed in to change notification settings - Fork 3
120 lines (104 loc) · 3.42 KB
/
build_static.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
name: Static Build
on:
push:
branches:
- main
- release-*
tags:
# YYYYMMDD
- "20[0-9][0-9][0-1][0-9][0-3][0-9]*"
schedule:
- cron: "0 0 * * 1"
pull_request:
workflow_dispatch:
jobs:
static-build:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
arch:
- amd
- arm
steps:
- name: Prepare AMD
if: ${{ matrix.arch == 'amd' }}
run: |
echo "TARGET=x86_64-unknown-linux-musl" >> $GITHUB_ENV
echo "DEVSHELL=.#crossShell" >> $GITHUB_ENV
- name: Prepare ARM
if: ${{ matrix.arch == 'arm' }}
run: |
echo "TARGET=aarch64-unknown-linux-musl" >> $GITHUB_ENV
echo "DEVSHELL=.#armCrossShell" >> $GITHUB_ENV
- name: Checkout Repository
uses: actions/checkout@v4
- name: Install Nix
uses: cachix/install-nix-action@v23
- uses: cachix/cachix-action@v13
# If PR is from a non-collaborator (e. g. dependabot) the secrets are missing and the login to cachix fails.
continue-on-error: true
with:
name: espresso-systems-private
authToken: "${{ secrets.CACHIX_AUTH_TOKEN }}"
extraPullNames: nix-community
- name: Cache cargo
uses: actions/[email protected]
with:
path: |
~/.cargo/registry/index
~/.cargo/registry/cache
~/.cargo/git
target
key: discord-faucet-static-${{matrix.arch}}-v0-${{ hashFiles('Cargo.lock') }}
- name: Fix Git Security Issue
run: git config --global --add safe.directory "$PWD"
- name: Compile all executables
# timeout-minutes: 120
run: |
nix develop $DEVSHELL --accept-flake-config --option sandbox relaxed -c cargo build --release
- name: Upload artifacts
uses: actions/upload-artifact@v3
with:
name: ${{ env.TARGET }}-services
path: |
target/${{ env.TARGET }}/release/discord-faucet
static-dockers:
runs-on: ubuntu-latest
needs: static-build
steps:
- name: Checkout Repository
uses: actions/checkout@v4
- name: Download executables AMD
uses: actions/download-artifact@v3
with:
name: x86_64-unknown-linux-musl-services
path: target/amd64/release
- name: Download executables ARM
uses: actions/download-artifact@v3
with:
name: aarch64-unknown-linux-musl-services
path: target/arm64/release
- name: Setup Docker BuildKit (buildx)
uses: docker/setup-buildx-action@v3
- name: Login to Github Container Repo
uses: docker/login-action@v3
if: github.event_name != 'pull_request'
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Generate discord-faucet docker metadata
uses: docker/metadata-action@v5
id: discord-faucet
with:
images: ghcr.io/espressosystems/discord-faucet
- name: Build and push discord-faucet docker
uses: docker/build-push-action@v5
with:
context: ./
file: Dockerfile
platforms: linux/amd64
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.discord-faucet.outputs.tags }}
labels: ${{ steps.discord-faucet.outputs.labels }}