Skip to content
Draft
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
42 changes: 26 additions & 16 deletions .github/workflows/build-test-docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,25 @@ on:
image-tag:
type: string
required: true
platform:
type: string
required: false
default: "linux/amd64"
image-name:
type: string
required: true
cache-from:
type: string
required: false
default: ""
cache-to:
type: string
required: false
default: ""
setup-qemu:
type: string
required: false
default: "false"

jobs:
test-docker-build:
Expand All @@ -14,17 +33,7 @@ jobs:
permissions:
contents: read
packages: read
strategy:
matrix:
include:
- arch: amd64
platform: linux/amd64
image-name: build-amd64
needs-qemu: false
- arch: arm64
platform: linux/arm64
image-name: build-arm64
needs-qemu: true

steps:
- name: Check out the repo
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
Expand All @@ -43,11 +52,12 @@ jobs:
file: ./Dockerfile
push: false
load: true
platforms: ${{ matrix.platform }}
cache-from: type=registry,ref=ghcr.io/elementsinteractive/twyn:buildcache-${{ matrix.arch }}
image-name: ${{ matrix.image-name }}
setup-qemu: ${{ matrix.needs-qemu }}
platforms: ${{ inputs.platform }}
cache-from: ${{ inputs.cache-from }}
cache-to: ${{ inputs.cache-to }}
image-name: ${{ inputs.image-name }}
setup-qemu: ${{ inputs.setup-qemu }}

- name: Test
run: |
docker run --platform ${{ matrix.platform }} --rm ${{ matrix.image-name }}:${{ inputs.image-tag }} --version
docker run --platform ${{ inputs.platform }} --rm ${{ inputs.image-name }}:${{ inputs.image-tag }} --version
39 changes: 22 additions & 17 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,29 @@ jobs:

build_and_test_docker:
uses: ./.github/workflows/build-test-docker.yml
strategy:
matrix:
include:
- platform: linux/amd64
cache-from: type=registry,ref=ghcr.io/elementsinteractive/twyn:buildcache-amd64
cache-to: type=registry,ref=ghcr.io/elementsinteractive/twyn:buildcache-amd64
image-name: build-amd64
setup-qemu: false
- platform: linux/arm64
cache-from: type=registry,ref=ghcr.io/elementsinteractive/twyn:buildcache-arm64
cache-to: type=registry,ref=ghcr.io/elementsinteractive/twyn:buildcache-arm64
image-name: build-arm64
setup-qemu: true

with:
image-tag: latest
image-tag: "pr-${{ github.event.pull_request.number }}"
platform: ${{ matrix.platform }}
cache-from: ${{ matrix.cache-from }}
cache-to: ${{ matrix.cache-to }}
image-name: ${{ matrix.image-name }}
setup-qemu: ${{ matrix.setup-qemu }}

secrets: inherit

publish_to_pypi:
name: Publish to PyPI
Expand Down Expand Up @@ -77,22 +98,6 @@ jobs:
type=registry,ref=ghcr.io/elementsinteractive/twyn:buildcache-amd64
type=registry,ref=ghcr.io/elementsinteractive/twyn:buildcache-arm64

- name: Delete old cache entries
env:
GH_TOKEN: ${{ github.token }}
run: |
# Get all versions of the container package
versions=$(gh api "orgs/elementsinteractive/packages/container/twyn/versions" --paginate)

# Extract version IDs that do NOT have any buildcache-* tags (buildcache-amd64, buildcache-arm64, etc.)
ids_to_delete=$(echo "$versions" | jq -r '.[] | select(.metadata.container.tags | map(test("^buildcache-")) | any | not) | .id')

# Delete them
for id in $ids_to_delete; do
echo "Deleting old cache version ID: $id"
gh api -X DELETE "orgs/elementsinteractive/packages/container/twyn/versions/$id"
done

release_notes:
runs-on: ubuntu-latest
needs: [publish_to_pypi, publish_to_dockerhub]
Expand Down
21 changes: 21 additions & 0 deletions .github/workflows/trigger-test-docker-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,5 +37,26 @@ jobs:
name: Trigger test Docker build
if: (needs.should-test-docker-build.outputs.workflow == 'true' || needs.should-test-docker-build.outputs.docker == 'true')
uses: ./.github/workflows/build-test-docker.yml
strategy:
matrix:
include:
- platform: linux/amd64
cache-from: type=registry,ref=ghcr.io/elementsinteractive/twyn:buildcache-amd64
cache-to: ""
image-name: build-amd64
setup-qemu: false
- platform: linux/arm64
cache-from: type=registry,ref=ghcr.io/elementsinteractive/twyn:buildcache-arm64
cache-to: ""
image-name: build-arm64
setup-qemu: true

with:
image-tag: "pr-${{ github.event.pull_request.number }}"
platform: ${{ matrix.platform }}
cache-from: ${{ matrix.cache-from }}
cache-to: ${{ matrix.cache-to }}
image-name: ${{ matrix.image-name }}
setup-qemu: ${{ matrix.setup-qemu }}

secrets: inherit
Loading