Skip to content
Merged
Show file tree
Hide file tree
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
58 changes: 49 additions & 9 deletions .github/workflows/patch-release-step1.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@

on:
workflow_dispatch:
inputs:
target_minor:
description: 'Target minor version to patch, e.g. v1.8. Leave empty to default to the latest released minor.'
required: false
type: string
default: ''

jobs:
create_patch_release_pr:
Expand Down Expand Up @@ -44,17 +50,51 @@
git fetch --all
git fetch --tags

# Find all minor release branches matching pattern main-vX.Y
RELEASE_BRANCHES=$(git branch -r --format='%(refname:short)' | grep -E 'origin/main-v[0-9]+\.[0-9]+$' | sed 's|origin/||' | sort -V)

if [[ -z "$RELEASE_BRANCHES" ]]; then
echo "::error::No minor release branches found matching pattern 'main-vX.Y'"
exit 1
TARGET_MINOR="${{ inputs.target_minor }}"

Check failure on line 53 in .github/workflows/patch-release-step1.yml

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

inputs.target_minor is vulnerable to script injection: values of inputs are provided by whoever triggers the workflow. Change this workflow to not use user-controlled data directly in a run block, for example by assigning this expression to an environment variable.

See more on https://sonarcloud.io/project/issues?id=ObolNetwork_charon&issues=AZ26DE-O3CJrm6sXnUDA&open=AZ26DE-O3CJrm6sXnUDA&pullRequest=4492

if [[ -n "$TARGET_MINOR" ]]; then
# Opt-in: patch a specific (non-latest) minor.
if [[ ! "$TARGET_MINOR" =~ ^v[0-9]+\.[0-9]+$ ]]; then
echo "::error::Invalid target_minor format: '$TARGET_MINOR'. Expected 'vX.Y' (e.g. v1.8)"
exit 1
fi
RELEASE_BRANCH="main-${TARGET_MINOR}"
if ! git show-ref --verify --quiet "refs/remotes/origin/${RELEASE_BRANCH}"; then
echo "::error::Release branch ${RELEASE_BRANCH} does not exist on origin"
exit 1
fi
if ! git tag -l "${TARGET_MINOR}.0" | grep -q .; then
echo "::error::Minor ${TARGET_MINOR} has not been released (tag ${TARGET_MINOR}.0 does not exist)"
exit 1
fi
echo "::notice::Using explicitly targeted minor: ${RELEASE_BRANCH}"
else
# Default: latest minor with a released stable vX.Y.0 tag.
# Skips in-progress minors (RC-only, e.g. v1.10.0-rc3).
RELEASE_BRANCHES=$(git branch -r --format='%(refname:short)' | grep -E 'origin/main-v[0-9]+\.[0-9]+$' | sed 's|origin/||' | sort -V)

if [[ -z "$RELEASE_BRANCHES" ]]; then
Comment thread
KaloyanTanev marked this conversation as resolved.
echo "::error::No minor release branches found matching pattern 'main-vX.Y'"
exit 1
fi

RELEASE_BRANCH=""
while IFS= read -r candidate; do
if [[ "$candidate" =~ ^main-v([0-9]+)\.([0-9]+)$ ]]; then
CAND_MAJOR="${BASH_REMATCH[1]}"
CAND_MINOR="${BASH_REMATCH[2]}"
if git tag -l "v${CAND_MAJOR}.${CAND_MINOR}.0" | grep -q .; then
RELEASE_BRANCH="$candidate"
fi
fi
done <<< "$RELEASE_BRANCHES"

if [[ -z "$RELEASE_BRANCH" ]]; then
echo "::error::No minor release branches with a stable vX.Y.0 tag found"
exit 1
fi
fi

# Get the latest release branch (last in sorted list)
RELEASE_BRANCH=$(echo "$RELEASE_BRANCHES" | tail -n 1)

# Extract version from branch name (e.g., main-v1.8 -> 1.8)
if [[ ! "$RELEASE_BRANCH" =~ ^main-v([0-9]+)\.([0-9]+)$ ]]; then
echo "::error::Invalid branch name format. Expected 'main-vX.Y', got: $RELEASE_BRANCH"
Expand Down
63 changes: 52 additions & 11 deletions .github/workflows/patch-release-step2.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@

