-
Notifications
You must be signed in to change notification settings - Fork 4
171 lines (164 loc) · 5.01 KB
/
buildx_on_pr.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
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
name: PR
on:
pull_request:
env:
IMAGE_NAME: ghcr.io/by275/libtorrent
LT_VER: "2.0.10"
jobs:
changes:
runs-on: ubuntu-22.04
outputs:
alpine: ${{ steps.alpine.outputs.changes }}
ubuntu: ${{ steps.ubuntu.outputs.changes }}
steps:
- uses: dorny/paths-filter@v3
id: alpine
with:
filters: |
alpine3.17: '{.github,alpine3.17}/**'
alpine3.18: '{.github,alpine3.18}/**'
alpine3.19: '{.github,alpine3.19}/**'
alpine3.20: '{.github,alpine3.20}/**'
- uses: dorny/paths-filter@v3
id: ubuntu
with:
filters: |
ubuntu20.04: '{.github,ubuntu20.04}/**'
ubuntu22.04: '{.github,ubuntu22.04}/**'
ubuntu23.10: '{.github,ubuntu23.10}/**'
ubuntu24.04: '{.github,ubuntu24.04}/**'
alpine:
needs:
- changes
if: ${{ needs.changes.outputs.alpine != '[]' && needs.changes.outputs.alpine != '' }}
runs-on: ubuntu-22.04
strategy:
matrix:
distro: ${{ fromJSON(needs.changes.outputs.alpine) }}
arch: [amd64, arm64, arm]
steps:
-
name: Checkout
uses: actions/checkout@v4
-
name: Set up QEMU
uses: docker/setup-qemu-action@v3
-
name: Set up Buildx
uses: docker/setup-buildx-action@v3
-
name: Login to ghcr.io
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
-
name: Buildx and Push
uses: docker/build-push-action@v5
with:
context: ${{ matrix.distro }}/.
file: ${{ matrix.distro }}/Dockerfile
tags: |
${{ env.IMAGE_NAME }}:testing-${{ matrix.distro }}-${{ matrix.arch }}
platforms: linux/${{ matrix.arch }}
push: true
build-args: |
LT_VER=${{ env.LT_VER }}
provenance: false
alpine-release:
needs:
- changes
- alpine
if: ${{ needs.changes.outputs.alpine != '[]' && needs.changes.outputs.alpine != '' }}
runs-on: ubuntu-22.04
strategy:
matrix:
distro: ${{ fromJSON(needs.changes.outputs.alpine) }}
steps:
-
name: Checkout
uses: actions/checkout@v4
-
name: Set up QEMU
uses: docker/setup-qemu-action@v3
-
name: Set up Buildx
uses: docker/setup-buildx-action@v3
-
name: Login to ghcr.io
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
-
name: Create manifest and push for testing
run: |
docker manifest create ${{ env.IMAGE_NAME }}:testing-${{ matrix.distro }} \
${{ env.IMAGE_NAME }}:testing-${{ matrix.distro }}-amd64 \
${{ env.IMAGE_NAME }}:testing-${{ matrix.distro }}-arm64 \
${{ env.IMAGE_NAME }}:testing-${{ matrix.distro }}-arm
docker manifest push ${{ env.IMAGE_NAME }}:testing-${{ matrix.distro }}
-
name: Generate Release Assets
run: |
bash release.sh testing "${{ matrix.distro }}"
- name: Upload Artifact
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.distro }}
path: "release/*.tar.gz"
ubuntu:
needs:
- changes
if: ${{ needs.changes.outputs.ubuntu != '[]' && needs.changes.outputs.ubuntu != '' }}
runs-on: ubuntu-22.04
strategy:
matrix:
distro: ${{ fromJSON(needs.changes.outputs.ubuntu) }}
steps:
-
name: Checkout
uses: actions/checkout@v4
-
name: Set up QEMU
uses: docker/setup-qemu-action@v3
-
name: Set up Buildx
uses: docker/setup-buildx-action@v3
-
name: Login to ghcr.io
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
-
name: Cross Build and Load Artifacts
run: |
cd ${{ matrix.distro }}
docker build --build-arg LT_VER=${{ env.LT_VER }} -t lt-build:local -f cross-build.dockerfile .
docker run --rm -v ${PWD}/build:/build lt-build:local /bin/bash -c "rm -rf /build/* && mv /lt-build/* /build/"
-
name: Buildx and Push
uses: docker/build-push-action@v5
with:
context: ${{ matrix.distro }}/.
file: ${{ matrix.distro }}/Dockerfile
tags: |
${{ env.IMAGE_NAME }}:testing-${{ matrix.distro }}
platforms: linux/amd64,linux/arm/v7,linux/arm64
push: true
build-args: |
LT_VER=${{ env.LT_VER }}
provenance: false
-
name: Generate Release Assets
run: |
bash release.sh testing "${{ matrix.distro }}"
- name: Upload Artifact
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.distro }}
path: "release/*.tar.gz"