Compare commits

...

1 Commits

Author SHA1 Message Date
François Delbrayelle
343c66f125 build(release): only release changed plugins 2025-08-12 11:59:15 +02:00
3 changed files with 374 additions and 174 deletions

View File

@@ -1,20 +1,28 @@
name: 'Load Kestra Plugin List' name: 'Load Kestra Plugin List'
description: 'Composite action to load list of plugins' description: 'Composite action to load list of plugins (from .plugins) and output repositories and GA coordinates'
inputs: inputs:
plugin-version: plugin-version:
description: "Kestra version" description: "Kestra version placeholder to replace LATEST in GA coordinates"
default: 'LATEST' default: 'LATEST'
required: true required: true
plugin-file: plugin-file:
description: "File of the plugins" description: "Path to the .plugins file"
default: './.plugins' default: './.plugins'
required: true required: true
include:
description: "Regex include filter applied on repository names"
required: false
default: ''
exclude:
description: "Regex exclude filter applied on repository names"
required: false
default: ''
outputs: outputs:
plugins: plugins:
description: "List of all Kestra plugins" description: "Space-separated list of GA coordinates (group:artifact:version)"
value: ${{ steps.plugins.outputs.plugins }} value: ${{ steps.plugins.outputs.plugins }}
repositories: repositories:
description: "List of all Kestra repositories of plugins" description: "Space-separated list of repository names (e.g., plugin-ai plugin-airbyte)"
value: ${{ steps.plugins.outputs.repositories }} value: ${{ steps.plugins.outputs.repositories }}
runs: runs:
using: composite using: composite
@@ -23,7 +31,35 @@ runs:
id: plugins id: plugins
shell: bash shell: bash
run: | run: |
PLUGINS=$([ -f ${{ inputs.plugin-file }} ] && cat ${{ inputs.plugin-file }} | grep "io\\.kestra\\." | sed -e '/#/s/^.//' | sed -e "s/LATEST/${{ inputs.plugin-version }}/g" | cut -d':' -f2- | xargs || echo ''); set -euo pipefail
REPOSITORIES=$([ -f ${{ inputs.plugin-file }} ] && cat ${{ inputs.plugin-file }} | grep "io\\.kestra\\." | sed -e '/#/s/^.//' | cut -d':' -f1 | uniq | sort | xargs || echo '')
echo "plugins=$PLUGINS" >> $GITHUB_OUTPUT # Read only uncommented lines that contain io.kestra.* coordinates.
echo "repositories=$REPOSITORIES" >> $GITHUB_OUTPUT # This avoids the previous approach that 'uncommented' lines by stripping the first char after '#'.
if [[ -f "${{ inputs.plugin-file }}" ]]; then
ENABLED_LINES=$(grep -E '^\s*[^#]' "${{ inputs.plugin-file }}" | grep "io\.kestra\." || true)
else
ENABLED_LINES=""
fi
# Build GA coordinates by replacing LATEST with the provided plugin-version (if present)
PLUGINS=$(echo "$ENABLED_LINES" \
| sed -e "s/LATEST/${{ inputs.plugin-version }}/g" \
| cut -d':' -f2- \
| xargs || echo '')
# Extract repository names (first column), unique + sorted
REPOSITORIES=$(echo "$ENABLED_LINES" \
| cut -d':' -f1 \
| uniq | sort \
| xargs || echo '')
# Apply include/exclude filters if provided (POSIX ERE via grep -E)
if [ -n "${{ inputs.include }}" ] && [ -n "$REPOSITORIES" ]; then
REPOSITORIES=$(echo "$REPOSITORIES" | xargs -n1 | grep -E "${{ inputs.include }}" | xargs || true)
fi
if [ -n "${{ inputs.exclude }}" ] && [ -n "$REPOSITORIES" ]; then
REPOSITORIES=$(echo "$REPOSITORIES" | xargs -n1 | grep -Ev "${{ inputs.exclude }}" | xargs || true)
fi
echo "plugins=$PLUGINS" >> "$GITHUB_OUTPUT"
echo "repositories=$REPOSITORIES" >> "$GITHUB_OUTPUT"

View File

