Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
284 changes: 141 additions & 143 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,12 @@ on:
env:
# Common versions
PYTHON_VERSION: '3.14.0' # TODO: Used?
HATCH_VERSION: '1.14.2'
DOCKER_BUILDX_VERSION: 'v0.26.1'

# These environment variables are important to the Crossplane CLI install.sh
# script. They determine what version it installs.
XP_CHANNEL: stable
# v2.2.0 does not allow functions to include anything but CRDs.
XP_VERSION: v2.1.0
XP_VERSION: v2.2.0

# This CI job will automatically push new builds to xpkg.upbound.io if the
# XPKG_ACCESS_ID and XPKG_TOKEN secrets are set in the GitHub respository (or
Expand Down Expand Up @@ -52,8 +50,8 @@ jobs:
# with:
# python-version: ${{ env.PYTHON_VERSION }}

# - name: Setup Hatch
# run: pipx install hatch==${{ env.HATCH_VERSION }}
# - name: Install Hatch
# uses: pypa/hatch@install

# - name: Lint
# run: hatch run lint:check
Expand All @@ -69,8 +67,8 @@ jobs:
with:
python-version: ${{ env.PYTHON_VERSION }}

- name: Setup Hatch
run: pipx install hatch==${{ env.HATCH_VERSION }}
- name: Install Hatch
uses: pypa/hatch@install

- name: Run Unit Tests
run: hatch run test:ci
Expand All @@ -94,38 +92,38 @@ jobs:
build-pypi:
runs-on: ubuntu-24.04
steps:
- name: Checkout
uses: actions/checkout@v6

- name: Setup Python
uses: actions/setup-python@v6
with:
python-version: ${{ env.PYTHON_VERSION }}

- name: Setup Hatch
run: pipx install hatch==${{ env.HATCH_VERSION }}

# If a version wasn't explicitly passed as a workflow_dispatch input we
# default to version v0.0.0+<git-commit-date>-<git-short-sha>, for example
# v0.0.0+20231101115142-1091066df799. This is a simple implementation of
# Go's pseudo-versions: https://go.dev/ref/mod#pseudo-versions.
- name: Set Default PyPI Project Version
if: env.PYPI_VERSION == ''
run: echo "PYPI_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

- name: Set PyPI Project Version
run: hatch version ${{ env.PYPI_VERSION }}

- name: Build Sdist and Wheel
run: hatch build

- name: Upload Sdist and Wheel to GitHub
uses: actions/upload-artifact@v7
with:
name: dist
path: "dist/*"
if-no-files-found: error
retention-days: 1
- name: Checkout
uses: actions/checkout@v6

- name: Setup Python
uses: actions/setup-python@v6
with:
python-version: ${{ env.PYTHON_VERSION }}

- name: Install Hatch
uses: pypa/hatch@install

# If a version wasn't explicitly passed as a workflow_dispatch input we
# default to version v0.0.0+<git-commit-date>-<git-short-sha>, for example
# v0.0.0+20231101115142-1091066df799. This is a simple implementation of
# Go's pseudo-versions: https://go.dev/ref/mod#pseudo-versions.
- name: Set Default PyPI Project Version
if: env.PYPI_VERSION == ''
run: echo "PYPI_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

- name: Set PyPI Project Version
run: hatch version ${{ env.PYPI_VERSION }}

- name: Build Sdist and Wheel
run: hatch build

- name: Upload Sdist and Wheel to GitHub
uses: actions/upload-artifact@v7
with:
name: dist
path: "dist/*"
if-no-files-found: error
retention-days: 1

# We want to build most packages for the amd64 and arm64 architectures. To
# speed this up we build single-platform packages in parallel. We then upload
Expand All @@ -142,55 +140,55 @@ jobs:
- amd64
- arm64
steps:
- name: Setup QEMU
uses: docker/setup-qemu-action@v4
with:
platforms: all

- name: Setup Docker Buildx
uses: docker/setup-buildx-action@v4
with:
version: ${{ env.DOCKER_BUILDX_VERSION }}
install: true

- name: Checkout
uses: actions/checkout@v6

- name: Download Wheel from GitHub
uses: actions/download-artifact@v8
with:
name: dist
pattern: '*.whl'
path: dist

# 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@v7
with:
context: .
platforms: linux/${{ matrix.arch }}
cache-from: type=gha
cache-to: type=gha,mode=max
target: image
build-args:
PYTHON_VERSION=${{ env.PYTHON_VERSION }}
outputs: type=docker,dest=runtime-${{ matrix.arch }}.tar

- name: Setup the Crossplane CLI
run: "mkdir bin && cd bin && curl -sL https://raw.githubusercontent.com/crossplane/crossplane/master/install.sh | sh"

- name: Build Package
run: bin/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@v7
with:
name: package-${{ matrix.arch }}
path: "*.xpkg"
if-no-files-found: error
retention-days: 1
- name: Setup QEMU
uses: docker/setup-qemu-action@v4
with:
platforms: all

- name: Setup Docker Buildx
uses: docker/setup-buildx-action@v4
with:
version: ${{ env.DOCKER_BUILDX_VERSION }}
install: true

- name: Checkout
uses: actions/checkout@v6

- name: Download Wheel from GitHub
uses: actions/download-artifact@v8
with:
name: dist
pattern: '*.whl'
path: dist

