Skip to content
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

Tagging hotfix #39

Merged
merged 1 commit into from
Feb 16, 2023
Merged
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
62 changes: 34 additions & 28 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,52 +56,59 @@ jobs:
id: generate-tags
shell: bash
run: |
echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT

container_tags=()
# The following is run when the timer is triggered or a merge/push to main
# Generate a timestamp for creating an image version history
TIMESTAMP="$(date +%Y%m%d)"
VARIANT="${{ matrix.major_version }}-${{ matrix.driver_version }}"

COMMIT_TAGS=()
BUILD_TAGS=()

container_tags+=("${{ matrix.major_version }}-${{ matrix.driver_version }}")
# Have tags for tracking builds during pull request
SHA_SHORT="$(git rev-parse --short HEAD)"
COMMIT_TAGS+=("pr-${{ github.event.number }}-${VARIANT}")
COMMIT_TAGS+=("${SHA_SHORT}-${VARIANT}")

if [[ "${{ matrix.is_latest_version }}" == "true" ]] && \
[[ "${{ matrix.is_stable_version }}" == "true" ]]; then
BRANCH="stable"
elif [[ "${{ matrix.is_latest_version }}" == "true" ]] && \
[[ "${{ matrix.is_stable_version }}" != "true" ]]; then
BRANCH="unstable"
else
BRANCH="oldstable"
[[ "${{ matrix.is_stable_version }}" == "true" ]] && \
[[ "${{ matrix.is_latest_driver }}" == "true" ]]; then
COMMIT_TAGS+=("pr-${{ github.event.number }}")
COMMIT_TAGS+=("${SHA_SHORT}")
fi

BUILD_TAGS=("${VARIANT}")

if [[ "${{ matrix.is_latest_driver }}" == "true" ]]; then
container_tags+=("${{ matrix.major_version }}-current")
container_tags+=("${BRANCH}")
container_tags+=("${{ matrix.major_version }}")
BUILD_TAGS+=("${{ matrix.major_version }}-current")
BUILD_TAGS+=("${{ matrix.major_version }}")
fi

# Append matching timestamp tags to keep a version history
for TAG in "${container_tags[@]}"; do
container_tags+=("${TAG}-${TIMESTAMP}")
for TAG in "${BUILD_TAGS[@]}"; do
BUILD_TAGS+=("${TAG}-${TIMESTAMP}")
done

if [[ "${BRANCH}" == "stable" ]] && \
if [[ "${{ matrix.is_latest_version }}" == "true" ]] && \
[[ "${{ matrix.is_stable_version }}" == "true" ]] && \
[[ "${{ matrix.is_latest_driver }}" == "true" ]]; then
container_tags+=("${TIMESTAMP}")
container_tags+=("latest")
BUILD_TAGS+=("${TIMESTAMP}")
BUILD_TAGS+=("latest")
fi

echo "Generated the following tags: "
for TAG in "${container_tags[@]}"; do
echo "${TAG}"
done

if [[ "${{ github.event_name }}" == "pull_request" ]]; then
alias_tags=("pr-${{ github.event.number }}")
echo "Generated the following commit tags: "
for TAG in "${COMMIT_TAGS[@]}"; do
echo "${TAG}"
done

alias_tags=("${COMMIT_TAGS[@]}")
else
alias_tags=("${container_tags[@]}")
alias_tags=("${BUILD_TAGS[@]}")
fi

echo "Generated the following build tags: "
for TAG in "${BUILD_TAGS[@]}"; do
echo "${TAG}"
done

echo "alias_tags=${alias_tags[*]}" >> $GITHUB_OUTPUT

Expand Down Expand Up @@ -137,7 +144,6 @@ jobs:
image: ${{ format('{0}-nvidia', matrix.image_name) }}
tags: |
${{ steps.generate-tags.outputs.alias_tags }}
${{ steps.generate-tags.outputs.sha_short }}
build-args: |
IMAGE_NAME=${{ matrix.image_name }}
FEDORA_MAJOR_VERSION=${{ matrix.major_version }}
Expand Down