@@ -51,105 +51,78 @@ jobs:
51
51
wget -qO /usr/local/bin/yq https://github.com/mikefarah/yq/releases/latest/download/yq_linux_amd64
52
52
chmod +x /usr/local/bin/yq
53
53
54
- - name : Find extensions
55
- id : find_extensions
54
+ - name : Process and build extensions
56
55
run : |
56
+ # Get branch name
57
+ branch="${GITHUB_REF##*/}"
58
+
59
+ # Convert repository owner to lowercase for Docker compatibility
60
+ REPO_OWNER="${{ github.repository_owner }}"
61
+ REPO_OWNER_LOWER=$(echo "$REPO_OWNER" | tr '[:upper:]' '[:lower:]')
62
+
63
+ # Find extensions based on input or search all
57
64
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
65
+ if [[ ! -d "extensions/${{ github.event.inputs.specific_extension }}" ]]; then
63
66
echo "::error::Extension directory not found: extensions/${{ github.event.inputs.specific_extension }}"
64
67
exit 1
65
68
fi
69
+ extension_files=$(find extensions/${{ github.event.inputs.specific_extension }} -name 'bioc-extension.yaml')
70
+ echo "Building specific extension: ${{ github.event.inputs.specific_extension }}"
66
71
else
67
- # Find all extensions
68
- echo "extensions=$(find extensions -name 'bioc-extension.yaml' | sort)" >> $GITHUB_OUTPUT
72
+ extension_files=$(find extensions -name 'bioc-extension.yaml' | sort)
69
73
echo "Building all available extensions"
70
74
fi
71
-
72
- - name : Extract extension data to files
73
- run : |
74
- branch="${GITHUB_REF##*/}"
75
-
76
- # Create empty files
77
- > /tmp/basenames.txt
78
- > /tmp/basetags.txt
79
- > /tmp/outnames.txt
80
- > /tmp/dirs.txt
81
75
82
- for ext_file in $(echo "${{ steps.find_extensions.outputs.extensions }}"); do
76
+ # Process each extension file directly
77
+ for ext_file in $extension_files; do
83
78
ext_dir=$(dirname "$ext_file")
84
79
ext_name=$(basename "$ext_dir")
85
80
86
81
echo "Processing extension: $ext_name from $ext_file"
87
82
88
- # Parse YAML directly using yq - convert outname to lowercase
89
- outname=$(yq '.container.outname' "$ext_file" | tr '[:upper:]' '[:lower:]')
90
- base_image=$(yq '.container.base.image' "$ext_file" | tr '[:upper:]' '[:lower:]')
91
-
92
83
# Check if Dockerfile exists
93
84
if [[ ! -f "$ext_dir/Dockerfile" ]]; then
94
85
echo "::warning::No Dockerfile found for extension $ext_name, skipping"
95
86
continue
96
87
fi
97
88
89
+ # Parse YAML directly using yq
90
+ outname=$(yq '.container.outname' "$ext_file" | tr '[:upper:]' '[:lower:]')
91
+ base_image=$(yq '.container.base.image' "$ext_file" | tr '[:upper:]' '[:lower:]')
92
+
98
93
# Handle tags
99
94
tags_count=$(yq '.container.base.tag | length' "$ext_file")
100
95
101
- # If no tags defined, use branch name as default tag
96
+ # Build for each tag (or branch name if no tags specified)
102
97
if [[ $tags_count -eq 0 ]]; then
103
- echo "$outname" >> /tmp/outnames.txt
104
- echo "$base_image" >> /tmp/basenames.txt
105
- echo "$branch" >> /tmp/basetags.txt
106
- echo "$ext_dir" >> /tmp/dirs.txt
98
+ tags=("$branch")
107
99
else
108
- # For each tag, create a line in each file
100
+ # Get all tags as an array
101
+ tags=()
109
102
for (( i=0; i<$tags_count; i++ )); do
110
- tag=$(yq ".container.base.tag[$i]" "$ext_file")
111
- echo "$outname" >> /tmp/outnames.txt
112
- echo "$base_image" >> /tmp/basenames.txt
113
- echo "$tag" >> /tmp/basetags.txt
114
- echo "$ext_dir" >> /tmp/dirs.txt
103
+ tags+=("$(yq ".container.base.tag[$i]" "$ext_file")")
115
104
done
116
105
fi
117
- done
118
-
119
- echo "Files created with build data:"
120
- echo "===== Outnames ====="
121
- cat /tmp/outnames.txt
122
- echo "===== Base Images ====="
123
- cat /tmp/basenames.txt
124
- echo "===== Tags ====="
125
- cat /tmp/basetags.txt
126
- echo "===== Directories ====="
127
- cat /tmp/dirs.txt
128
-
129
- - name : Build extensions
130
- run : |
131
- # Check if we have any extensions to build
132
- if [[ ! -s /tmp/outnames.txt ]]; then
133
- echo "No extensions to build"
134
- exit 0
135
- fi
136
-
137
- # Convert repository owner to lowercase for Docker compatibility
138
- REPO_OWNER="${{ github.repository_owner }}"
139
- REPO_OWNER_LOWER=$(echo "$REPO_OWNER" | tr '[:upper:]' '[:lower:]')
140
-
141
- # Process line by line with paste command
142
- paste /tmp/outnames.txt /tmp/basenames.txt /tmp/basetags.txt /tmp/dirs.txt | while read outname base_image tag ext_dir; do
143
- echo "Building $outname:$tag from $base_image:$tag using Dockerfile in $ext_dir"
144
-
145
- # Build and push with lowercase names
146
- docker buildx build --platform linux/amd64 \
147
- -t "ghcr.io/$REPO_OWNER_LOWER/$outname:$tag" \
148
- -t "docker.io/$REPO_OWNER_LOWER/$outname:$tag" \
149
- --build-arg BASE_IMAGE=$base_image \
150
- --build-arg TAG=$tag \
151
- --push \
152
- "$ext_dir"
153
106
154
- echo "Successfully built and pushed $outname:$tag"
107
+ # Build for each tag
108
+ for tag in "${tags[@]}"; do
109
+ echo "Building $outname:$tag from $base_image:$tag using Dockerfile in $ext_dir"
110
+
111
+ # Build and push with lowercase names
112
+ docker buildx build --platform linux/amd64 \
113
+ -t "ghcr.io/$REPO_OWNER_LOWER/$outname:$tag" \
114
+ -t "docker.io/$REPO_OWNER_LOWER/$outname:$tag" \
115
+ --build-arg BASE_IMAGE=$base_image \
116
+ --build-arg TAG=$tag \
117
+ --push \
118
+ "$ext_dir"
119
+
120
+ build_result=$?
121
+ if [ $build_result -ne 0 ]; then
122
+ echo "::error::Failed to build $outname:$tag"
123
+ exit $build_result
124
+ fi
125
+
126
+ echo "Successfully built and pushed $outname:$tag"
127
+ done
155
128
done
0 commit comments