Skip to content

Commit c80fa67

Browse files
authored
Updated docker build script (#84)
1 parent 2719e1d commit c80fa67

1 file changed

Lines changed: 35 additions & 59 deletions

File tree

.github/workflows/on_publish.yaml

Lines changed: 35 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,32 @@
1-
name: Build docker container on publish
1+
name: Create Docker Image
22
on:
33
release:
4-
types: [ created, edited ]
4+
types:
5+
- created
6+
57
workflow_dispatch:
6-
inputs:
7-
tag:
8-
description: 'tag'
9-
required: true
10-
default: 'latest'
11-
type: string
12-
permissions:
13-
contents: read
8+
9+
env:
10+
DOCKER_REPO: ghcr.io/mutablelogic/gomedia
11+
1412
jobs:
15-
var:
16-
name: Set variables
17-
runs-on: ubuntu-latest
18-
outputs:
19-
image: "ghcr.io/${{ github.repository }}"
20-
tag: ${{ steps.var.outputs.tag }}
21-
steps:
22-
- name: Checkout
23-
uses: actions/checkout@v4
24-
with:
25-
fetch-depth: 0
26-
- name: Set variables
27-
id: var
28-
run: |
29-
if [ "${{ github.event_name }}" != "release" ] && [ "${{ inputs.tag }}" != "latest" ]; then
30-
TAG="${{ inputs.tag }}" && echo "tag=${TAG#v}" >> $GITHUB_OUTPUT
31-
else
32-
TAG="$(git describe --tags)" && echo "tag=${TAG#v}" >> $GITHUB_OUTPUT
33-
fi
3413
build:
3514
name: Build
36-
needs: var
37-
permissions:
38-
contents: read
39-
packages: write
4015
strategy:
4116
matrix:
42-
arch: [ amd64, arm64 ]
43-
runs-on: ${{ matrix.arch == 'amd64' && 'ubuntu-latest' || matrix.arch }}
17+
arch: [amd64, arm64]
18+
runs-on:
19+
- ${{ matrix.arch == 'amd64' && 'ubuntu-24.04' || matrix.arch == 'arm64' && 'ubuntu-24.04-arm' }}
4420
env:
45-
ARCH: ${{ matrix.arch }}
4621
OS: linux
47-
DOCKER_REGISTRY: ghcr.io/mutablelogic
22+
ARCH: ${{ matrix.arch }}
23+
outputs:
24+
tag: ${{ steps.build.outputs.tag }}
25+
permissions:
26+
contents: read
27+
packages: write
4828
steps:
49-
- name: Install git
29+
- name: Install build tools
5030
run: |
5131
sudo apt -y update
5232
sudo apt -y install build-essential git
@@ -62,23 +42,20 @@ jobs:
6242
username: ${{ github.repository_owner }}
6343
password: ${{ secrets.GITHUB_TOKEN }}
6444
- name: Build and Push
65-
id: build
45+
id: build
6646
run: |
67-
git checkout v${{ needs.var.outputs.tag }}
68-
make docker && make docker-push
47+
BUILDKIT_PROGRESS=plain make docker && make docker-push && make docker-version >> "$GITHUB_OUTPUT"
6948
manifest:
7049
name: Manifest
71-
needs:
72-
- var
73-
- build
74-
permissions:
75-
packages: write
50+
needs: build
7651
strategy:
7752
matrix:
78-
include:
79-
- tag: ${{ needs.var.outputs.tag }}
80-
- tag: latest # TODO: Skip this if the event calling is not publishing a release
53+
tag:
54+
- ${{ needs.build.outputs.tag }}
55+
- "latest"
8156
runs-on: ubuntu-latest
57+
permissions:
58+
packages: write
8259
steps:
8360
- name: Login
8461
uses: docker/login-action@v3
@@ -88,18 +65,17 @@ jobs:
8865
password: ${{ secrets.GITHUB_TOKEN }}
8966
- name: Create
9067
run: |
91-
docker manifest create ${{ needs.var.outputs.image }}:${{ matrix.tag }} \
92-
--amend ${{ needs.var.outputs.image }}-linux-amd64:${{ needs.var.outputs.tag }} \
93-
--amend ${{ needs.var.outputs.image }}-linux-arm64:${{ needs.var.outputs.tag }}
68+
docker manifest create ${{ env.DOCKER_REPO }}:${{ matrix.tag }} \
69+
--amend ${{ env.DOCKER_REPO }}:${{ needs.build.outputs.tag }}-linux-amd64 \
70+
--amend ${{ env.DOCKER_REPO }}:${{ needs.build.outputs.tag }}-linux-arm64
9471
- name: Annotate
9572
run: |
96-
docker manifest annotate --arch arm64 --os linux \
97-
${{ needs.var.outputs.image }}:${{ matrix.tag }} \
98-
${{ needs.var.outputs.image }}-linux-arm64:${{ needs.var.outputs.tag }}
9973
docker manifest annotate --arch amd64 --os linux \
100-
${{ needs.var.outputs.image }}:${{ matrix.tag }} \
101-
${{ needs.var.outputs.image }}-linux-amd64:${{ needs.var.outputs.tag }}
102-
docker manifest push ${{ needs.var.outputs.image }}:${{ matrix.tag }}
74+
${{ env.DOCKER_REPO }}:${{ matrix.tag }} \
75+
${{ env.DOCKER_REPO }}:${{ needs.build.outputs.tag }}-linux-amd64
76+
docker manifest annotate --arch arm64 --os linux \
77+
${{ env.DOCKER_REPO }}:${{ matrix.tag }} \
78+
${{ env.DOCKER_REPO }}:${{ needs.build.outputs.tag }}-linux-arm64
10379
- name: Push
10480
run: |
105-
docker manifest push ${{ needs.var.outputs.image }}:${{ matrix.tag }}
81+
docker manifest push ${{ env.DOCKER_REPO }}:${{ matrix.tag }}

0 commit comments

Comments
 (0)