on:
workflow_dispatch:
inputs:
target_minor:
description: 'Target minor version to patch, e.g. v1.8. Leave empty to default to the latest released minor.'
required: false
type: string
default: ''

jobs:
tag_patch_release_candidate:
Expand Down Expand Up @@ -39,22 +45,57 @@
- name: 3. Find Latest Release Branch
id: find_branch
run: |
# Fetch all remote branches
# Fetch all remote branches and tags
git fetch --all
git fetch --tags

# Find all minor release branches matching pattern main-vX.Y
RELEASE_BRANCHES=$(git branch -r --format='%(refname:short)' | grep -E 'origin/main-v[0-9]+\.[0-9]+$' | sed 's|origin/||' | sort -V)

if [[ -z "$RELEASE_BRANCHES" ]]; then
echo "::error::No minor release branches found matching pattern 'main-vX.Y'"
exit 1
TARGET_MINOR="${{ inputs.target_minor }}"

Check failure on line 52 in .github/workflows/patch-release-step2.yml

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

inputs.target_minor is vulnerable to script injection: values of inputs are provided by whoever triggers the workflow. Change this workflow to not use user-controlled data directly in a run block, for example by assigning this expression to an environment variable.

See more on https://sonarcloud.io/project/issues?id=ObolNetwork_charon&issues=AZ26DE9-3CJrm6sXnUC_&open=AZ26DE9-3CJrm6sXnUC_&pullRequest=4492

if [[ -n "$TARGET_MINOR" ]]; then
# Opt-in: patch a specific (non-latest) minor.
if [[ ! "$TARGET_MINOR" =~ ^v[0-9]+\.[0-9]+$ ]]; then
echo "::error::Invalid target_minor format: '$TARGET_MINOR'. Expected 'vX.Y' (e.g. v1.8)"
exit 1
fi
RELEASE_BRANCH="main-${TARGET_MINOR}"
if ! git show-ref --verify --quiet "refs/remotes/origin/${RELEASE_BRANCH}"; then
echo "::error::Release branch ${RELEASE_BRANCH} does not exist on origin"
exit 1
fi
if ! git tag -l "${TARGET_MINOR}.0" | grep -q .; then
echo "::error::Minor ${TARGET_MINOR} has not been released (tag ${TARGET_MINOR}.0 does not exist)"
exit 1
fi
echo "::notice::Using explicitly targeted minor: ${RELEASE_BRANCH}"
else
# Default: latest minor with a released stable vX.Y.0 tag.
# Skips in-progress minors (RC-only, e.g. v1.10.0-rc3).
RELEASE_BRANCHES=$(git branch -r --format='%(refname:short)' | grep -E 'origin/main-v[0-9]+\.[0-9]+$' | sed 's|origin/||' | sort -V)

if [[ -z "$RELEASE_BRANCHES" ]]; then
echo "::error::No minor release branches found matching pattern 'main-vX.Y'"
exit 1
fi

RELEASE_BRANCH=""
while IFS= read -r candidate; do
if [[ "$candidate" =~ ^main-v([0-9]+)\.([0-9]+)$ ]]; then
CAND_MAJOR="${BASH_REMATCH[1]}"
CAND_MINOR="${BASH_REMATCH[2]}"
if git tag -l "v${CAND_MAJOR}.${CAND_MINOR}.0" | grep -q .; then
RELEASE_BRANCH="$candidate"
fi
fi
done <<< "$RELEASE_BRANCHES"

if [[ -z "$RELEASE_BRANCH" ]]; then
echo "::error::No minor release branches with a stable vX.Y.0 tag found"
exit 1
fi
fi

# Get the latest release branch (last in sorted list)
RELEASE_BRANCH=$(echo "$RELEASE_BRANCHES" | tail -n 1)

echo "RELEASE_BRANCH=${RELEASE_BRANCH}" >> $GITHUB_OUTPUT
echo "::notice::Found latest minor release branch: ${RELEASE_BRANCH}"
echo "::notice::Using minor release branch: ${RELEASE_BRANCH}"

# Checkout the release branch
git checkout "$RELEASE_BRANCH"
Expand Down
63 changes: 52 additions & 11 deletions .github/workflows/patch-release-step3.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@

