@@ -5,9 +5,24 @@ description: "Configuring build pipelines for Crossplane extensions with GitHub
5
5
Actions"
6
6
---
7
7
8
+ ## Distributing Crossplane extensions
9
+
10
+ Crossplane provides a packaging specification for extending a Crossplane
11
+ instance with APIs and business logic for composing resources.
12
+
8
13
Building a Crossplane extension involves creating OCI images in the [ xpkg]
9
14
format. Authors and maintainers of Crossplane extensions must push their
10
- packages to an OCI registry before Crossplane can reference and use them.
15
+ packages to an OCI registry before users can reference and use them.
16
+
17
+ The release process for Crossplane extensions grew organically in the community
18
+ and developed its own conventions and common configurations. Authors of these
19
+ extensions should follow this guide to enable automation for building
20
+ and pushing their packages as part of their git workflow.
21
+
22
+ This guide provides step-by-step instructions for configuring automated
23
+ CI pipelines in GitHub Actions for pushing your Crossplane extensions to
24
+ ` xpkg.crossplane.io ` and/or ` xpkg.upbound.io ` , which are two registries
25
+ that the Crossplane community use today.
11
26
12
27
{{< hint "tip" >}}
13
28
For more information about Crossplane packages, review the
@@ -16,9 +31,6 @@ For more information about Crossplane packages, review the
16
31
17
32
## Typical workflow
18
33
19
- This guide covers configuring a GitHub Action for building Crossplane
20
- providers and functions and pushing them to an OCI registry such as ` ghcr.io ` .
21
-
22
34
A typical GitHub workflow definition contains the following steps:
23
35
24
36
1 . Fetching the source repository
@@ -31,12 +43,130 @@ The supplied credentials for the remote registry require read and write access
31
43
as upload requests to the registry specify ` push ` authorization scope.
32
44
{{< /hint >}}
33
45
34
- The template GitHub repositories for [ providers] and [ functions] provide
35
- a functional GitHub Action in ` .github/workflows/ci.yml ` . The following
36
- sections of this guide cover configuration options and conventions for each.
46
+ ## Quickstart: Releasing a Provider to ` xpkg.crossplane.io `
47
+
48
+ ### Prerequisites
49
+
50
+ - A GitHub repository, for example created from the
51
+ [ Upjet template] ( https://github.com/crossplane/upjet-provider-template )
52
+
53
+ ### Steps
54
+
55
+ 1 . Create a new YAML file under ` .github/workflows ` . By convention, name this
56
+ file ` publish-provider-package.yaml ` .
57
+ 2 . Copy the following workflow definition into the file, replacing
58
+ ` <REPOSITORY NAME> ` with the desired name of the repository in the registry.
59
+
60
+ ```yaml
61
+ name: Publish Provider Package
62
+
63
+ on:
64
+ workflow_dispatch:
65
+ inputs:
66
+ version:
67
+ description: "Version string to use while publishing the package (e.g. v1.0.0-alpha.1)"
68
+ default: ''
69
+ required: false
70
+ go-version:
71
+ description: 'Go version to use if building needs to be done'
72
+ default: '1.23'
73
+ required: false
74
+
75
+ jobs:
76
+ publish-provider-package:
77
+ uses: crossplane-contrib/provider-workflows/.github/workflows/publish-provider-non-family.yml@main
78
+ with:
79
+ repository: <REPOSITORY NAME>
80
+ version: ${{ github.event.inputs.version }}
81
+ go-version: ${{ github.event.inputs.go-version }}
82
+ cleanup-disk: true
83
+ secrets:
84
+ GHCR_PAT: ${{ secrets.GITHUB_TOKEN }}
85
+ ```
86
+
87
+ 3 . Commit the workflow file to the default branch of the GitHub repository.
88
+ 4 . The workflow should now be available to trigger via the GitHub UI in the
89
+ ` Actions ` tab.
90
+
91
+ ### Optionally mirroring to ` xpkg.upbound.io `
92
+
93
+ ` xpkg.upbound.io ` is the registry known as the [ Upbound Marketplace] .
94
+
95
+ To optionally push (mirror) the same package to this registry, you need
96
+ an Upbound account.
97
+
98
+ 1 . [ Log in] ( https://accounts.upbound.io/login ) to Upbound.
99
+ 2 . Create an [ access token] ( https://accounts.upbound.io/settings/tokens ) .
100
+ 3 . Copy the token into a GitHub Actions secret, for example
101
+ ` XPKG_UPBOUND_TOKEN ` .
102
+ 4 . Reference the secret created in step 3 in the ` secrets ` block of the
103
+ workflow YAML file. For example:
104
+
105
+ ```yaml
106
+ secrets:
107
+ GHCR_PAT: ${{ secrets.GITHUB_TOKEN }}
108
+ XPKG_UPBOUND_TOKEN: ${{ secrets.XPKG_UPBOUND_TOKEN }}
109
+ ```
110
+
111
+ {{< hint "warning" >}}
112
+ The process for optionally pushing to the Upbound Marketplace in this quickstart
113
+ is changing to be consistent with how other pipelines authenticate to
114
+ the Upbound registry.
115
+
116
+ See https://github.com/crossplane-contrib/provider-workflows/issues/14 for
117
+ details.
118
+ {{< /hint >}}
119
+
120
+ ## Quickstart: Releasing a Function to ` xpkg.crossplane.io `
121
+
122
+ The template repository for [ functions] provides a functional GitHub Action
123
+ YAML file that pushes to ` xpkg.crossplane.io ` without extra configuration.
124
+
125
+ To optionally configure pushing to the Upbound Marketplace (` xpkg.upbound.io ` ):
126
+
127
+ 1 . [ Log in] ( https://accounts.upbound.io/login ) to Upbound.
128
+ 2 . Create a [ Repository] ( https://docs.upbound.io/build/repositories/store-configurations/#create-a-repository ) .
129
+ 3 . Create a [ Robot] ( https://docs.upbound.io/operate/accounts/identity-management/robots/ )
130
+ and a [ Team] ( https://docs.upbound.io/operate/accounts/identity-management/teams/ ) .
131
+ 4 . Assign the Robot to the Team.
132
+ 5 . Grant the team ` WRITE ` permission to the repository.
133
+ 6 . Provision a token (key pair) for the Robot, and save the access ID and token
134
+ as separate GitHub Actions secrets (for example ` XPKG_ACCESS_ID ` and ` XPKG_TOKEN ` ).
135
+ 7 . Change the workflow YAML file to authenticate to ` xpkg.upbound.io ` :
136
+
137
+ ``` yaml
138
+ # In env: block
139
+ XPKG : xpkg.upbound.io/${{ github.repository}}
140
+ [...]
141
+
142
+ # extra login step in the job
143
+ - name : Login to Upbound
144
+ uses : docker/login-action@v3
145
+ if : env.XPKG_ACCESS_ID != ''
146
+ with :
147
+ registry : xpkg.upbound.io
148
+ username : ${{ secrets.XPKG_ACCESS_ID }}
149
+ password : ${{ secrets.XPKG_TOKEN }}
150
+ ` ` `
151
+
152
+ 8. Change the workflow YAML file to push to ` xpkg.upbound.io`:
153
+
154
+ ` ` ` yaml
155
+ # after login step above
156
+ - name: Push Multi-Platform Package to Upbound
157
+ if: env.XPKG_ACCESS_ID != ''
158
+ run: "./crossplane --verbose xpkg push --package-files $(echo *.xpkg|tr ' ' ,) ${{ env.XPKG }}:${{ env.XPKG_VERSION }}"
159
+ ` ` `
37
160
38
161
# # Common Configuration
39
162
163
+ While the reusable workflows referenced in the quickstart guides are for
164
+ convenience, users may choose to write their own custom GitHub Actions.
165
+
166
+ This and following sections provide more detailed information
167
+ about common configuration options and conventions to implement the release
168
+ process.
169
+
40
170
All workflows require references to credentials for a remote registry.
41
171
Typically, users configure them as [GitHub Actions Secrets], and the workflow
42
172
performs authentication via the`docker/login-action`
@@ -97,8 +227,8 @@ where it builds from, and tag it as `v0.1.0`.
97
227
98
228
{{< hint "note" >}}
99
229
Some custom workflows may accept an explicit input for the remote reference,
100
- which overrides inferring from a git ref or tag. The [`ci.yml`] file for
101
- ` crossplane-contrib/function-python` is a good example.
230
+ which overrides inferring from a git ref or tag. The [`ci.yml`](https://github.com/crossplane-contrib/function-python/blob/main/.github/workflows/ci.yml)
231
+ file for `crossplane-contrib/function-python` is a good example.
102
232
{{< /hint >}}
103
233
104
234
# # Configuring workflows for function packages
@@ -155,8 +285,8 @@ registry.
155
285
156
286
# ## Configure target registry
157
287
158
- The provider template repository includes a top-level `Makefile`. Edit
159
- the following variables to define the target registry :
288
+ The provider template repository includes a top-level [ `Makefile`](https://github.com/crossplane/upjet-provider-template/blob/main/Makefile).
289
+ Edit the following variables to define the target registry :
160
290
161
291
1. `XPKG_REG_ORGS` - a space-delimited list of target repositories.
162
292
2. `XPKG_REG_ORGS_NO_PROMOTE` - for registries that don't use or infer
@@ -216,8 +346,7 @@ what's configured in GitHub.
216
346
<!-- Named Links -->
217
347
[xpkg] : https://github.com/crossplane/crossplane/blob/main/contributing/specifications/xpkg.md
218
348
[functions] : https://github.com/crossplane/function-template-go/blob/main/.github/workflows/ci.yml
219
- [providers] : https://github.com/crossplane/upjet-provider-template/blob/main/.github/workflows/ci.yml
220
349
[GitHub Actions Secrets] : https://docs.github.com/en/actions/security-for-github-actions/security-guides/using-secrets-in-github-actions
221
350
[build submodule] : https://github.com/crossplane/build
222
- [`ci.yml`] : https://github.com/crossplane-contrib/function-python/blob/main/.github/workflows/ci.yml
223
351
[crossplane-contrib/provider-workflows] : https://github.com/crossplane-contrib/provider-workflows/blob/main/.github/workflows
352
+ [Upbound Marketplace] : https://marketplace.upbound.io
0 commit comments