diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index e3d3e0d0..daad3d31 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -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 @@ -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 }}