Skip to content

Restrict SNAPSHOT tag publication to builds from main - #37

Merged
kthoms merged 3 commits into
mainfrom
copilot/fix-snapshot-tagging-issue
May 21, 2026
Merged

kthoms merged 3 commits into
mainfrom
copilot/fix-snapshot-tagging-issue

Conversation

Copilot AI commented May 21, 2026 •

Copy link
Copy Markdown
Contributor

Snapshot builds currently publish a global SNAPSHOT tag regardless of source branch, which allows release-branch builds to overwrite the canonical development snapshot. This change scopes global SNAPSHOT publication to main while preserving versioned snapshot tags for all snapshot builds.

  • Tagging logic in release publishing

    • Updated release.sh to always publish ${VERSION}-SNAPSHOT for snapshot builds.
    • Added branch-aware gating so plain SNAPSHOT is only appended when the effective branch is main.
  • Workflow branch source propagation

    • Updated publish job env in build-test-and-publish.yml to pass SNAPSHOT_TAG_BRANCH from:
      • github.event.release.target_commitish (release-triggered workflows), or
      • github.ref_name (fallback for other triggers).
  • Focused regression coverage

    • Added test/test-release-tags.sh to assert:
      • main snapshot builds include both ${VERSION}-SNAPSHOT and SNAPSHOT
      • release-branch snapshot builds include ${VERSION}-SNAPSHOT but not SNAPSHOT
if [ "${SNAPSHOT}" = "true" ]; then
  tags+=("${VERSION}-SNAPSHOT")
  SNAPSHOT_TAG_BRANCH="${SNAPSHOT_TAG_BRANCH:-${GITHUB_REF_NAME:-}}"
  if [ "${SNAPSHOT_TAG_BRANCH}" = "main" ]; then
    tags+=("SNAPSHOT")
  fi
fi

Copilot AI changed the title [WIP] Fix image tagging issue for non-main branches Restrict SNAPSHOT tag publication to builds from main May 21, 2026
Copilot AI requested a review from kthoms May 21, 2026 21:32
Copilot finished work on behalf of kthoms May 21, 2026 21:32
@kthoms
kthoms marked this pull request as ready for review May 21, 2026 21:45
Copilot AI review requested due to automatic review settings May 21, 2026 21:45
@kthoms
kthoms merged commit 8beb30b into main May 21, 2026
5 checks passed
@kthoms
kthoms deleted the copilot/fix-snapshot-tagging-issue branch May 21, 2026 21:46

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR prevents non-main snapshot builds from overwriting the canonical global SNAPSHOT Docker tag by only publishing SNAPSHOT when the effective source branch is main, while still publishing ${VERSION}-SNAPSHOT for all snapshot builds.

Changes:

  • Update release.sh snapshot tagging to always emit ${VERSION}-SNAPSHOT, and only add the plain SNAPSHOT tag when SNAPSHOT_TAG_BRANCH resolves to main.
  • Propagate SNAPSHOT_TAG_BRANCH into the publish job from github.event.release.target_commitish (release event) or github.ref_name (fallback).
  • Add a regression test script intended to validate tag behavior for main vs. release branches.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
test/test-release-tags.sh Adds a mock-docker regression test for snapshot tag selection by branch.
release.sh Gates publication of the global SNAPSHOT tag to main while keeping versioned snapshot tags.
.github/workflows/build-test-and-publish.yml Passes SNAPSHOT_TAG_BRANCH to the publish step based on trigger context.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread test/test-release-tags.sh
Comment on lines +23 to +33
PATH="${MOCK_DIR}:${PATH}" \
MOCK_DOCKER_CALLS="${MOCK_DOCKER_CALLS}" \
DISTRO="run" \
VERSION="1.2.3" \
SNAPSHOT="true" \
SNAPSHOT_TAG_BRANCH="${snapshot_tag_branch}" \
DOCKERHUB_USERNAME="user" \
DOCKERHUB_PASSWORD="pass" \
IMAGE_REPO_OPERATON="operaton/operaton" \
GITHUB_STEP_SUMMARY="${MOCK_DIR}/summary.log" \
bash "${ROOT_DIR}/release.sh" > /dev/null 2>&1
Comment thread test/test-release-tags.sh
Comment on lines +1 to +5
#!/usr/bin/env bash
set -euo pipefail

ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
MOCK_DIR="$(mktemp -d)"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Image must not be tagged as SNAPSHOT when it was not build from main

3 participants