Skip to content

Commit

Permalink
Use dynamic matrix to build all versions
Browse files Browse the repository at this point in the history
  • Loading branch information
amercader committed Dec 4, 2024
1 parent 82ac1a0 commit 5c25a90
Show file tree
Hide file tree
Showing 10 changed files with 90 additions and 126 deletions.
10 changes: 0 additions & 10 deletions .github/workflows/build-ckan-2.10-focal.yml

This file was deleted.

62 changes: 62 additions & 0 deletions .github/workflows/build-deb-package.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
name: CKAN deb packages build workflow

on:
push:
paths-ignore:
- 'README.md'

jobs:
get-build-versions:
runs-on: ubuntu-latest
outputs:
versions: ${{ steps.get-versions.outputs.versions }}
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Get versions to build from VERSIONS file
id: get-versions
run: |
# Remove whitespace and line breaks
VERSIONS=$(cat "VERSIONS.json" | tr -d '[:space:]\n')
echo "versions=$VERSIONS" >> $GITHUB_OUTPUT
build:
needs: get-build-versions
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
build: ${{ fromJson(needs.get-build-versions.outputs.versions) }}

name: CKAN ref ${{ matrix.build.ckan_ref }} on Ubuntu ${{ matrix.build.ubuntu_version }}

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Build package
uses: docker/build-push-action@v6
with:
push: false
outputs: "type=local,dest=."
build-args: |
CKAN_REF=${{ matrix.build.ckan_ref }}
UBUNTU_VERSION=${{ matrix.build.ubuntu_version }}
- name: Rename file
# To remove patch version .e.g python-ckan_2.11.1b0-jammy_amd64.deb -> python-ckan_2.11-jammy_amd64.deb
run: |
for f in python-ckan_*; do mv "$f" "$(echo "$f" | sed 's/\([0-9]\+\.[0-9]\+\)[^-]*-/\1-/')"; done
OUTPUT_FILE=$(basename python-ckan*)
echo "OUTPUT_FILE=$OUTPUT_FILE" >> $GITHUB_ENV
echo "Generated file: $OUTPUT_FILE"
- name: Upload deb file
uses: actions/upload-artifact@v4
with:
name: ${{ env.OUTPUT_FILE }}
path: ${{ env.OUTPUT_FILE }}
44 changes: 0 additions & 44 deletions .github/workflows/reusable-build-deb-package.yml

This file was deleted.

8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Builds CKAN deb packages. This script essentially sets up the necessary vars and
positional arguments:
ref The CKAN branch or tag to build (e.g. master, dev-v2.11, ckan-2.10.6...)
target The Ubuntu distribution to target (e.g. focal, jammy, noble...)
target The Ubuntu version to target (e.g. 20.04, 22.04, 24.04...)
optional arguments:
-h, --help show this help message and exit
Expand All @@ -30,9 +30,9 @@ optional arguments:

For instance:

./ckan-package ckan-2.11.1 noble
./ckan-package dev-v2.11 jammy
./ckan-package master noble
./ckan-package ckan-2.11.1 24.04
./ckan-package dev-v2.11 22.04
./ckan-package master 24.04

The currently supported packages are:

Expand Down
3 changes: 0 additions & 3 deletions UBUNTU_VERSIONS.txt

This file was deleted.

18 changes: 18 additions & 0 deletions VERSIONS.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
[
{
"ubuntu_version": "20.04",
"ckan_ref": "ckan-2.10.5"
},
{
"ubuntu_version": "22.04",
"ckan_ref": "ckan-2.10.5"
},
{
"ubuntu_version": "22.04",
"ckan_ref": "ckan-2.11.0"
},
{
"ubuntu_version": "24.04",
"ckan_ref": "ckan-2.11.0"
}
]
15 changes: 6 additions & 9 deletions ckan-package
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
#!/usr/bin/env python

import argparse
import json
import subprocess
import sys


if __name__ == "__main__":
description = """Builds CKAN deb packages.
This script essentially sets up the necessary vars and calls `docker buildx build`."""
Expand All @@ -14,7 +14,7 @@ This script essentially sets up the necessary vars and calls `docker buildx buil
help="The CKAN branch or tag to build (e.g. master, dev-v2.11, ckan-2.10.6...)",
)
parser.add_argument(
"target", help="The Ubuntu distribution to target (e.g. focal, jammy, noble...)"
"target", help="The Ubuntu distribution to target (e.g. 20.04, 22.04, 24.04...)"
)
parser.add_argument(
"-i",
Expand All @@ -29,13 +29,10 @@ This script essentially sets up the necessary vars and calls `docker buildx buil
target = args.target
iteration = args.iteration

supported_targets = {}
with open("UBUNTU_VERSIONS.txt") as f:
for line in f.readlines():
[version, name] = line.split()
supported_targets[name] = version
with open("VERSIONS.json") as f:
supported_versions = json.load(f)

if target not in supported_targets.keys():
if target not in [v["ubuntu_version"] for v in supported_versions]:
print(f"Wrong target: {target}")
sys.exit(1)

Expand All @@ -50,7 +47,7 @@ This script essentially sets up the necessary vars and calls `docker buildx buil
"--build-arg",
f"ITERATION={iteration}",
"--build-arg",
f"UBUNTU_VERSION={supported_targets[target]}",
f"UBUNTU_VERSION={target}",
".",
]

Expand Down
8 changes: 0 additions & 8 deletions common/app.yml

This file was deleted.

22 changes: 0 additions & 22 deletions common/build.yml

This file was deleted.

26 changes: 0 additions & 26 deletions common/web.yml

This file was deleted.

0 comments on commit 5c25a90

Please sign in to comment.