@@ -15,24 +15,111 @@ on:
description: 'Use DRY_RUN mode' description: 'Use DRY_RUN mode'
required: false required: false
default: 'false' default: 'false'
type: choice
options: ['false', 'true']
repositories:
description: 'Space-separated repo names to release (e.g. "plugin-ai plugin-airbyte"). If empty, uses .plugins.'
required: false
type: string
include:
description: 'Regex include filter on repo names (applied when using .plugins)'
required: false
type: string
exclude:
description: 'Regex exclude filter on repo names (applied when using .plugins)'
required: false
type: string
onlyChanged:
description: 'Release only repos changed since last tag (or sinceTag if provided)'
required: false
default: 'false'
type: choice
options: ['false', 'true']
sinceTag:
description: 'Optional tag used as base for change detection (e.g. v0.24.0)'
required: false
type: string
jobs: jobs:
release: prepare:
name: Release plugins name: Compute target repositories
runs-on: ubuntu-latest runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.compute.outputs.matrix }}
steps: steps:
# Checkout # Checkout the current repo (assumed to contain .plugins and the workflow)
- uses: actions/checkout@v4 - uses: actions/checkout@v4
with: with:
fetch-depth: 0 fetch-depth: 0
# Checkout GitHub Actions # Checkout the kestra-io/actions repo (for setup-build, etc.)
- uses: actions/checkout@v4 - uses: actions/checkout@v4
with: with:
repository: kestra-io/actions repository: kestra-io/actions
path: actions path: actions
ref: main ref: main
# Setup build - name: Install tools
run: sudo apt-get update && sudo apt-get install -y jq
# Load repositories from .plugins (only uncommented lines) with optional include/exclude filters
- name: Get Plugins List
id: plugins-list
uses: ./.github/actions/plugins-list
with:
plugin-version: 'LATEST'
plugin-file: './.plugins'
include: ${{ github.event.inputs.include }}
exclude: ${{ github.event.inputs.exclude }}
# Finalize repo list:
# - If "repositories" input is provided, it takes precedence.
# - Otherwise, use the filtered list from the composite action.
- name: Build repo list
id: build-list
shell: bash
env:
INP_REPOS: ${{ github.event.inputs.repositories }}
run: |
set -euo pipefail
if [ -n "${INP_REPOS:-}" ]; then
LIST="${INP_REPOS}"
else
LIST="${{ steps.plugins-list.outputs.repositories }}"
fi
# Convert to JSON array for matrix
arr_json=$(printf '%s\n' $LIST | jq -R . | jq -s .)
echo "list=$LIST" >> "$GITHUB_OUTPUT"
echo "arr_json=$arr_json" >> "$GITHUB_OUTPUT"
- name: Compute matrix
id: compute
shell: bash
run: |
set -euo pipefail
echo "matrix={\"repo\": ${{ steps.build-list.outputs.arr_json }}}" >> "$GITHUB_OUTPUT"
release:
name: Release ${{ matrix.repo }}
needs: [prepare]
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix: ${{ fromJson(needs.prepare.outputs.matrix) }}
steps:
# Checkout the current repo (for dev-tools/release-plugins.sh)
- uses: actions/checkout@v4
with:
fetch-depth: 0
# Checkout the kestra-io/actions repo (for setup-build, etc.)
- uses: actions/checkout@v4
with:
repository: kestra-io/actions
path: actions
ref: main
# Build toolchain used by plugin builds
- uses: ./actions/.github/actions/setup-build - uses: ./actions/.github/actions/setup-build
id: build id: build
with: with:
@@ -41,42 +128,45 @@ jobs:
python-enabled: true python-enabled: true
caches-enabled: true caches-enabled: true
# Get Plugins List - name: Configure Git
- name: Get Plugins List
uses: ./.github/actions/plugins-list
id: plugins-list
with:
plugin-version: 'LATEST'
- name: 'Configure Git'
run: | run: |
git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com" git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"
git config --global user.name "github-actions[bot]" git config --global user.name "github-actions[bot]"
# Execute
- name: Run Gradle Release - name: Run Gradle Release
if: ${{ github.event.inputs.dryRun == 'false' }} if: ${{ github.event.inputs.dryRun == 'false' }}
env: env:
GITHUB_PAT: ${{ secrets.GH_PERSONAL_TOKEN }} GITHUB_PAT: ${{ secrets.GH_PERSONAL_TOKEN }}
run: | run: |
chmod +x ./dev-tools/release-plugins.sh; chmod +x ./dev-tools/release-plugins.sh
ARGS=()
./dev-tools/release-plugins.sh \ ARGS+=(--release-version="${{ github.event.inputs.releaseVersion }}")
--release-version=${{github.event.inputs.releaseVersion}} \ ARGS+=(--next-version="${{ github.event.inputs.nextVersion }}")
--next-version=${{github.event.inputs.nextVersion}} \ ARGS+=(--yes)
--yes \ if [ "${{ github.event.inputs.onlyChanged }}" = "true" ]; then
${{ steps.plugins-list.outputs.repositories }} ARGS+=(--only-changed)
fi
if [ -n "${{ github.event.inputs.sinceTag }}" ]; then
ARGS+=(--since-tag="${{ github.event.inputs.sinceTag }}")
fi
./dev-tools/release-plugins.sh "${ARGS[@]}" "${{ matrix.repo }}"
# Dry-run release
- name: Run Gradle Release (DRY_RUN) - name: Run Gradle Release (DRY_RUN)
if: ${{ github.event.inputs.dryRun == 'true' }} if: ${{ github.event.inputs.dryRun == 'true' }}
env: env:
GITHUB_PAT: ${{ secrets.GH_PERSONAL_TOKEN }} GITHUB_PAT: ${{ secrets.GH_PERSONAL_TOKEN }}
run: | run: |
chmod +x ./dev-tools/release-plugins.sh; chmod +x ./dev-tools/release-plugins.sh
ARGS=()
./dev-tools/release-plugins.sh \ ARGS+=(--release-version="${{ github.event.inputs.releaseVersion }}")
--release-version=${{github.event.inputs.releaseVersion}} \ ARGS+=(--next-version="${{ github.event.inputs.nextVersion }}")
--next-version=${{github.event.inputs.nextVersion}} \ ARGS+=(--dry-run)
--dry-run \ ARGS+=(--yes)
--yes \ if [ "${{ github.event.inputs.onlyChanged }}" = "true" ]; then
${{ steps.plugins-list.outputs.repositories }} ARGS+=(--only-changed)
fi
if [ -n "${{ github.event.inputs.sinceTag }}" ]; then
ARGS+=(--since-tag="${{ github.event.inputs.sinceTag }}")
fi
./dev-tools/release-plugins.sh "${ARGS[@]}" "${{ matrix.repo }}"