# 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@v7
with:
context: .
platforms: linux/${{ matrix.arch }}
cache-from: type=gha
cache-to: type=gha,mode=max
target: image
build-args:
PYTHON_VERSION=${{ env.PYTHON_VERSION }}
outputs: type=docker,dest=runtime-${{ matrix.arch }}.tar

- name: Setup the Crossplane CLI
run: "mkdir bin && cd bin && curl -sL https://raw.githubusercontent.com/crossplane/crossplane/master/install.sh | sh"

- name: Build Package
run: bin/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@v7
with:
name: package-${{ matrix.arch }}
path: "*.xpkg"
if-no-files-found: error
retention-days: 1

publish-pypi:
# Don't publish unless we were run with an explicit version.
Expand All @@ -199,20 +197,20 @@ jobs:
- build-xpkg # only publish if xpkg builds succeeds
runs-on: ubuntu-24.04
steps:
- name: Download Sdist and Wheel from GitHub
uses: actions/download-artifact@v8
with:
name: dist
path: dist
- name: Download Sdist and Wheel from GitHub
uses: actions/download-artifact@v8
with:
name: dist
path: dist

- name: Setup Hatch
run: pipx install hatch==${{ env.HATCH_VERSION }}
- name: Install Hatch
uses: pypa/hatch@install

- name: Publish to PyPI
env:
HATCH_INDEX_USER: __token__
HATCH_INDEX_AUTH: ${{ secrets.PYPI_API_TOKEN }}
run: hatch publish --no-prompt
- name: Publish to PyPI
env:
HATCH_INDEX_USER: __token__
HATCH_INDEX_AUTH: ${{ secrets.PYPI_API_TOKEN }}
run: hatch publish --no-prompt

# This job downloads the single-platform packages built by the build job, and
# pushes them as a multi-platform package. We only push the package it the
Expand All @@ -227,46 +225,46 @@ jobs:
contents: read
packages: write
steps:
- name: Checkout
uses: actions/checkout@v6

- name: Download Single-Platform Packages
uses: actions/download-artifact@v8
with:
# See https://github.com/docker/build-push-action/blob/263435/README.md#summaries
pattern: "!*.dockerbuild"
path: .
merge-multiple: true

- name: Setup the Crossplane CLI
run: "mkdir bin && cd bin && curl -sL https://raw.githubusercontent.com/crossplane/crossplane/master/install.sh | sh"

# If a version wasn't explicitly passed as a workflow_dispatch input we
# default to version v0.0.0-<git-commit-date>-<git-short-sha>, for example
# v0.0.0-20231101115142-1091066df799. This is a simple implementation of
# Go's pseudo-versions: https://go.dev/ref/mod#pseudo-versions.
- name: Set Default Multi-Platform Package Version
if: env.XPKG_VERSION == ''
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

- name: Login to Upbound
uses: docker/login-action@v4
if: env.XPKG_ACCESS_ID != ''
with:
registry: xpkg.upbound.io
username: ${{ secrets.XPKG_ACCESS_ID }}
password: ${{ secrets.XPKG_TOKEN }}

- name: Push Multi-Platform Package to Upbound
if: env.XPKG_ACCESS_ID != ''
run: "bin/crossplane --verbose xpkg push --package-files $(echo *.xpkg|tr ' ' ,) ${{ env.XPKG }}:${{ env.XPKG_VERSION }}"

- name: Login to GHCR
uses: docker/login-action@v4
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Push Multi-Platform Package to GHCR
run: "bin/crossplane --verbose xpkg push --package-files $(echo *.xpkg|tr ' ' ,) ${{ env.CROSSPLANE_REGORG }}:${{ env.XPKG_VERSION }}"
- name: Checkout
uses: actions/checkout@v6

- name: Download Single-Platform Packages
uses: actions/download-artifact@v8
with:
# See https://github.com/docker/build-push-action/blob/263435/README.md#summaries
pattern: "!*.dockerbuild"
path: .
merge-multiple: true

- name: Setup the Crossplane CLI
run: "mkdir bin && cd bin && curl -sL https://raw.githubusercontent.com/crossplane/crossplane/master/install.sh | sh"

# If a version wasn't explicitly passed as a workflow_dispatch input we
# default to version v0.0.0-<git-commit-date>-<git-short-sha>, for example
# v0.0.0-20231101115142-1091066df799. This is a simple implementation of
# Go's pseudo-versions: https://go.dev/ref/mod#pseudo-versions.
- name: Set Default Multi-Platform Package Version
if: env.XPKG_VERSION == ''
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

- name: Login to Upbound
uses: docker/login-action@v4
if: env.XPKG_ACCESS_ID != ''
with:
registry: xpkg.upbound.io
username: ${{ secrets.XPKG_ACCESS_ID }}
password: ${{ secrets.XPKG_TOKEN }}

- name: Push Multi-Platform Package to Upbound
if: env.XPKG_ACCESS_ID != ''
run: "bin/crossplane --verbose xpkg push --package-files $(echo *.xpkg|tr ' ' ,) ${{ env.XPKG }}:${{ env.XPKG_VERSION }}"

- name: Login to GHCR
uses: docker/login-action@v4
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Push Multi-Platform Package to GHCR
run: "bin/crossplane --verbose xpkg push --package-files $(echo *.xpkg|tr ' ' ,) ${{ env.CROSSPLANE_REGORG }}:${{ env.XPKG_VERSION }}"
Loading
Loading