This repository has been archived by the owner on Apr 27, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
113 lines (97 loc) · 3.25 KB
/
docker-build-push.yaml
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
name: docker build and push
on:
pull_request: {}
push:
branches:
- main
tags:
- '*'
env:
GO_VERSION: '1.21.3'
DOCKER_BUILDX_VERSION: 'v0.11.2'
XP_CHANNEL: master
XP_VERSION: current
XPKG_ACCESS_ID: ${{ secrets.XPKG_ACCESS_ID }}
XPKG: index.docker.io/gotwarlost/crossplane-function-cue
jobs:
build:
name: build multi-arch packages
runs-on: ubuntu-22.04
strategy:
fail-fast: true
matrix:
arch:
- amd64
- arm64
steps:
- name: setup QEMU
uses: docker/setup-qemu-action@v3
with:
platforms: all
- name: setup Docker Buildx
uses: docker/setup-buildx-action@v3
with:
version: ${{ env.DOCKER_BUILDX_VERSION }}
install: true
- name: checkout
uses: actions/checkout@v4
- name: setup LDFLAGS
run: |
LDFLAGS="$(make ci-print-ldflags)"
echo "LDFLAGS=${LDFLAGS}">>$GITHUB_ENV
# We ask Docker to use GitHub Action's native caching support to speed up
# the build, per https://docs.docker.com/build/cache/backends/gha/.
- name: build runtime
id: image
uses: docker/build-push-action@v5
with:
context: .
platforms: linux/${{ matrix.arch }}
cache-from: type=gha
cache-to: type=gha,mode=max
target: image
build-args: |
GO_VERSION=${{ env.GO_VERSION }}
LDFLAGS=${{ env.LDFLAGS }}
outputs: type=docker,dest=runtime-${{ matrix.arch }}.tar
- name: setup the Crossplane CLI
run: "curl -sL https://raw.githubusercontent.com/crossplane/crossplane/master/install.sh | sh"
- name: remove examples from tree
run: rm -rf examples/
- name: build Package
run: ./crossplane xpkg build --package-file=${{ matrix.arch }}.xpkg --package-root=package/ --embed-runtime-image-tarball=runtime-${{ matrix.arch }}.tar
- name: upload single-platform package
uses: actions/upload-artifact@v3
with:
name: packages
path: "*.xpkg"
if-no-files-found: error
retention-days: 1
# This job downloads the single-platform packages built by the build job, and
# pushes them as a multi-platform package.
push:
runs-on: ubuntu-22.04
needs:
- build
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Download Single-Platform Packages
uses: actions/download-artifact@v3
with:
name: packages
path: .
- name: Setup the Crossplane CLI
run: "curl -sL https://raw.githubusercontent.com/crossplane/crossplane/master/install.sh | sh"
- name: Set Multi-Platform Package Version
run: echo "XPKG_VERSION=$(make ci-print-version)" >> $GITHUB_ENV
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
registry: docker.io
username: ${{ secrets.XPKG_ACCESS_ID }}
password: ${{ secrets.XPKG_TOKEN }}
if: env.XPKG_ACCESS_ID != ''
- name: Push Multi-Platform Package to docker hub
if: env.XPKG_ACCESS_ID != ''
run: "./crossplane --verbose xpkg push --package-files $(echo *.xpkg|tr ' ' ,) ${{ env.XPKG }}:${{ env.XPKG_VERSION }}"