on:
workflow_dispatch:
inputs:
target_minor:
description: 'Target minor version to patch, e.g. v1.8. Leave empty to default to the latest released minor.'
required: false
type: string
default: ''

jobs:
prepare_patch_full_release:
Expand Down Expand Up @@ -39,22 +45,57 @@
- name: 3. Find Latest Release Branch
id: find_branch
run: |
# Fetch all remote branches
# Fetch all remote branches and tags
git fetch --all
git fetch --tags

# Find all minor release branches matching pattern main-vX.Y
RELEASE_BRANCHES=$(git branch -r --format='%(refname:short)' | grep -E 'origin/main-v[0-9]+\.[0-9]+$' | sed 's|origin/||' | sort -V)

if [[ -z "$RELEASE_BRANCHES" ]]; then
echo "::error::No minor release branches found matching pattern 'main-vX.Y'"
exit 1
TARGET_MINOR="${{ inputs.target_minor }}"

Check failure on line 52 in .github/workflows/patch-release-step3.yml

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

inputs.target_minor is vulnerable to script injection: values of inputs are provided by whoever triggers the workflow. Change this workflow to not use user-controlled data directly in a run block, for example by assigning this expression to an environment variable.

See more on https://sonarcloud.io/project/issues?id=ObolNetwork_charon&issues=AZ26DE7Z3CJrm6sXnUC-&open=AZ26DE7Z3CJrm6sXnUC-&pullRequest=4492

if [[ -n "$TARGET_MINOR" ]]; then
# Opt-in: patch a specific (non-latest) minor.
if [[ ! "$TARGET_MINOR" =~ ^v[0-9]+\.[0-9]+$ ]]; then
echo "::error::Invalid target_minor format: '$TARGET_MINOR'. Expected 'vX.Y' (e.g. v1.8)"
exit 1
fi
RELEASE_BRANCH="main-${TARGET_MINOR}"
if ! git show-ref --verify --quiet "refs/remotes/origin/${RELEASE_BRANCH}"; then
echo "::error::Release branch ${RELEASE_BRANCH} does not exist on origin"
exit 1
fi
if ! git tag -l "${TARGET_MINOR}.0" | grep -q .; then
echo "::error::Minor ${TARGET_MINOR} has not been released (tag ${TARGET_MINOR}.0 does not exist)"
exit 1
fi
echo "::notice::Using explicitly targeted minor: ${RELEASE_BRANCH}"
else
# Default: latest minor with a released stable vX.Y.0 tag.
# Skips in-progress minors (RC-only, e.g. v1.10.0-rc3).
RELEASE_BRANCHES=$(git branch -r --format='%(refname:short)' | grep -E 'origin/main-v[0-9]+\.[0-9]+$' | sed 's|origin/||' | sort -V)

if [[ -z "$RELEASE_BRANCHES" ]]; then
echo "::error::No minor release branches found matching pattern 'main-vX.Y'"
exit 1
fi

RELEASE_BRANCH=""
while IFS= read -r candidate; do
if [[ "$candidate" =~ ^main-v([0-9]+)\.([0-9]+)$ ]]; then
CAND_MAJOR="${BASH_REMATCH[1]}"
CAND_MINOR="${BASH_REMATCH[2]}"
if git tag -l "v${CAND_MAJOR}.${CAND_MINOR}.0" | grep -q .; then
RELEASE_BRANCH="$candidate"
fi
fi
done <<< "$RELEASE_BRANCHES"

if [[ -z "$RELEASE_BRANCH" ]]; then
echo "::error::No minor release branches with a stable vX.Y.0 tag found"
exit 1
fi
fi

# Get the latest release branch (last in sorted list)
RELEASE_BRANCH=$(echo "$RELEASE_BRANCHES" | tail -n 1)

echo "RELEASE_BRANCH=${RELEASE_BRANCH}" >> $GITHUB_OUTPUT
echo "::notice::Found latest minor release branch: ${RELEASE_BRANCH}"
echo "::notice::Using minor release branch: ${RELEASE_BRANCH}"