View File

@@ -1,152 +1,199 @@
#!/bin/bash #!/usr/bin/env bash
#=============================================================================== #===============================================================================
# SCRIPT: release-plugins.sh # SCRIPT: release-plugins.sh
# #
# DESCRIPTION: # DESCRIPTION:
# This script can be used to run a ./gradlew release command on each kestra plugin repository. # Runs Gradle release for one or multiple Kestra plugin repositories.
# By default, if no `GITHUB_PAT` environment variable exist, the script will attempt to clone GitHub repositories using SSH_KEY. # - If $GITHUB_PAT is set, HTTPS cloning via PAT is used.
# - Otherwise, SSH cloning is used (requires SSH key configured on runner).
#
# USAGE:
# ./release-plugins.sh [options] [plugin-repositories...]
# #
# USAGE: ./release-plugins.sh [options]
# OPTIONS: # OPTIONS:
# --release-version <version> Specify the release version (required) # --release-version <version> Specify the release version (required).
# --next-version <version> Specify the next version (required) # --next-version <version> Specify the next (development) version (required).
# --dry-run Specify to run in DRY_RUN. # --plugin-file <path> File containing the plugin list (default: ../.plugins).
# -y, --yes Automatically confirm prompts (non-interactive). # --dry-run Run in DRY_RUN mode (no publish, no changes pushed).
# -h, --help Show the help message and exit # --only-changed Skip repositories with no commits since last tag (or --since-tag).
# --since-tag <tag> Use this tag as base for change detection (default: last tag).
# -y, --yes Automatically confirm prompts (non-interactive).
# -h, --help Show this help message and exit.
#
# EXAMPLES: # EXAMPLES:
# To release all plugins: # # Release all plugins from .plugins:
# ./release-plugins.sh --release-version=0.20.0 --next-version=0.21.0-SNAPSHOT # ./release-plugins.sh --release-version=1.0.0 --next-version=1.1.0-SNAPSHOT
# To release a specific plugin: #
# ./release-plugins.sh --release-version=0.20.0 --next-version=0.21.0-SNAPSHOT plugin-kubernetes # # Release a specific plugin:
# To release specific plugins from file: # ./release-plugins.sh --release-version=1.0.0 --next-version=1.1.0-SNAPSHOT plugin-kubernetes
# ./release-plugins.sh --release-version=0.20.0 --plugin-file .plugins #
# # Release specific plugins from file:
# ./release-plugins.sh --release-version=1.0.0 --next-version=1.1.0-SNAPSHOT --plugin-file .plugins
#
# # Release only plugins that have changed since the last tag:
# ./release-plugins.sh --release-version=1.0.0 --next-version=1.1.0-SNAPSHOT --only-changed --yes
#=============================================================================== #===============================================================================
set -e; set -euo pipefail
############################################################### ###############################################################
# Global vars # Globals
############################################################### ###############################################################
BASEDIR=$(dirname "$(readlink -f $0)") BASEDIR=$(dirname "$(readlink -f "$0")")
WORKING_DIR=/tmp/kestra-release-plugins-$(date +%s); WORKING_DIR="/tmp/kestra-release-plugins-$(date +%s)"
PLUGIN_FILE="$BASEDIR/../.plugins" PLUGIN_FILE="$BASEDIR/../.plugins"
GIT_BRANCH=master GIT_BRANCH="master" # Fallback if default branch cannot be detected
############################################################### ###############################################################
# Functions # Functions
############################################################### ###############################################################
# Function to display the help message
usage() { usage() {
echo "Usage: $0 --release-version <version> --next-version [plugin-repositories...]" echo "Usage: $0 --release-version <version> --next-version <version> [options] [plugin-repositories...]"
echo echo
echo "Options:" echo "Options:"
echo " --release-version <version> Specify the release version (required)." echo " --release-version <version> Specify the release version (required)."
echo " --next-version <version> Specify the next version (required)." echo " --next-version <version> Specify the next version (required)."
echo " --plugin-file File containing the plugin list (default: .plugins)" echo " --plugin-file <path> File containing the plugin list (default: ../.plugins)."
echo " --dry-run Specify to run in DRY_RUN." echo " --dry-run Run in DRY_RUN mode."
echo " -y, --yes Automatically confirm prompts (non-interactive)." echo " --only-changed Skip repositories with no commits since last tag (or --since-tag)."
echo " -h, --help Show this help message and exit." echo " --since-tag <tag> Use this tag as base for change detection (default: last tag)."
exit 1 echo " -y, --yes Automatically confirm prompts (non-interactive)."
echo " -h, --help Show this help message and exit."
exit 1
} }
# Function to ask to continue askToContinue() {
function askToContinue() { read -r -p "Are you sure you want to continue? [y/N] " confirm
read -p "Are you sure you want to continue? [y/N] " confirm
[[ "$confirm" =~ ^[Yy]$ ]] || { echo "Operation cancelled."; exit 1; } [[ "$confirm" =~ ^[Yy]$ ]] || { echo "Operation cancelled."; exit 1; }
} }
# Detect default branch from remote; fallback to $GIT_BRANCH if unknown
detect_default_branch() {
local default_branch
default_branch=$(git remote show origin | sed -n '/HEAD branch/s/.*: //p' || true)
if [[ -z "${default_branch:-}" ]]; then
default_branch="$GIT_BRANCH"
fi
echo "$default_branch"
}
# Return last tag that matches v* or any tag if v* not found; empty if none
last_tag_or_empty() {
local tag
tag=$(git tag --list 'v*' --sort=-v:refname | head -n1 || true)
if [[ -z "${tag:-}" ]]; then
tag=$(git tag --sort=-creatordate | head -n1 || true)
fi
echo "$tag"
}
# True (0) if there are commits since tag on branch, False (1) otherwise.
has_changes_since_tag() {
local tag="$1"
local branch="$2"
if [[ -z "$tag" ]]; then
# No tag => consider it as changed (first release)
return 0
fi
git fetch --tags --quiet
git fetch origin "$branch" --quiet
local count
count=$(git rev-list --count "${tag}..origin/${branch}" || echo "0")
[[ "${count}" -gt 0 ]]
}
############################################################### ###############################################################
# Options # Options parsing
############################################################### ###############################################################
PLUGINS_ARGS=() PLUGINS_ARGS=()
AUTO_YES=false AUTO_YES=false
DRY_RUN=false DRY_RUN=false
# Get the options ONLY_CHANGED=false
SINCE_TAG=""
RELEASE_VERSION=""
NEXT_VERSION=""
while [[ "$#" -gt 0 ]]; do while [[ "$#" -gt 0 ]]; do
case "$1" in case "$1" in
--release-version) --release-version)
RELEASE_VERSION="$2" RELEASE_VERSION="$2"; shift 2 ;;
shift 2 --release-version=*)
;; RELEASE_VERSION="${1#*=}"; shift ;;
--release-version=*) --next-version)
RELEASE_VERSION="${1#*=}" NEXT_VERSION="$2"; shift 2 ;;
shift --next-version=*)
;; NEXT_VERSION="${1#*=}"; shift ;;
--next-version) --plugin-file)
NEXT_VERSION="$2" PLUGIN_FILE="$2"; shift 2 ;;
shift 2 --plugin-file=*)
;; PLUGIN_FILE="${1#*=}"; shift ;;
--next-version=*) --dry-run)
NEXT_VERSION="${1#*=}" DRY_RUN=true; shift ;;
shift --only-changed)
;; ONLY_CHANGED=true; shift ;;
--plugin-file) --since-tag)
PLUGIN_FILE="$2" SINCE_TAG="$2"; shift 2 ;;
shift 2 --since-tag=*)
;; SINCE_TAG="${1#*=}"; shift ;;
--plugin-file=*) -y|--yes)
PLUGIN_FILE="${1#*=}" AUTO_YES=true; shift ;;
shift -h|--help)
;; usage ;;
--dry-run) *)
DRY_RUN=true PLUGINS_ARGS+=("$1"); shift ;;
shift esac
;;
-y|--yes)
AUTO_YES=true
shift
;;
-h|--help)
usage
;;
*)
PLUGINS_ARGS+=("$1")
shift
;;
esac
done done
## Check options # Required options
if [[ -z "$RELEASE_VERSION" ]]; then if [[ -z "$RELEASE_VERSION" ]]; then
echo -e "Missing required argument: --release-version\n"; echo -e "Missing required argument: --release-version\n"; usage
usage
fi fi
if [[ -z "$NEXT_VERSION" ]]; then if [[ -z "$NEXT_VERSION" ]]; then
echo -e "Missing required argument: --next-version\n"; echo -e "Missing required argument: --next-version\n"; usage
usage
fi fi
## Get plugin list ###############################################################
# Build plugin list (from args or from .plugins)
###############################################################
PLUGINS_ARRAY=()
PLUGINS_COUNT=0
if [[ "${#PLUGINS_ARGS[@]}" -eq 0 ]]; then if [[ "${#PLUGINS_ARGS[@]}" -eq 0 ]]; then
if [ -f "$PLUGIN_FILE" ]; then if [[ -f "$PLUGIN_FILE" ]]; then
PLUGINS=$(cat "$PLUGIN_FILE" | grep "io\\.kestra\\." | sed -e '/#/s/^.//' | cut -d':' -f1 | uniq | sort); # Keep only uncommented lines, then keep the first column (repo name)
PLUGINS_COUNT=$(echo "$PLUGINS" | wc -l); mapfile -t PLUGINS_ARRAY < <(
PLUGINS_ARRAY=$(echo "$PLUGINS" | xargs || echo ''); grep -E '^\s*[^#]' "$PLUGIN_FILE" 2>/dev/null \
PLUGINS_ARRAY=($PLUGINS_ARRAY); | grep "io\.kestra\." \
| cut -d':' -f1 \
| uniq | sort
)
PLUGINS_COUNT="${#PLUGINS_ARRAY[@]}"
else
echo "Plugin file not found: $PLUGIN_FILE"
exit 1
fi fi
else else
PLUGINS_ARRAY=("${PLUGINS_ARGS[@]}") PLUGINS_ARRAY=("${PLUGINS_ARGS[@]}")
PLUGINS_COUNT="${#PLUGINS_ARGS[@]}" PLUGINS_COUNT="${#PLUGINS_ARGS[@]}"
fi fi
# Extract the major and minor versions # Extract major.minor (e.g. 0.21) to build the release branch name
BASE_VERSION=$(echo "$RELEASE_VERSION" | sed -E 's/^([0-9]+\.[0-9]+)\..*/\1/') BASE_VERSION=$(echo "$RELEASE_VERSION" | sed -E 's/^([0-9]+\.[0-9]+)\..*/\1/')
PUSH_RELEASE_BRANCH="releases/v${BASE_VERSION}.x" PUSH_RELEASE_BRANCH="releases/v${BASE_VERSION}.x"
## Get plugin list
echo "RELEASE_VERSION=$RELEASE_VERSION" echo "RELEASE_VERSION=$RELEASE_VERSION"
echo "NEXT_VERSION=$NEXT_VERSION" echo "NEXT_VERSION=$NEXT_VERSION"
echo "PUSH_RELEASE_BRANCH=$PUSH_RELEASE_BRANCH" echo "PUSH_RELEASE_BRANCH=$PUSH_RELEASE_BRANCH"
echo "GIT_BRANCH=$GIT_BRANCH" echo "GIT_BRANCH=$GIT_BRANCH (fallback)"
echo "DRY_RUN=$DRY_RUN" echo "DRY_RUN=$DRY_RUN"
echo "Found ($PLUGINS_COUNT) plugin repositories:"; echo "ONLY_CHANGED=$ONLY_CHANGED"
echo "SINCE_TAG=${SINCE_TAG:-<auto>}"
echo "Found ($PLUGINS_COUNT) plugin repositories:"
for PLUGIN in "${PLUGINS_ARRAY[@]}"; do for PLUGIN in "${PLUGINS_ARRAY[@]}"; do
echo "$PLUGIN" echo " - $PLUGIN"
done done
if [[ "$AUTO_YES" == false ]]; then if [[ "$AUTO_YES" == false ]]; then
@@ -156,56 +203,77 @@ fi
############################################################### ###############################################################
# Main # Main
############################################################### ###############################################################
mkdir -p $WORKING_DIR mkdir -p "$WORKING_DIR"
COUNTER=1; COUNTER=1
for PLUGIN in "${PLUGINS_ARRAY[@]}" for PLUGIN in "${PLUGINS_ARRAY[@]}"; do
do cd "$WORKING_DIR"
cd $WORKING_DIR;
echo "---------------------------------------------------------------------------------------" echo "---------------------------------------------------------------------------------------"
echo "[$COUNTER/$PLUGINS_COUNT] Release Plugin: $PLUGIN" echo "[$COUNTER/$PLUGINS_COUNT] Release Plugin: $PLUGIN"
echo "---------------------------------------------------------------------------------------" echo "---------------------------------------------------------------------------------------"
if [[ -z "${GITHUB_PAT}" ]]; then
git clone git@github.com:kestra-io/$PLUGIN # Clone the repo using SSH, otherwise PAT if provided
if [[ -z "${GITHUB_PAT:-}" ]]; then
git clone "git@github.com:kestra-io/${PLUGIN}.git"
else else
echo "Clone git repository using GITHUB PAT" echo "Clone git repository using GITHUB PAT"
git clone https://${GITHUB_PAT}@github.com/kestra-io/$PLUGIN.git git clone "https://${GITHUB_PAT}@github.com/kestra-io/${PLUGIN}.git"
fi
cd "$PLUGIN";
if [[ "$PLUGIN" == "plugin-transform" ]] && [[ "$GIT_BRANCH" == "master" ]]; then # quickfix
git checkout main;
else
git checkout "$GIT_BRANCH";
fi fi
# Check if tag already exists on remote cd "$PLUGIN"
TAG_EXISTS=$(git ls-remote --tags origin "refs/tags/v${RELEASE_VERSION}" | wc -l)
# Determine the default branch dynamically to avoid hardcoding "master"/"main"
DEFAULT_BRANCH=$(detect_default_branch)
git checkout "$DEFAULT_BRANCH"
# Skip if the release tag already exists on remote (check both with and without 'v' prefix)
TAG_EXISTS=$(
{ git ls-remote --tags origin "refs/tags/v${RELEASE_VERSION}" \
&& git ls-remote --tags origin "refs/tags/${RELEASE_VERSION}"; } | wc -l
)
if [[ "$TAG_EXISTS" -ne 0 ]]; then if [[ "$TAG_EXISTS" -ne 0 ]]; then
echo "Tag ${RELEASE_VERSION} already exists for $PLUGIN. Skipping..." echo "Tag ${RELEASE_VERSION} already exists for $PLUGIN. Skipping..."
COUNTER=$(( COUNTER + 1 ))
continue continue
fi fi
if [[ "$DRY_RUN" == false ]]; then
CURRENT_BRANCH=$(git branch --show-current);
echo "Run gradle release for plugin: $PLUGIN"; # Change detection (if requested)
echo "Branch: $CURRENT_BRANCH"; if [[ "$ONLY_CHANGED" == true ]]; then
git fetch --tags --quiet
git fetch origin "$DEFAULT_BRANCH" --quiet
BASE_TAG="$SINCE_TAG"
if [[ -z "$BASE_TAG" ]]; then
BASE_TAG=$(last_tag_or_empty)
fi
if has_changes_since_tag "$BASE_TAG" "$DEFAULT_BRANCH"; then
echo "Changes detected since ${BASE_TAG:-<no-tag>} on ${DEFAULT_BRANCH}, proceeding."
else
echo "No changes since ${BASE_TAG:-<no-tag>} on ${DEFAULT_BRANCH} for $PLUGIN. Skipping..."
COUNTER=$(( COUNTER + 1 ))
continue
fi
fi
if [[ "$DRY_RUN" == false ]]; then
CURRENT_BRANCH=$(git branch --show-current)
echo "Run gradle release for plugin: $PLUGIN"
echo "Branch: $CURRENT_BRANCH"
if [[ "$AUTO_YES" == false ]]; then if [[ "$AUTO_YES" == false ]]; then
askToContinue askToContinue
fi fi
# Create and push release branch # Create and push the release branch (branch that will hold the release versions)
git checkout -b "$PUSH_RELEASE_BRANCH"; git checkout -b "$PUSH_RELEASE_BRANCH"
git push -u origin "$PUSH_RELEASE_BRANCH"; git push -u origin "$PUSH_RELEASE_BRANCH"
# Run gradle release # Switch back to the working branch to run the gradle release
git checkout "$CURRENT_BRANCH"; git checkout "$CURRENT_BRANCH"
# Run Gradle release with snapshot tolerance if releaseVersion contains -SNAPSHOT
if [[ "$RELEASE_VERSION" == *"-SNAPSHOT" ]]; then if [[ "$RELEASE_VERSION" == *"-SNAPSHOT" ]]; then
# -SNAPSHOT qualifier maybe used to test release-candidates
./gradlew release -Prelease.useAutomaticVersion=true \ ./gradlew release -Prelease.useAutomaticVersion=true \
-Prelease.releaseVersion="${RELEASE_VERSION}" \ -Prelease.releaseVersion="${RELEASE_VERSION}" \
-Prelease.newVersion="${NEXT_VERSION}" \ -Prelease.newVersion="${NEXT_VERSION}" \
@@ -218,22 +286,28 @@ do
-Prelease.pushReleaseVersionBranch="${PUSH_RELEASE_BRANCH}" -Prelease.pushReleaseVersionBranch="${PUSH_RELEASE_BRANCH}"
fi fi
git push; # Push new commits/tags created by the release plugin
# Update the upper bound version of kestra git push --follow-tags
# Update the upper bound version of Kestra on the release branch (e.g., [0.21,))
PLUGIN_KESTRA_VERSION="[${BASE_VERSION},)" PLUGIN_KESTRA_VERSION="[${BASE_VERSION},)"
git checkout "$PUSH_RELEASE_BRANCH" && git pull; git checkout "$PUSH_RELEASE_BRANCH" && git pull --ff-only
sed -i "s/^kestraVersion=.*/kestraVersion=${PLUGIN_KESTRA_VERSION}/" ./gradle.properties sed -i "s/^kestraVersion=.*/kestraVersion=${PLUGIN_KESTRA_VERSION}/" ./gradle.properties
git add ./gradle.properties git add ./gradle.properties
# Check if there are staged changes
# Commit only if there are actual changes staged
if ! git diff --cached --quiet; then if ! git diff --cached --quiet; then
git commit -m"chore(deps): update kestraVersion to ${PLUGIN_KESTRA_VERSION}." git commit -m "chore(deps): update kestraVersion to ${PLUGIN_KESTRA_VERSION}."
git push git push
fi fi
sleep 5; # add a short delay to not spam Maven Central
else
echo "Skip gradle release [DRY_RUN=true]";
fi
COUNTER=$(( COUNTER + 1 ));
done;
exit 0; # Small delay to avoid hammering Maven Central
sleep 5
else
echo "Skip gradle release [DRY_RUN=true]"
fi
COUNTER=$(( COUNTER + 1 ))
done
exit 0