-
Notifications
You must be signed in to change notification settings - Fork 135
91 lines (76 loc) · 3.04 KB
/
docker-publish.yml
File metadata and controls
91 lines (76 loc) · 3.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
name: Docker Build and Publish
on:
release:
types: [created]
workflow_dispatch:
inputs:
tag:
description: 'Docker image tag'
required: false
default: 'latest'
permissions:
contents: read
packages: write
env:
REGISTRY: ghcr.io
jobs:
docker:
name: Build and Publish Docker Image
runs-on: ubuntu-latest
steps:
- name: Set IMAGE_NAME to lowercase
run: echo "IMAGE_NAME=$(echo '${{ github.repository }}' | tr '[:upper:]' '[:lower:]')" >> $GITHUB_ENV
- name: Check out code
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
fetch-depth: 0
submodules: "recursive"
- name: Set up Go
uses: actions/setup-go@7a3fe6cf4cb3a834922a1244abfce67bcef6a0c5 # v6.2.0
with:
go-version-file: "go.mod"
cache: false
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@8d2750c68a42422c14e847fe6c8ac0403b4cbd6f # v3.12.0
- name: Log in to GitHub Container Registry
uses: docker/login-action@b45d80f862d83dbcd57f89517bcf500b2ab88fb2 # v4.0.0
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract release version
id: extract_version
run: |
if [ "${{ github.event_name }}" = "release" ]; then
echo "version=$(echo "${{ github.event.release.tag_name }}" | sed 's/v\.//')" >> $GITHUB_OUTPUT
else
echo "version=${{ github.event.inputs.tag }}" >> $GITHUB_OUTPUT
fi
- name: Build azqr binaries for multi-arch
run: |
# Build for amd64
GOOS=linux GOARCH=amd64 CGO_ENABLED=0 PRODUCT_VERSION=${{ steps.extract_version.outputs.version }} make azqr
# Build for arm64
GOOS=linux GOARCH=arm64 CGO_ENABLED=0 PRODUCT_VERSION=${{ steps.extract_version.outputs.version }} make azqr
# Verify binaries were created
ls -la bin/linux_amd64/azqr
ls -la bin/linux_arm64/azqr
# Test the binaries
file bin/linux_amd64/azqr
file bin/linux_arm64/azqr
- name: Build and push Docker image
uses: docker/build-push-action@d08e5c354a6adb9ed34480a06d141179aa583294 # v7.0.0
with:
context: .
platforms: linux/amd64,linux/arm64
push: true
tags: |
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ steps.extract_version.outputs.version }}
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest
file: Dockerfile
- name: Generate Docker image summary
run: |
echo "## Docker Image Published" >> $GITHUB_STEP_SUMMARY
echo "- **Registry**: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}" >> $GITHUB_STEP_SUMMARY
echo "- **Version**: ${{ steps.extract_version.outputs.version }}" >> $GITHUB_STEP_SUMMARY
echo "- **Platforms**: linux/amd64, linux/arm64" >> $GITHUB_STEP_SUMMARY