Skip to content
Open
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
29 changes: 21 additions & 8 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,12 @@ jobs:
registry-type: public

- name: Validate and fixup Helm version
env:
# Pass inputs through the environment, never by interpolating
# expressions into the script, so input text cannot run as shell code.
INPUT_VERSION: ${{ inputs.version }}
FORCE_REPUBLISH: ${{ inputs.force_republish }}
run: |
INPUT_VERSION="${{ github.event.inputs.version }}"

# Strip v prefix if present for helm chart version
if [[ $INPUT_VERSION == v* ]]; then
VERSION="${INPUT_VERSION#v}"
Expand All @@ -85,7 +88,7 @@ jobs:
exit 1
fi

if [[ "${{ github.event.inputs.force_republish }}" != "true" ]]; then
if [[ "$FORCE_REPUBLISH" != "true" ]]; then
if [[ -n "$(git tag --list "$VERSION")" ]]; then
echo "❌ Error: Version $VERSION already exists"
echo "Please use a different version number"
Expand All @@ -104,21 +107,30 @@ jobs:
echo "CHART_VERSION=$VERSION" >> $GITHUB_ENV

- name: Validate and fixup services version
env:
INPUT_SERVICES_VERSION: ${{ inputs.services_version }}
run: |
if [ "${{ inputs.services_version }}" != "" ]; then
INPUT_SERVICES_VERSION="${{ inputs.services_version }}"
if [ "$INPUT_SERVICES_VERSION" != "" ]; then
if [[ $INPUT_SERVICES_VERSION == v* ]]; then
SERVICES_VERSION="$INPUT_SERVICES_VERSION"
else
SERVICES_VERSION="v$INPUT_SERVICES_VERSION"
echo "ℹ️ Added 'v' prefix to services version: ${{ inputs.services_version }} -> $SERVICES_VERSION"
echo "ℹ️ Added 'v' prefix to services version: $INPUT_SERVICES_VERSION -> $SERVICES_VERSION"
fi

# The value is written to GITHUB_ENV and passed to lock_versions,
# so reject anything that is not a v-prefixed semver tag.
if [[ ! $SERVICES_VERSION =~ ^v[0-9]+\.[0-9]+\.[0-9]+(-[0-9A-Za-z-]+(\.[0-9A-Za-z-]+)*)?(\+[0-9A-Za-z-]+(\.[0-9A-Za-z-]+)*)?$ ]]; then

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Preserve non-semver service image tags

When services_version is a commit SHA or custom image tag such as latest, this new regex exits before invoking lock_versions. Those inputs worked previously, and lock_versions --help explicitly documents latest, so this prevents releases from pinning supported non-semver builds; validate the value for safe transport without restricting it to semver.

AGENTS.md reference: AGENTS.md:L7-L11

Useful? React with 👍 / 👎.

echo "❌ Error: Services version '$INPUT_SERVICES_VERSION' is not a valid semver format"
echo "Expected format: [v]x.y.z[-prerelease][+build] (e.g., 1.2.3, v1.2.3)"
exit 1
fi
echo "SERVICES_VERSION=$SERVICES_VERSION" >> $GITHUB_ENV
fi

- name: Prepare release branch
run: |
if [[ "${{ github.event.inputs.force_republish }}" == "true" ]]; then
if [[ "$FORCE_REPUBLISH" == "true" ]]; then
# Capture the SHA from the existing (broken) tag before we delete anything
START_POINT=$(git rev-parse $CHART_VERSION)
echo "ℹ️ Republishing from existing tag $CHART_VERSION @ $START_POINT"
Expand Down Expand Up @@ -183,11 +195,12 @@ jobs:

# In normal mode, fast-forward main to include the version bumps.
# (Skipped for force_republish: the release branch diverges from main.)
if [[ "${{ github.event.inputs.force_republish }}" != "true" ]]; then
if [[ "$FORCE_REPUBLISH" != "true" ]]; then
git push origin release/$CHART_VERSION:main
fi
env:
GH_TOKEN: ${{ steps.bot-token.outputs.token }}
FORCE_REPUBLISH: ${{ inputs.force_republish }}

- name: Create GitHub Release
run: |
Expand Down
Loading