Skip to content

Commit 3ab9540

Browse files
committed
Separate extensions
1 parent 9045225 commit 3ab9540

File tree

2 files changed

+127
-108
lines changed

2 files changed

+127
-108
lines changed

.github/workflows/build_containers.yaml

Lines changed: 3 additions & 108 deletions
Original file line numberDiff line numberDiff line change
@@ -4,23 +4,15 @@ on:
44
branches:
55
- devel
66
- RELEASE_*
7+
paths-ignore:
8+
- 'extensions/**'
79
workflow_dispatch:
8-
inputs:
9-
only_extensions:
10-
description: 'Run only the extensions part of the workflow'
11-
required: false
12-
default: 'false'
13-
type: choice
14-
options:
15-
- 'true'
16-
- 'false'
1710
schedule:
1811
- cron: '0 18 * * 5'
1912

2013
jobs:
2114
build-amd64:
2215
runs-on: ubuntu-latest
23-
if: ${{ github.event_name != 'workflow_dispatch' || github.event.inputs.only_extensions != 'true' }}
2416
strategy:
2517
fail-fast: false
2618
matrix:
@@ -100,7 +92,6 @@ jobs:
10092

10193
build-arm64:
10294
runs-on: ubuntu-latest-arm64
103-
if: ${{ github.event_name != 'workflow_dispatch' || github.event.inputs.only_extensions != 'true' }}
10495
strategy:
10596
fail-fast: false
10697
matrix:
@@ -176,7 +167,7 @@ jobs:
176167
merge:
177168
needs: [build-amd64, build-arm64]
178169
runs-on: ubuntu-latest
179-
if: ${{ always() && (github.event_name != 'workflow_dispatch' || github.event.inputs.only_extensions != 'true') }}
170+
if: always()
180171
strategy:
181172
fail-fast: false
182173
matrix:
@@ -290,99 +281,3 @@ jobs:
290281
- name: Inspect images
291282
run: |
292283
cat /tmp/tags | xargs -i bash -c 'docker buildx imagetools inspect {}'
293-
294-
extensions:
295-
needs: [merge]
296-
if: ${{ always() && (github.event_name != 'workflow_dispatch' || needs.merge.result != 'skipped') }}
297-
runs-on: ubuntu-latest
298-
steps:
299-
- uses: actions/checkout@v4
300-
301-
- name: Free root space
302-
uses: almahmoud/free-root-space@main
303-
with:
304-
verbose: true
305-
306-
- name: Set up QEMU
307-
uses: docker/setup-qemu-action@v3
308-
309-
- name: Set up Docker Buildx
310-
uses: docker/setup-buildx-action@v3
311-
312-
- name: Login to GHCR
313-
uses: docker/login-action@v3
314-
with:
315-
registry: ghcr.io
316-
username: ${{ github.actor }}
317-
password: ${{ secrets.GITHUB_TOKEN }}
318-
319-
- name: Login to Dockerhub
320-
uses: docker/login-action@v3
321-
with:
322-
username: ${{ secrets.DOCKER_USERNAME }}
323-
password: ${{ secrets.DOCKER_PASSWORD }}
324-
325-
- name: Install dependencies
326-
run: |
327-
# Install yq for YAML parsing
328-
wget -qO /usr/local/bin/yq https://github.com/mikefarah/yq/releases/latest/download/yq_linux_amd64
329-
chmod +x /usr/local/bin/yq
330-
331-
- name: Find extensions
332-
id: find_extensions
333-
run: |
334-
echo "extensions=$(find extensions -name 'bioc-extension.yaml' | sort)" >> $GITHUB_OUTPUT
335-
336-
- name: Process extensions
337-
run: |
338-
mkdir -p /tmp/extension_builds
339-
branch="${GITHUB_REF##*/}"
340-
341-
for ext_file in $(echo "${{ steps.find_extensions.outputs.extensions }}"); do
342-
ext_dir=$(dirname "$ext_file")
343-
ext_name=$(basename "$ext_dir")
344-
345-
echo "Processing extension: $ext_name from $ext_file"
346-
347-
# Parse YAML directly using yq
348-
outname=$(yq '.container.outname' "$ext_file")
349-
base_image=$(yq '.container.base.image' "$ext_file")
350-
351-
# Handle tags which could be a string, list, or map
352-
tags=$(yq -o=json '.container.base.tag' "$ext_file")
353-
354-
# Process tags based on their type
355-
if [[ "$tags" == "null" ]]; then
356-
tags="$branch"
357-
elif [[ "$tags" == "{\"*\"}" ]]; then
358-
# Handle object format like {"3.21", "devel"}
359-
tags=$(echo "$tags" | jq -r 'keys | join(" ")')
360-
elif [[ "$tags" == "[*]" ]]; then
361-
# Handle array format
362-
tags=$(echo "$tags" | jq -r 'join(" ")')
363-
fi
364-
365-
echo "Building extension $ext_name: $outname from $base_image with tags: $tags"
366-
367-
# Process each tag
368-
for tag in $tags; do
369-
echo "Building for tag: $tag"
370-
371-
# Check for Dockerfile in extension directory
372-
if [ -f "$ext_dir/Dockerfile" ]; then
373-
echo "Using extension Dockerfile at $ext_dir/Dockerfile"
374-
375-
docker buildx build --platform linux/amd64 \
376-
-t "ghcr.io/${{ github.repository_owner }}/$outname:$tag" \
377-
-t "docker.io/${{ github.repository_owner }}/$outname:$tag" \
378-
--build-arg BASE_IMAGE=$base_image \
379-
--build-arg TAG=$tag \
380-
--push \
381-
"$ext_dir"
382-
383-
echo "Successfully built and pushed $outname:$tag"
384-
else
385-
echo "No Dockerfile found for extension $ext_name"
386-
fi
387-
done
388-
done
Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
name: Build Bioconductor Extension Images
2+
on:
3+
push:
4+
branches:
5+
- devel
6+
- RELEASE_*
7+
paths:
8+
- 'extensions/**'
9+
workflow_dispatch:
10+
inputs:
11+
specific_extension:
12+
description: 'Build only a specific extension (folder name in extensions/)'
13+
required: false
14+
type: string
15+
schedule:
16+
- cron: '0 20 * * 5' # Run every Friday at 8PM UTC
17+
18+
jobs:
19+
build-extensions:
20+
runs-on: ubuntu-latest
21+
steps:
22+
- uses: actions/checkout@v4
23+
24+
- name: Free root space
25+
uses: almahmoud/free-root-space@main
26+
with:
27+
verbose: true
28+
29+
- name: Set up QEMU
30+
uses: docker/setup-qemu-action@v3
31+
32+
- name: Set up Docker Buildx
33+
uses: docker/setup-buildx-action@v3
34+
35+
- name: Login to GHCR
36+
uses: docker/login-action@v3
37+
with:
38+
registry: ghcr.io
39+
username: ${{ github.actor }}
40+
password: ${{ secrets.GITHUB_TOKEN }}
41+
42+
- name: Login to Dockerhub
43+
uses: docker/login-action@v3
44+
with:
45+
username: ${{ secrets.DOCKER_USERNAME }}
46+
password: ${{ secrets.DOCKER_PASSWORD }}
47+
48+
- name: Install dependencies
49+
run: |
50+
# Install yq for YAML parsing
51+
wget -qO /usr/local/bin/yq https://github.com/mikefarah/yq/releases/latest/download/yq_linux_amd64
52+
chmod +x /usr/local/bin/yq
53+
54+
- name: Find extensions
55+
id: find_extensions
56+
run: |
57+
if [[ -n "${{ github.event.inputs.specific_extension }}" ]]; then
58+
# Check if the specified extension exists
59+
if [[ -d "extensions/${{ github.event.inputs.specific_extension }}" ]]; then
60+
echo "extensions=$(find extensions/${{ github.event.inputs.specific_extension }} -name 'bioc-extension.yaml')" >> $GITHUB_OUTPUT
61+
echo "Building specific extension: ${{ github.event.inputs.specific_extension }}"
62+
else
63+
echo "::error::Extension directory not found: extensions/${{ github.event.inputs.specific_extension }}"
64+
exit 1
65+
fi
66+
else
67+
# Find all extensions
68+
echo "extensions=$(find extensions -name 'bioc-extension.yaml' | sort)" >> $GITHUB_OUTPUT
69+
echo "Building all available extensions"
70+
fi
71+
72+
- name: Process extensions
73+
run: |
74+
mkdir -p /tmp/extension_builds
75+
branch="${GITHUB_REF##*/}"
76+
77+
for ext_file in $(echo "${{ steps.find_extensions.outputs.extensions }}"); do
78+
ext_dir=$(dirname "$ext_file")
79+
ext_name=$(basename "$ext_dir")
80+
81+
echo "Processing extension: $ext_name from $ext_file"
82+
83+
# Parse YAML directly using yq
84+
outname=$(yq '.container.outname' "$ext_file")
85+
base_image=$(yq '.container.base.image' "$ext_file")
86+
87+
# Handle tags which could be a string, list, or map
88+
tags=$(yq -o=json '.container.base.tag' "$ext_file")
89+
90+
# Process tags based on their type
91+
if [[ "$tags" == "null" ]]; then
92+
tags="$branch"
93+
elif [[ "$tags" == "{\"*\"}" ]]; then
94+
# Handle object format like {"3.21", "devel"}
95+
tags=$(echo "$tags" | jq -r 'keys | join(" ")')
96+
elif [[ "$tags" == "[*]" ]]; then
97+
# Handle array format
98+
tags=$(echo "$tags" | jq -r 'join(" ")')
99+
fi
100+
101+
echo "Building extension $ext_name: $outname from $base_image with tags: $tags"
102+
103+
# Process each tag
104+
for tag in $tags; do
105+
echo "Building for tag: $tag"
106+
107+
# Check for Dockerfile in extension directory
108+
if [ -f "$ext_dir/Dockerfile" ]; then
109+
echo "Using extension Dockerfile at $ext_dir/Dockerfile"
110+
111+
docker buildx build --platform linux/amd64 \
112+
-t "ghcr.io/${{ github.repository_owner }}/$outname:$tag" \
113+
-t "docker.io/${{ github.repository_owner }}/$outname:$tag" \
114+
--build-arg BASE_IMAGE=$base_image \
115+
--build-arg TAG=$tag \
116+
--push \
117+
"$ext_dir"
118+
119+
echo "Successfully built and pushed $outname:$tag"
120+
else
121+
echo "No Dockerfile found for extension $ext_name"
122+
fi
123+
done
124+
done

0 commit comments

Comments
 (0)