This repository has been archived by the owner on Mar 27, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
79 lines (63 loc) · 2.23 KB
/
build-go.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
name: Build image
on:
push:
branches:
- master
jobs:
build:
name: Build image
runs-on: ubuntu-latest
strategy:
matrix:
arch: [amd64, arm64]
steps:
- name: Check out code into the Go module directory
uses: actions/checkout@v3
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version-file: go.mod
id: go
- name: Get dependencies
run: |
go get -v -t -d ./...
- name: Prepare destination directory
run: |
mkdir -p dist/tmp
chmod uga+rwx dist/tmp
- name: Build
run: CGO_ENABLED=0 GOOS=linux GOARCH=${{ matrix.arch }} go build -v -ldflags="-s -w" -o dist/vogon-go .
- name: Create image
run: podman build --tag ghcr.io/zlogic/vogon-go:${{ github.ref_name }}-${{ matrix.arch }} --arch=${{ matrix.arch }} --file .github/Dockerfile dist
- name: Save image file
run: podman save ghcr.io/zlogic/vogon-go:${{ github.ref_name }}-${{ matrix.arch }} > vogon-go.tar
- name: Upload image artifact
uses: actions/upload-artifact@v3
with:
name: vogon-go-${{ matrix.arch }}
path: vogon-go.tar
retention-days: 1
push-images:
name: Combine and push images
runs-on: ubuntu-latest
needs: build
steps:
- name: Download image artifacts
id: download
uses: actions/download-artifact@v3
- name: Create manifest
run: podman manifest create vogon-go:${{ github.ref_name }}
- name: Import images into Podman
run: |
for img in ${{ steps.download.outputs.download-path }}/*/vogon-go.tar; do
podman load < ${img}
podman manifest add vogon-go:${{ github.ref_name }} docker-archive:${img}
done
- name: Login into container registry
run: echo "${{ secrets.GITHUB_TOKEN }}" | podman login ghcr.io -u ${{ github.actor }} --password-stdin
- name: Push manifest
run: podman manifest push --all vogon-go:${{ github.ref_name }} docker://ghcr.io/zlogic/vogon-go:${{ github.ref_name }}
- name: Push images
run: |
podman images --noheading --format="{{.Repository}}:{{.Tag}}" --filter "reference=ghcr.io/zlogic/vogon-go:${{ github.ref_name }}-*" | \
xargs -I '{}' podman push '{}'