-
Notifications
You must be signed in to change notification settings - Fork 122
135 lines (113 loc) · 3.7 KB
/
build-dev.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
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
name: Build - Dev
on:
workflow_dispatch:
push:
tags:
- "!v*"
branches:
- master
pull_request:
branches:
- master
concurrency:
group: ${{ github.workflow }}-${{ github.ref || github.run_id }}
cancel-in-progress: ${{ github.ref != 'refs/heads/master' }}
env:
BUILD_VERSION: latest # Computed
DOCKER_HUB_USER: defi
# Note: We do not use debug build on CI for dev as well, since debug builds
# take 5x the amount of space and run the GitHub CI workers out of space.
# make.sh still defaults to debug for local builds
MAKE_DEBUG: 0
GIT_VERSION: 1
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
target: [x86_64-pc-linux-gnu, x86_64-w64-mingw32, x86_64-apple-darwin]
include:
- container: defi/ain-builder:latest
- target: x86_64-w64-mingw32
container: defi/ain-win-builder:latest
container:
image: ${{ matrix.container }}
env:
TARGET: ${{matrix.target}}
steps:
- uses: actions/checkout@v4
- run: git config --global --add safe.directory '*'
- name: Populate environment
run: ./make.sh ci-export-vars
- name: Setup dependencies
run: ./make.sh ci-setup-deps
- name: Setup user dependencies
run: ./make.sh ci-setup-user-deps
- name: Restore cpp build cache
id: cpp-cache-restore
uses: actions/cache/restore@v3
with:
path: |
./build/depends
./build/src
~/.ccache
key: cpp-${{ env.TARGET }}-${{ env.BUILD_TYPE }}
- name: Rust build cache
uses: Swatinem/rust-cache@v2
id: rust-cache-restore
with:
workspaces: lib -> ../build/lib/target
save-if: ${{ github.ref == 'refs/heads/master' }}
shared-key: ${{ env.TARGET }}
- name: Build and package
run: ./make.sh release
- name: Publish artifact
uses: actions/upload-artifact@v3
with:
name: defichain-${{ env.BUILD_VERSION }}-${{ env.TARGET }}
path: ./build/defichain-${{ env.BUILD_VERSION }}-${{ env.TARGET }}.${{ env.PKG_TYPE }}
- name: Delete previous cpp build cache
if: ${{ github.ref == 'refs/heads/master' && steps.cpp-cache-restore.outputs.cache-hit }}
continue-on-error: true
run: |
gh extension install actions/gh-actions-cache
gh actions-cache delete "cpp-${{ env.TARGET }}-${{ env.BUILD_TYPE }}" --confirm
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Save cpp build cache
if: ${{ github.ref == 'refs/heads/master' }}
uses: actions/cache/save@v3
with:
path: |
./build/depends
./build/src
~/.ccache
key: cpp-${{ env.TARGET }}-${{ env.BUILD_TYPE }}
docker-build:
runs-on: ubuntu-latest
needs: [build]
env:
TARGET: x86_64-pc-linux-gnu
steps:
- uses: actions/checkout@v4
- name: Populate environment
run: ./make.sh ci-export-vars
- name: Download binaries
uses: actions/download-artifact@v3
with:
name: defichain-${{ env.BUILD_VERSION }}-${{ env.TARGET }}
path: ./build/
- name: Unpack binaries
run: tar -xvzf ./build/defichain-${{ env.BUILD_VERSION }}-${{ env.TARGET }}.${{ env.PKG_TYPE }} -C ./build/
- name: Build defi image
run: rm .dockerignore && ./make.sh docker-build-from-binaries
- name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ env.DOCKER_HUB_USER }}
password: ${{ secrets.DOCKER_HUB_TOKEN }}
- name: Push to Docker Hub
run: |
set -e; ver=${{ env.BUILD_VERSION }}
docker tag defichain-${{ env.TARGET }}:${ver} defi/defichain:${ver}
docker push defi/defichain:${ver}