17
17
GO_VERSION : ' 1.21.3'
18
18
GOLANGCI_VERSION : ' v1.54.2'
19
19
DOCKER_BUILDX_VERSION : ' v0.11.2'
20
+
21
+ # These environment variables are important to the Crossplane CLI install.sh
22
+ # script. They determine what version it installs.
20
23
XP_CHANNEL : master # TODO(negz): Pin to stable once v1.14 is released.
21
24
XP_VERSION : current # TODO(negz): Pin to a version once v1.14 is released.
22
25
23
- # Common users. We can't run a step 'if secrets.USR != ""' but we can run
24
- # a step 'if env.USR' != ""', so we copy these to succinctly test whether
25
- # credentials have been provided before trying to run steps that need them .
26
+ # This CI job will automatically push new builds to xpkg.upbound.io if the
27
+ # XPKG_ACCESS_ID and XPKG_TOKEN secrets are set in the GitHub respository (or
28
+ # organization) settings. Create a token at https://accounts.upbound.io .
26
29
XPKG_ACCESS_ID : ${{ secrets.XPKG_ACCESS_ID }}
27
30
28
- # The package to push, without a version tag.
31
+ # The package to push, without a version tag. The default matches GitHub. For
32
+ # example xpkg.upbound.io/crossplane/function-template-go.
29
33
XPKG : xpkg.upbound.io/${{ github.repository}}
34
+
35
+ # The package version to push. The default is 0.0.0-gitsha.
30
36
XPKG_VERSION : ${{ inputs.version }}
31
37
32
38
jobs :
61
67
- name : Run Unit Tests
62
68
run : go test -v -cover ./...
63
69
70
+ # We want to build most packages for the amd64 and arm64 architectures. To
71
+ # speed this up we build single-platform packages in parallel. We then upload
72
+ # those packages to GitHub as a build artifact. The push job downloads those
73
+ # artifacts and pushes them as a single multi-platform package.
64
74
build :
65
75
runs-on : ubuntu-22.04
66
76
strategy :
84
94
- name : Checkout
85
95
uses : actions/checkout@v4
86
96
97
+ # We ask Docker to use GitHub Action's native caching support to speed up
98
+ # the build, per https://docs.docker.com/build/cache/backends/gha/.
87
99
- name : Build Runtime
88
100
id : image
89
101
uses : docker/build-push-action@v5
@@ -111,6 +123,9 @@ jobs:
111
123
if-no-files-found : error
112
124
retention-days : 1
113
125
126
+ # This job downloads the single-platform packages built by the build job, and
127
+ # pushes them as a multi-platform package. We only push the package it the
128
+ # XPKG_ACCESS_ID and XPKG_TOKEN secrets were provided.
114
129
push :
115
130
runs-on : ubuntu-22.04
116
131
needs :
@@ -137,10 +152,12 @@ jobs:
137
152
password : ${{ secrets.XPKG_TOKEN }}
138
153
139
154
# If a version wasn't explicitly passed as a workflow_dispatch input we
140
- # default to version v0.0.0-shortsha, for example v0.0.0-8ed5691.
155
+ # default to version v0.0.0-<git-commit-date>-<git-short-sha>, for example
156
+ # v0.0.0-20231101115142-1091066df799. This is a simple implementation of
157
+ # Go's pseudo-versions: https://go.dev/ref/mod#pseudo-versions.
141
158
- name : Set Default Multi-Platform Package Version
142
159
if : env.XPKG_VERSION == ''
143
- run : echo "XPKG_VERSION=v0.0.0-$(git rev-parse --short HEAD)" >> $GITHUB_ENV
160
+ run : echo "XPKG_VERSION=v0.0.0-$(date -d@$( git show -s --format=%ct) +%Y%m%d%H%M%S)-$(git rev-parse --short=12 HEAD)" >> $GITHUB_ENV
144
161
145
162
- name : Push Multi-Platform Package to Upbound
146
163
if : env.XPKG_ACCESS_ID != ''
0 commit comments