- name: 3. Extract Version from Branch Name
id: version
Expand Down
63 changes: 52 additions & 11 deletions .github/workflows/patch-release-step4.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@

on:
workflow_dispatch:
inputs:
target_minor:
description: 'Target minor version to patch, e.g. v1.8. Leave empty to default to the latest released minor.'
required: false
type: string
default: ''

jobs:
tag_patch_full_release:
Expand Down Expand Up @@ -50,22 +56,57 @@
- name: 3. Find Latest Release Branch
id: find_branch
run: |
# Fetch all remote branches
# Fetch all remote branches and tags
git fetch --all
git fetch --tags

# Find all minor release branches matching pattern main-vX.Y
RELEASE_BRANCHES=$(git branch -r --format='%(refname:short)' | grep -E 'origin/main-v[0-9]+\.[0-9]+$' | sed 's|origin/||' | sort -V)

if [[ -z "$RELEASE_BRANCHES" ]]; then
echo "::error::No minor release branches found matching pattern 'main-vX.Y'"
exit 1
TARGET_MINOR="${{ inputs.target_minor }}"

Check failure on line 63 in .github/workflows/patch-release-step4.yml

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

inputs.target_minor is vulnerable to script injection: values of inputs are provided by whoever triggers the workflow. Change this workflow to not use user-controlled data directly in a run block, for example by assigning this expression to an environment variable.

See more on https://sonarcloud.io/project/issues?id=ObolNetwork_charon&issues=AZ26DE-e3CJrm6sXnUDB&open=AZ26DE-e3CJrm6sXnUDB&pullRequest=4492

if [[ -n "$TARGET_MINOR" ]]; then
# Opt-in: patch a specific (non-latest) minor.
if [[ ! "$TARGET_MINOR" =~ ^v[0-9]+\.[0-9]+$ ]]; then
echo "::error::Invalid target_minor format: '$TARGET_MINOR'. Expected 'vX.Y' (e.g. v1.8)"
exit 1
fi
RELEASE_BRANCH="main-${TARGET_MINOR}"
if ! git show-ref --verify --quiet "refs/remotes/origin/${RELEASE_BRANCH}"; then
echo "::error::Release branch ${RELEASE_BRANCH} does not exist on origin"
exit 1
fi
if ! git tag -l "${TARGET_MINOR}.0" | grep -q .; then
echo "::error::Minor ${TARGET_MINOR} has not been released (tag ${TARGET_MINOR}.0 does not exist)"
exit 1
fi
echo "::notice::Using explicitly targeted minor: ${RELEASE_BRANCH}"
else
# Default: latest minor with a released stable vX.Y.0 tag.
# Skips in-progress minors (RC-only, e.g. v1.10.0-rc3).
RELEASE_BRANCHES=$(git branch -r --format='%(refname:short)' | grep -E 'origin/main-v[0-9]+\.[0-9]+$' | sed 's|origin/||' | sort -V)

if [[ -z "$RELEASE_BRANCHES" ]]; then
echo "::error::No minor release branches found matching pattern 'main-vX.Y'"
exit 1
fi

RELEASE_BRANCH=""
while IFS= read -r candidate; do
if [[ "$candidate" =~ ^main-v([0-9]+)\.([0-9]+)$ ]]; then
CAND_MAJOR="${BASH_REMATCH[1]}"
CAND_MINOR="${BASH_REMATCH[2]}"
if git tag -l "v${CAND_MAJOR}.${CAND_MINOR}.0" | grep -q .; then
RELEASE_BRANCH="$candidate"
fi
fi
done <<< "$RELEASE_BRANCHES"

if [[ -z "$RELEASE_BRANCH" ]]; then
echo "::error::No minor release branches with a stable vX.Y.0 tag found"
exit 1
fi
fi

# Get the latest release branch (last in sorted list)
RELEASE_BRANCH=$(echo "$RELEASE_BRANCHES" | tail -n 1)

echo "RELEASE_BRANCH=${RELEASE_BRANCH}" >> $GITHUB_OUTPUT
echo "::notice::Found latest minor release branch: ${RELEASE_BRANCH}"
echo "::notice::Using minor release branch: ${RELEASE_BRANCH}"

- name: 3. Extract Version from Branch Name
id: version
Expand Down
Loading