-
Notifications
You must be signed in to change notification settings - Fork 32
140 lines (122 loc) · 4.34 KB
/
docker-build.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
134
135
136
137
138
139
140
name: Build Docker Images and Binaries
# reusable workflow, do not add triggers
on:
workflow_call:
workflow_dispatch:
permissions:
id-token: write
contents: read
packages: write
jobs:
goreleaser:
runs-on: burnt-labs-amd64
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Run GoReleaser
env:
INCLUDE: ""
run: |
make build-all
build-docker:
name: main
needs: goreleaser
strategy:
fail-fast: false
matrix:
runner:
- selector: burnt-labs-amd64
platform: linux/amd64
- selector: burnt-labs-arm64
platform: linux/arm64
runs-on: ${{ matrix.runner.selector }}
steps:
- name: Check out code
uses: actions/checkout@v4
with:
ref: ${{ github.ref }}
fetch-depth: 0
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up docker buildx for push
uses: docker/setup-buildx-action@v3
with:
driver: docker
platforms: ${{ matrix.runner.platform }}
- name: Prepare environment
run: |
echo "PLATFORM=${{ matrix.runner.platform }}" | tr '/' '-' | tee -a $GITHUB_ENV
echo "XIOND_FN=xiond/${{ matrix.runner.platform }}" | tr '/' '-' | tee -a $GITHUB_ENV
echo "DOCKER_FN=docker/${{ matrix.runner.platform }}.tar" | tr '/' '-' | tee -a $GITHUB_ENV
echo "HEIGHLINER_FN=heighliner/${{ matrix.runner.platform }}.tar" | tr '/' '-' | tee -a $GITHUB_ENV
echo "VERSION=$(git describe --tags | sed 's/^v//')" | tee -a $GITHUB_ENV
- uses: int128/docker-build-cache-config-action@v1
id: cache
with:
image: ghcr.io/${{ github.repository }}/cache
- name: Build Docker Image
id: build-docker
uses: docker/build-push-action@v5
with:
build-args: |
COMMIT="${GITHUB_SHA}"
VERSION=${{ env.VERSION }}
TAG_VERSION="${GITHUB_SHA:0:7}"
labels: ${{ steps.meta.outputs.labels }}
platforms: ${{ matrix.runner.platform }}
push: false
target: release
cache-from: ${{ steps.cache.outputs.cache-from }}
cache-to: ${{ steps.cache.outputs.cache-to }}
outputs: type=docker,name=xion:${{ env.PLATFORM }},name-canonical=true
- name: Build Heighliner Image
id: build-heighliner
uses: docker/build-push-action@v5
with:
build-args: |
BASE_IMAGE=xion
VERSION=${{ env.PLATFORM }}
BINARIES=/usr/bin/xiond
labels: ${{ steps.meta.outputs.labels }}
platforms: ${{ matrix.runner.platform }}
target: heighliner
outputs: type=docker,name=heighliner:${{ env.PLATFORM }},name-canonical=true
- name: Save Docker Image
working-directory: ${{ runner.temp }}
run: |
docker save xion:${{ env.PLATFORM }} > ${{ env.DOCKER_FN }}
- name: Upload Docker Image
uses: actions/upload-artifact@v4
with:
name: ${{ env.DOCKER_FN }}
path: ${{ runner.temp }}/${{ env.DOCKER_FN }}
if-no-files-found: error
retention-days: 3
- name: Save Heighliner Image
working-directory: ${{ runner.temp }}
run: |
docker save heighliner:${{ env.PLATFORM }} > ${{ env.HEIGHLINER_FN }}
- name: Upload Heighliner Image
uses: actions/upload-artifact@v4
with:
name: ${{ env.HEIGHLINER_FN }}
path: ${{ runner.temp }}/${{ env.HEIGHLINER_FN }}
if-no-files-found: error
retention-days: 3
- name: Copy xiond binary from container
# if-contains(github.event.ref, 'v[0-9]+\.[0-9]+\.[0-9]+')
working-directory: ${{ runner.temp }}
run: |
tmpname="ctr-$(basename $XIOND_FN)"
docker create --platform ${{ matrix.runner.platform }} --name "${tmpname}" "xion:${PLATFORM}"
docker cp "${tmpname}:/usr/bin/xiond" "${XIOND_FN}"
docker rm -v "${tmpname}"
- name: Upload binary
# if-contains(github.event.ref, 'v[0-9]+\.[0-9]+\.[0-9]+')
uses: actions/upload-artifact@v4
with:
name: ${{ env.XIOND_FN }}
path: ${{ runner.temp }}/${{ env.XIOND_FN }}
retention-days: 3