-
Notifications
You must be signed in to change notification settings - Fork 64
139 lines (119 loc) · 3.92 KB
/
Copy pathrelease.yml
File metadata and controls
139 lines (119 loc) · 3.92 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
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
name: Release Docker image
on:
push:
tags:
- 'v*' # Push events to matching v*, i.e. v1.0, v20.15.10
permissions: read-all
env:
IMAGE_NAME: phanan/koel
jobs:
test:
name: Run tests
runs-on: ubuntu-24.04
steps:
- name: Checkout code
uses: actions/checkout@v6
- name: Run tests
uses: ./.github/actions/test
build:
name: Build ${{ matrix.platform }}
runs-on: ${{ matrix.runner }}
needs: [test]
strategy:
fail-fast: false
matrix:
include:
# amd64 and arm64 each build on their own architecture. arm/v7 is 32-bit ARM,
# which the 64-bit Arm runners cannot execute, so it stays emulated on x86.
- platform: linux/amd64
runner: ubuntu-24.04
emulated: false
- platform: linux/arm64
runner: ubuntu-24.04-arm
emulated: false
- platform: linux/arm/v7
runner: ubuntu-24.04
emulated: true
steps:
- name: Checkout code
uses: actions/checkout@v6
- name: Name this platform
env:
PLATFORM: ${{ matrix.platform }}
run: echo "PLATFORM_SLUG=${PLATFORM//\//-}" >> "$GITHUB_ENV"
- name: Set up QEMU
if: matrix.emulated
uses: docker/setup-qemu-action@v4
with:
platforms: ${{ matrix.platform }}
- name: Set up Docker Build
uses: docker/setup-buildx-action@v4
- name: Login to DockerHub
uses: docker/login-action@v4
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_PASSWORD }}
- name: Resolve version
id: version
run: echo "TAG=$GITHUB_REF_NAME" >> "$GITHUB_OUTPUT"
# Each platform is pushed as an untagged image, identified only by its digest.
# The merge job below collects the digests into one tagged multi-arch manifest.
- name: Build and push the production image
id: build
uses: docker/build-push-action@v7
with:
platforms: ${{ matrix.platform }}
build-args: |
KOEL_VERSION_REF=${{ steps.version.outputs.TAG }}
outputs: type=image,name=${{ env.IMAGE_NAME }},push-by-digest=true,name-canonical=true,push=true
- name: Record the digest
env:
DIGEST: ${{ steps.build.outputs.digest }}
run: |
mkdir -p /tmp/digests
touch "/tmp/digests/${DIGEST#sha256:}"
- name: Upload the digest
uses: actions/upload-artifact@v4
with:
name: digest-${{ env.PLATFORM_SLUG }}
path: /tmp/digests/*
if-no-files-found: error
retention-days: 1
merge:
name: Push the multi-arch manifest
runs-on: ubuntu-24.04
needs: [build]
steps:
- name: Download the digests
uses: actions/download-artifact@v4
with:
path: /tmp/digests
pattern: digest-*
merge-multiple: true
- name: Set up Docker Build
uses: docker/setup-buildx-action@v4
- name: Login to DockerHub
uses: docker/login-action@v4
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_PASSWORD }}
- name: Resolve version
id: version
run: echo "VERSION=${GITHUB_REF_NAME#v}" >> "$GITHUB_OUTPUT"
- name: Create the manifest
working-directory: /tmp/digests
env:
VERSION: ${{ steps.version.outputs.VERSION }}
run: |
sources=()
for digest in *; do
sources+=("$IMAGE_NAME@sha256:$digest")
done
docker buildx imagetools create \
--tag "$IMAGE_NAME:latest" \
--tag "$IMAGE_NAME:$VERSION" \
"${sources[@]}"
- name: Verify the manifest
env:
VERSION: ${{ steps.version.outputs.VERSION }}
run: docker buildx imagetools inspect "$IMAGE_NAME:$VERSION"