-
Notifications
You must be signed in to change notification settings - Fork 8
112 lines (98 loc) · 3.69 KB
/
build.yml
File metadata and controls
112 lines (98 loc) · 3.69 KB
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
name: build
on:
workflow_dispatch:
inputs:
version:
description: 'Version to build and push (e.g., 30.2). Leave empty to build all without pushing.'
required: false
type: string
pull_request:
branches:
- master
push:
branches:
- master
tags:
- 'v*'
jobs:
discover:
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.matrix.outputs.matrix }}
push: ${{ steps.matrix.outputs.push }}
steps:
- name: Checkout
uses: actions/checkout@v5
- name: Discover versions and set matrix
id: matrix
run: |
# Skip branch builds if this commit has a tag (tag build will handle it)
if [[ "$GITHUB_REF" == refs/heads/* ]]; then
if git describe --exact-match --tags HEAD 2>/dev/null; then
echo "Commit has a tag, skipping branch build"
echo 'matrix={"include":[]}' >> $GITHUB_OUTPUT
echo "push=false" >> $GITHUB_OUTPUT
exit 0
fi
fi
VERSION_FLAG=""
if [[ -n "${{ inputs.version }}" ]]; then
VERSION_FLAG="--version ${{ inputs.version }}"
fi
echo "matrix=$(python scripts/ci.py matrix --ref $GITHUB_REF $VERSION_FLAG)" >> $GITHUB_OUTPUT
echo "push=$(python scripts/ci.py should-push --ref $GITHUB_REF $VERSION_FLAG)" >> $GITHUB_OUTPUT
build:
needs: discover
runs-on: ubuntu-latest
strategy:
matrix: ${{ fromJson(needs.discover.outputs.matrix) }}
fail-fast: false
steps:
- name: Checkout
uses: actions/checkout@v5
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Prepare Docker build
id: prepare
run: |
ALPINE_FLAG=""
if [[ "${{ matrix.variant }}" == "alpine" ]]; then
ALPINE_FLAG="--alpine"
BUILD_PATH="${{ matrix.version }}/alpine"
PLATFORMS="linux/amd64"
elif [[ "${{ matrix.version }}" == "master" ]]; then
BUILD_PATH="${{ matrix.version }}"
PLATFORMS="linux/amd64"
else
BUILD_PATH="${{ matrix.version }}"
PLATFORMS="linux/amd64,linux/arm64,linux/arm/v7"
fi
TAGS=$(python scripts/ci.py tags --version "${{ matrix.version }}" $ALPINE_FLAG)
echo "build_date=$(date -u +'%Y-%m-%dT%H:%M:%SZ')" >> $GITHUB_OUTPUT
echo "build_path=$BUILD_PATH" >> $GITHUB_OUTPUT
echo "platforms=$PLATFORMS" >> $GITHUB_OUTPUT
echo "tags=$TAGS" >> $GITHUB_OUTPUT
- name: Login to Docker Hub
if: ${{ needs.discover.outputs.push == 'true' }}
uses: docker/login-action@v3
with:
username: bitcoin
password: ${{ secrets.DOCKER_HUB_PASSWORD }}
- name: Build Docker image
run: |
TAGS=(${{ steps.prepare.outputs.tags }})
echo "Build date: ${{ steps.prepare.outputs.build_date }}"
echo "Build path: ${{ steps.prepare.outputs.build_path }}"
echo "Platforms: ${{ steps.prepare.outputs.platforms }}"
echo "Push: ${{ needs.discover.outputs.push }}"
echo "Tags: ${{ steps.prepare.outputs.tags }}"
docker buildx build \
--platform ${{ steps.prepare.outputs.platforms }} \
--output "type=image,push=${{ needs.discover.outputs.push }}" \
--progress=plain \
--build-arg "BUILD_DATE=${{ steps.prepare.outputs.build_date }}" \
--build-arg "VCS_REF=${GITHUB_SHA::8}" \
$(printf "%s" "${TAGS[@]/#/ --tag }") \
${{ steps.prepare.outputs.build_path }}/