-
Notifications
You must be signed in to change notification settings - Fork 2
112 lines (103 loc) · 4.04 KB
/
Copy pathdocker-multiarch.yml
File metadata and controls
112 lines (103 loc) · 4.04 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: Docker Multi-Platform Build
on:
workflow_dispatch:
inputs:
version:
description: 'Version tag to publish alongside latest/beta/alpha (e.g. 0.1.0)'
required: false
workflow_call:
inputs:
version:
description: 'Version tag to publish alongside latest/beta/alpha (e.g. 0.1.0)'
type: string
required: false
jobs:
build:
runs-on: ubuntu-latest
permissions:
packages: write
contents: read
steps:
- name: Checkout code
uses: actions/checkout@v7
- name: Set up QEMU
uses: docker/setup-qemu-action@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v4
#- name: Log in to Docker Hub
#uses: docker/login-action@v4.5.2
#with:
#username: ${{ secrets.DOCKERHUB_USERNAME }}
#password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Log in to GitHub Container Registry
uses: docker/login-action@v4.6.0
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Log in to Quay.io
uses: docker/login-action@v4.6.0
with:
registry: quay.io
username: ${{ secrets.QUAY_USERNAME }}
password: ${{ secrets.QUAY_TOKEN }}
- name: Compute image tags
id: tags
env:
VERSION: ${{ inputs.version }}
run: |
if [ -n "$VERSION" ] && ! echo "$VERSION" | grep -qE '^[a-zA-Z0-9._-]+$'; then
echo "::error::Invalid version input '$VERSION' (allowed: [a-zA-Z0-9._-])"
exit 1
fi
TAGS="ghcr.io/openrtmp/librtmp2-server:latest
ghcr.io/openrtmp/librtmp2-server:beta
ghcr.io/openrtmp/librtmp2-server:alpha
quay.io/openrtmp/librtmp2-server:latest
quay.io/openrtmp/librtmp2-server:beta
quay.io/openrtmp/librtmp2-server:alpha"
if [ -n "$VERSION" ]; then
# Only treat this as a "v"-prefixed release version (and mirror
# it under both the bare and v-prefixed tag) when it actually
# has a semver-like "vX.Y" shape, e.g. v0.1.1 -> 0.1.1 + v0.1.1.
# Requiring the dot (not just a leading digit) avoids
# mis-stripping arbitrary tags like "version1", "vprod", or
# "v1prod" that merely start with "v<digit>".
if echo "$VERSION" | grep -qE '^v[0-9]+\.[0-9]'; then
BARE_VERSION="${VERSION#v}"
else
BARE_VERSION="$VERSION"
fi
if ! echo "$BARE_VERSION" | grep -qE '^[A-Za-z0-9_][A-Za-z0-9_.-]{0,126}$'; then
echo "::error::Invalid version input '$VERSION' (normalized '$BARE_VERSION' must be a valid Docker tag: start with an alphanumeric or '_', then up to 126 more [A-Za-z0-9_.-] chars)"
exit 1
fi
TAGS="$TAGS
ghcr.io/openrtmp/librtmp2-server:$BARE_VERSION
quay.io/openrtmp/librtmp2-server:$BARE_VERSION"
# Publish the v-prefixed alias too whenever this looks like a
# semver-shaped release version (0.1.1 or v0.1.1 alike), so a
# single dispatch always produces both tags regardless of which
# form was typed. Tags that don't match this shape (e.g.
# "version1", "vprod", "1prod") only get their own literal tag,
# not an invented alias.
if echo "$BARE_VERSION" | grep -qE '^[0-9]+\.[0-9]'; then
TAGS="$TAGS
ghcr.io/openrtmp/librtmp2-server:v$BARE_VERSION
quay.io/openrtmp/librtmp2-server:v$BARE_VERSION"
fi
fi
{
echo "tags<<EOF"
echo "$TAGS"
echo "EOF"
} >> "$GITHUB_OUTPUT"
- name: Build and push
uses: docker/build-push-action@v7
with:
context: .
platforms: linux/amd64,linux/arm64/v8,linux/riscv64
push: true
tags: ${{ steps.tags.outputs.tags }}
build-args: |
APP_VERSION=${{ inputs.version }}