-
Notifications
You must be signed in to change notification settings - Fork 39
Updates to build.sh #126
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
kowh-ai
wants to merge
2
commits into
main
Choose a base branch
from
more-updates-to-build.sh
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Updates to build.sh #126
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -10,14 +10,77 @@ log() { | |
| show_versions() { | ||
| echo "Available CKAN versions:" | ||
| count=1 | ||
|
|
||
| # Collect all directories matching the pattern "ckan-*" | ||
| versions=() | ||
| for dir in ckan-*; do | ||
| if [ -f "$dir/VERSION.txt" ]; then | ||
| patchversion=$(<"$dir/VERSION.txt") | ||
| minorversion="${patchversion%.*}" | ||
| echo "$count. $minorversion (patch version: $patchversion)" | ||
| ((count++)) | ||
| versions+=("$patchversion") | ||
| fi | ||
| done | ||
|
|
||
| # Sort versions: master first, then descending numerical order | ||
| sorted_versions=$(printf "%s\n" "${versions[@]}" | sort -rV | sed '/^master$/d') | ||
| sorted_versions="master"$'\n'"$sorted_versions" | ||
|
|
||
| # Display sorted versions | ||
| for version in $sorted_versions; do | ||
| minorversion="${version%.*}" | ||
| echo "$count. $minorversion (patch version: $version)" | ||
| ((count++)) | ||
| done | ||
| } | ||
|
|
||
| show_tags() { | ||
| echo "Available CKAN tags:" | ||
|
|
||
| # Collect all directories matching the pattern "ckan-*" | ||
| versions=() | ||
| for dir in ckan-*; do | ||
| if [ -f "$dir/VERSION.txt" ]; then | ||
| patchversion=$(<"$dir/VERSION.txt") | ||
| versions+=("$patchversion") | ||
| fi | ||
| done | ||
|
|
||
| # Sort versions: master first, then descending numerical order | ||
| sorted_versions=$(printf "%s\n" "${versions[@]}" | sort -rV | sed '/^master$/d') | ||
| sorted_versions="master"$'\n'"$sorted_versions" | ||
|
|
||
| # Process sorted versions | ||
| last_git_tag=$(git describe --tags --abbrev=0) | ||
| last_minor_version="" | ||
| for version in $sorted_versions; do | ||
| if [[ "$version" == "master" ]]; then | ||
| # Special case for master | ||
| python_version=$(cat "ckan-master/PYTHON_VERSION.txt") | ||
| echo "Tags for CKAN version master:" | ||
| echo " - master" | ||
| echo " - master-py$python_version" | ||
| echo " - master-py$python_version-$last_git_tag" | ||
| else | ||
| # Handle regular versions | ||
| minor_version="${version%.*}" # Extract the minor version (e.g., 2.11) | ||
| python_version=$(cat "ckan-$minor_version/PYTHON_VERSION.txt") | ||
|
|
||
| echo "Tags for CKAN version $minor_version (patch version: $version):" | ||
| # Print minor version tag only once | ||
| if [[ "$minor_version" != "$last_minor_version" ]]; then | ||
| echo " - $minor_version" | ||
| echo " - $minor_version-$last_git_tag" | ||
| echo " - $minor_version-py$python_version" | ||
| echo " - $minor_version-py$python_version-$last_git_tag" | ||
| fi | ||
| # Print full version tag | ||
| echo " - $version" | ||
| echo " - $version-$last_git_tag" | ||
| echo " - $version-py$python_version" | ||
| echo " - $version-py$python_version-$last_git_tag" | ||
| last_minor_version="$minor_version" | ||
| fi | ||
| echo "" | ||
| done | ||
| } | ||
|
|
||
| push_images() { | ||
|
|
@@ -28,19 +91,37 @@ push_images() { | |
| log "Pushing image: $tag_name" | ||
| docker push "$tag_name" | ||
| docker push "$alt_tag_name" | ||
|
|
||
|
|
||
| # Check if a Python Dockerfile exists | ||
| if [[ -n "$python_dockerfile" ]]; then | ||
| log "Pushing image: $python_tag_name" | ||
| docker push "$python_tag_name" | ||
| docker push "$python_alt_tag_name" | ||
|
|
||
| # If not, check if the CKAN version is greater than 2.10 | ||
| elif [[ "$ckan_version_ref" =~ ^([2-9])\.([0-9]+) ]]; then | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We don't need this |
||
| major=${BASH_REMATCH[1]} | ||
| minor=${BASH_REMATCH[2]} | ||
|
|
||
| # Check if major version is greater than 2 or if it's 2 and minor is greater than 10 | ||
| if [[ $major -gt 2 || ($major -eq 2 && $minor -gt 10) ]]; then | ||
| log "Pushing image: $python_tag_name" | ||
| docker push "$python_tag_name" | ||
| docker push "$python_alt_tag_name" | ||
| fi | ||
| fi | ||
| } | ||
|
|
||
| set_vars() { | ||
| local ckan_version_ref="$1" | ||
| local env="$2" | ||
| local python_version="$3" | ||
|
|
||
| if [ ! -d "ckan-$ckan_version_ref" ]; then | ||
| echo "Unknown version: $ckan_version_ref" | ||
| exit 1 | ||
| fi | ||
|
|
||
| ckan_version=$(cat "ckan-$ckan_version_ref/VERSION.txt") | ||
| if [ -z "$python_version" ]; then | ||
| PYTHON_VERSION=$(cat "ckan-$ckan_version_ref/PYTHON_VERSION.txt") | ||
|
|
@@ -119,6 +200,7 @@ show_usage() { | |
| echo "Usage: $0 <action> [<params>]" | ||
| echo "Available actions:" | ||
| echo " versions - Shows the current CKAN versions used" | ||
| echo " tags - Shows all tags for all CKAN versions" | ||
| echo " build <version> [base|dev] [py version] - Builds images for a CKAN version" | ||
| echo " Optionally specify 'base' or 'dev'." | ||
| echo " Optionally specify a Python version." | ||
|
|
@@ -137,6 +219,9 @@ case "$action" in | |
| "versions") | ||
| show_versions | ||
| ;; | ||
| "tags") | ||
| show_tags | ||
| ;; | ||
| "build") | ||
| ckan_version_ref=$2 | ||
|
|
||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.