mirror of
https://github.com/kestra-io/kestra.git
synced 2025-12-25 11:12:12 -05:00
Compare commits
1 Commits
plugin/tem
...
issue/4659
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
343c66f125 |
54
.github/actions/plugins-list/action.yml
vendored
54
.github/actions/plugins-list/action.yml
vendored
@@ -1,20 +1,28 @@
|
||||
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:
|
||||
plugin-version:
|
||||
description: "Kestra version"
|
||||
description: "Kestra version placeholder to replace LATEST in GA coordinates"
|
||||
default: 'LATEST'
|
||||
required: true
|
||||
plugin-file:
|
||||
description: "File of the plugins"
|
||||
description: "Path to the .plugins file"
|
||||
default: './.plugins'
|
||||
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:
|
||||
plugins:
|
||||
description: "List of all Kestra plugins"
|
||||
description: "Space-separated list of GA coordinates (group:artifact:version)"
|
||||
value: ${{ steps.plugins.outputs.plugins }}
|
||||
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 }}
|
||||
runs:
|
||||
using: composite
|
||||
@@ -23,7 +31,35 @@ runs:
|
||||
id: plugins
|
||||
shell: bash
|
||||
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 '');
|
||||
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
|
||||
echo "repositories=$REPOSITORIES" >> $GITHUB_OUTPUT
|
||||
set -euo pipefail
|
||||
|
||||
# Read only uncommented lines that contain io.kestra.* coordinates.
|
||||
# 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"
|
||||
|
||||
148
.github/workflows/gradle-release-plugins.yml
vendored
148
.github/workflows/gradle-release-plugins.yml
vendored
@@ -15,24 +15,111 @@ on:
|
||||
description: 'Use DRY_RUN mode'
|
||||
required: 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:
|
||||
release:
|
||||
name: Release plugins
|
||||
prepare:
|
||||
name: Compute target repositories
|
||||
runs-on: ubuntu-latest
|
||||
outputs:
|
||||
matrix: ${{ steps.compute.outputs.matrix }}
|
||||
steps:
|
||||
# Checkout
|
||||
# Checkout the current repo (assumed to contain .plugins and the workflow)
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
# Checkout GitHub Actions
|
||||
# Checkout the kestra-io/actions repo (for setup-build, etc.)
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
repository: kestra-io/actions
|
||||
path: actions
|
||||
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
|
||||
id: build
|
||||
with:
|
||||
@@ -41,42 +128,45 @@ jobs:
|
||||
python-enabled: true
|
||||
caches-enabled: true
|
||||
|
||||
# Get Plugins List
|
||||
- name: Get Plugins List
|
||||
uses: ./.github/actions/plugins-list
|
||||
id: plugins-list
|
||||
with:
|
||||
plugin-version: 'LATEST'
|
||||
|
||||
- name: 'Configure Git'
|
||||
- name: Configure Git
|
||||
run: |
|
||||
git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"
|
||||
git config --global user.name "github-actions[bot]"
|
||||
|
||||
# Execute
|
||||
- name: Run Gradle Release
|
||||
if: ${{ github.event.inputs.dryRun == 'false' }}
|
||||
env:
|
||||
GITHUB_PAT: ${{ secrets.GH_PERSONAL_TOKEN }}
|
||||
run: |
|
||||
chmod +x ./dev-tools/release-plugins.sh;
|
||||
|
||||
./dev-tools/release-plugins.sh \
|
||||
--release-version=${{github.event.inputs.releaseVersion}} \
|
||||
--next-version=${{github.event.inputs.nextVersion}} \
|
||||
--yes \
|
||||
${{ steps.plugins-list.outputs.repositories }}
|
||||
chmod +x ./dev-tools/release-plugins.sh
|
||||
ARGS=()
|
||||
ARGS+=(--release-version="${{ github.event.inputs.releaseVersion }}")
|
||||
ARGS+=(--next-version="${{ github.event.inputs.nextVersion }}")
|
||||
ARGS+=(--yes)
|
||||
if [ "${{ github.event.inputs.onlyChanged }}" = "true" ]; then
|
||||
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)
|
||||
if: ${{ github.event.inputs.dryRun == 'true' }}
|
||||
env:
|
||||
GITHUB_PAT: ${{ secrets.GH_PERSONAL_TOKEN }}
|
||||
run: |
|
||||
chmod +x ./dev-tools/release-plugins.sh;
|
||||
|
||||
./dev-tools/release-plugins.sh \
|
||||
--release-version=${{github.event.inputs.releaseVersion}} \
|
||||
--next-version=${{github.event.inputs.nextVersion}} \
|
||||
--dry-run \
|
||||
--yes \
|
||||
${{ steps.plugins-list.outputs.repositories }}
|
||||
chmod +x ./dev-tools/release-plugins.sh
|
||||
ARGS=()
|
||||
ARGS+=(--release-version="${{ github.event.inputs.releaseVersion }}")
|
||||
ARGS+=(--next-version="${{ github.event.inputs.nextVersion }}")
|
||||
ARGS+=(--dry-run)
|
||||
ARGS+=(--yes)
|
||||
if [ "${{ github.event.inputs.onlyChanged }}" = "true" ]; then
|
||||
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 }}"
|
||||
|
||||
@@ -1,152 +1,199 @@
|
||||
#!/bin/bash
|
||||
#!/usr/bin/env bash
|
||||
#===============================================================================
|
||||
# SCRIPT: release-plugins.sh
|
||||
#
|
||||
# DESCRIPTION:
|
||||
# This script can be used to run a ./gradlew release command on each kestra plugin repository.
|
||||
# By default, if no `GITHUB_PAT` environment variable exist, the script will attempt to clone GitHub repositories using SSH_KEY.
|
||||
# Runs Gradle release for one or multiple Kestra plugin repositories.
|
||||
# - 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:
|
||||
# --release-version <version> Specify the release version (required)
|
||||
# --next-version <version> Specify the next version (required)
|
||||
# --dry-run Specify to run in DRY_RUN.
|
||||
# -y, --yes Automatically confirm prompts (non-interactive).
|
||||
# -h, --help Show the help message and exit
|
||||
|
||||
# --release-version <version> Specify the release version (required).
|
||||
# --next-version <version> Specify the next (development) version (required).
|
||||
# --plugin-file <path> File containing the plugin list (default: ../.plugins).
|
||||
# --dry-run Run in DRY_RUN mode (no publish, no changes pushed).
|
||||
# --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:
|
||||
# To release all plugins:
|
||||
# ./release-plugins.sh --release-version=0.20.0 --next-version=0.21.0-SNAPSHOT
|
||||
# To release a specific plugin:
|
||||
# ./release-plugins.sh --release-version=0.20.0 --next-version=0.21.0-SNAPSHOT plugin-kubernetes
|
||||
# To release specific plugins from file:
|
||||
# ./release-plugins.sh --release-version=0.20.0 --plugin-file .plugins
|
||||
# # Release all plugins from .plugins:
|
||||
# ./release-plugins.sh --release-version=1.0.0 --next-version=1.1.0-SNAPSHOT
|
||||
#
|
||||
# # Release a specific plugin:
|
||||
# ./release-plugins.sh --release-version=1.0.0 --next-version=1.1.0-SNAPSHOT plugin-kubernetes
|
||||
#
|
||||
# # 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)")
|
||||
WORKING_DIR=/tmp/kestra-release-plugins-$(date +%s);
|
||||
BASEDIR=$(dirname "$(readlink -f "$0")")
|
||||
WORKING_DIR="/tmp/kestra-release-plugins-$(date +%s)"
|
||||
PLUGIN_FILE="$BASEDIR/../.plugins"
|
||||
GIT_BRANCH=master
|
||||
GIT_BRANCH="master" # Fallback if default branch cannot be detected
|
||||
|
||||
###############################################################
|
||||
# Functions
|
||||
###############################################################
|
||||
|
||||
# Function to display the help message
|
||||
usage() {
|
||||
echo "Usage: $0 --release-version <version> --next-version [plugin-repositories...]"
|
||||
echo
|
||||
echo "Options:"
|
||||
echo " --release-version <version> Specify the release version (required)."
|
||||
echo " --next-version <version> Specify the next version (required)."
|
||||
echo " --plugin-file File containing the plugin list (default: .plugins)"
|
||||
echo " --dry-run Specify to run in DRY_RUN."
|
||||
echo " -y, --yes Automatically confirm prompts (non-interactive)."
|
||||
echo " -h, --help Show this help message and exit."
|
||||
exit 1
|
||||
echo "Usage: $0 --release-version <version> --next-version <version> [options] [plugin-repositories...]"
|
||||
echo
|
||||
echo "Options:"
|
||||
echo " --release-version <version> Specify the release version (required)."
|
||||
echo " --next-version <version> Specify the next version (required)."
|
||||
echo " --plugin-file <path> File containing the plugin list (default: ../.plugins)."
|
||||
echo " --dry-run Run in DRY_RUN mode."
|
||||
echo " --only-changed Skip repositories with no commits since last tag (or --since-tag)."
|
||||
echo " --since-tag <tag> Use this tag as base for change detection (default: last tag)."
|
||||
echo " -y, --yes Automatically confirm prompts (non-interactive)."
|
||||
echo " -h, --help Show this help message and exit."
|
||||
exit 1
|
||||
}
|
||||
|
||||
# Function to ask to continue
|
||||
function askToContinue() {
|
||||
read -p "Are you sure you want to continue? [y/N] " confirm
|
||||
askToContinue() {
|
||||
read -r -p "Are you sure you want to continue? [y/N] " confirm
|
||||
[[ "$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=()
|
||||
AUTO_YES=false
|
||||
DRY_RUN=false
|
||||
# Get the options
|
||||
ONLY_CHANGED=false
|
||||
SINCE_TAG=""
|
||||
|
||||
RELEASE_VERSION=""
|
||||
NEXT_VERSION=""
|
||||
|
||||
while [[ "$#" -gt 0 ]]; do
|
||||
case "$1" in
|
||||
--release-version)
|
||||
RELEASE_VERSION="$2"
|
||||
shift 2
|
||||
;;
|
||||
--release-version=*)
|
||||
RELEASE_VERSION="${1#*=}"
|
||||
shift
|
||||
;;
|
||||
--next-version)
|
||||
NEXT_VERSION="$2"
|
||||
shift 2
|
||||
;;
|
||||
--next-version=*)
|
||||
NEXT_VERSION="${1#*=}"
|
||||
shift
|
||||
;;
|
||||
--plugin-file)
|
||||
PLUGIN_FILE="$2"
|
||||
shift 2
|
||||
;;
|
||||
--plugin-file=*)
|
||||
PLUGIN_FILE="${1#*=}"
|
||||
shift
|
||||
;;
|
||||
--dry-run)
|
||||
DRY_RUN=true
|
||||
shift
|
||||
;;
|
||||
-y|--yes)
|
||||
AUTO_YES=true
|
||||
shift
|
||||
;;
|
||||
-h|--help)
|
||||
usage
|
||||
;;
|
||||
*)
|
||||
PLUGINS_ARGS+=("$1")
|
||||
shift
|
||||
;;
|
||||
esac
|
||||
case "$1" in
|
||||
--release-version)
|
||||
RELEASE_VERSION="$2"; shift 2 ;;
|
||||
--release-version=*)
|
||||
RELEASE_VERSION="${1#*=}"; shift ;;
|
||||
--next-version)
|
||||
NEXT_VERSION="$2"; shift 2 ;;
|
||||
--next-version=*)
|
||||
NEXT_VERSION="${1#*=}"; shift ;;
|
||||
--plugin-file)
|
||||
PLUGIN_FILE="$2"; shift 2 ;;
|
||||
--plugin-file=*)
|
||||
PLUGIN_FILE="${1#*=}"; shift ;;
|
||||
--dry-run)
|
||||
DRY_RUN=true; shift ;;
|
||||
--only-changed)
|
||||
ONLY_CHANGED=true; shift ;;
|
||||
--since-tag)
|
||||
SINCE_TAG="$2"; shift 2 ;;
|
||||
--since-tag=*)
|
||||
SINCE_TAG="${1#*=}"; shift ;;
|
||||
-y|--yes)
|
||||
AUTO_YES=true; shift ;;
|
||||
-h|--help)
|
||||
usage ;;
|
||||
*)
|
||||
PLUGINS_ARGS+=("$1"); shift ;;
|
||||
esac
|
||||
done
|
||||
|
||||
## Check options
|
||||
# Required options
|
||||
if [[ -z "$RELEASE_VERSION" ]]; then
|
||||
echo -e "Missing required argument: --release-version\n";
|
||||
usage
|
||||
echo -e "Missing required argument: --release-version\n"; usage
|
||||
fi
|
||||
|
||||
if [[ -z "$NEXT_VERSION" ]]; then
|
||||
echo -e "Missing required argument: --next-version\n";
|
||||
usage
|
||||
echo -e "Missing required argument: --next-version\n"; usage
|
||||
fi
|
||||
|
||||
## Get plugin list
|
||||
###############################################################
|
||||
# Build plugin list (from args or from .plugins)
|
||||
###############################################################
|
||||
PLUGINS_ARRAY=()
|
||||
PLUGINS_COUNT=0
|
||||
|
||||
if [[ "${#PLUGINS_ARGS[@]}" -eq 0 ]]; then
|
||||
if [ -f "$PLUGIN_FILE" ]; then
|
||||
PLUGINS=$(cat "$PLUGIN_FILE" | grep "io\\.kestra\\." | sed -e '/#/s/^.//' | cut -d':' -f1 | uniq | sort);
|
||||
PLUGINS_COUNT=$(echo "$PLUGINS" | wc -l);
|
||||
PLUGINS_ARRAY=$(echo "$PLUGINS" | xargs || echo '');
|
||||
PLUGINS_ARRAY=($PLUGINS_ARRAY);
|
||||
if [[ -f "$PLUGIN_FILE" ]]; then
|
||||
# Keep only uncommented lines, then keep the first column (repo name)
|
||||
mapfile -t PLUGINS_ARRAY < <(
|
||||
grep -E '^\s*[^#]' "$PLUGIN_FILE" 2>/dev/null \
|
||||
| grep "io\.kestra\." \
|
||||
| cut -d':' -f1 \
|
||||
| uniq | sort
|
||||
)
|
||||
PLUGINS_COUNT="${#PLUGINS_ARRAY[@]}"
|
||||
else
|
||||
echo "Plugin file not found: $PLUGIN_FILE"
|
||||
exit 1
|
||||
fi
|
||||
else
|
||||
PLUGINS_ARRAY=("${PLUGINS_ARGS[@]}")
|
||||
PLUGINS_COUNT="${#PLUGINS_ARGS[@]}"
|
||||
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/')
|
||||
PUSH_RELEASE_BRANCH="releases/v${BASE_VERSION}.x"
|
||||
|
||||
## Get plugin list
|
||||
echo "RELEASE_VERSION=$RELEASE_VERSION"
|
||||
echo "NEXT_VERSION=$NEXT_VERSION"
|
||||
echo "PUSH_RELEASE_BRANCH=$PUSH_RELEASE_BRANCH"
|
||||
echo "GIT_BRANCH=$GIT_BRANCH"
|
||||
echo "GIT_BRANCH=$GIT_BRANCH (fallback)"
|
||||
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
|
||||
echo "$PLUGIN"
|
||||
echo " - $PLUGIN"
|
||||
done
|
||||
|
||||
if [[ "$AUTO_YES" == false ]]; then
|
||||
@@ -156,56 +203,77 @@ fi
|
||||
###############################################################
|
||||
# Main
|
||||
###############################################################
|
||||
mkdir -p $WORKING_DIR
|
||||
mkdir -p "$WORKING_DIR"
|
||||
|
||||
COUNTER=1;
|
||||
for PLUGIN in "${PLUGINS_ARRAY[@]}"
|
||||
do
|
||||
cd $WORKING_DIR;
|
||||
COUNTER=1
|
||||
for PLUGIN in "${PLUGINS_ARRAY[@]}"; do
|
||||
cd "$WORKING_DIR"
|
||||
|
||||
echo "---------------------------------------------------------------------------------------"
|
||||
echo "[$COUNTER/$PLUGINS_COUNT] Release Plugin: $PLUGIN"
|
||||
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
|
||||
echo "Clone git repository using GITHUB PAT"
|
||||
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";
|
||||
git clone "https://${GITHUB_PAT}@github.com/kestra-io/${PLUGIN}.git"
|
||||
fi
|
||||
|
||||
# Check if tag already exists on remote
|
||||
TAG_EXISTS=$(git ls-remote --tags origin "refs/tags/v${RELEASE_VERSION}" | wc -l)
|
||||
cd "$PLUGIN"
|
||||
|
||||
# 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
|
||||
echo "Tag ${RELEASE_VERSION} already exists for $PLUGIN. Skipping..."
|
||||
COUNTER=$(( COUNTER + 1 ))
|
||||
continue
|
||||
fi
|
||||
|
||||
if [[ "$DRY_RUN" == false ]]; then
|
||||
CURRENT_BRANCH=$(git branch --show-current);
|
||||
|
||||
echo "Run gradle release for plugin: $PLUGIN";
|
||||
echo "Branch: $CURRENT_BRANCH";
|
||||
# Change detection (if requested)
|
||||
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
|
||||
askToContinue
|
||||
fi
|
||||
|
||||
# Create and push release branch
|
||||
git checkout -b "$PUSH_RELEASE_BRANCH";
|
||||
git push -u origin "$PUSH_RELEASE_BRANCH";
|
||||
# Create and push the release branch (branch that will hold the release versions)
|
||||
git checkout -b "$PUSH_RELEASE_BRANCH"
|
||||
git push -u origin "$PUSH_RELEASE_BRANCH"
|
||||
|
||||
# Run gradle release
|
||||
git checkout "$CURRENT_BRANCH";
|
||||
# Switch back to the working branch to run the gradle release
|
||||
git checkout "$CURRENT_BRANCH"
|
||||
|
||||
# Run Gradle release with snapshot tolerance if releaseVersion contains -SNAPSHOT
|
||||
if [[ "$RELEASE_VERSION" == *"-SNAPSHOT" ]]; then
|
||||
# -SNAPSHOT qualifier maybe used to test release-candidates
|
||||
./gradlew release -Prelease.useAutomaticVersion=true \
|
||||
-Prelease.releaseVersion="${RELEASE_VERSION}" \
|
||||
-Prelease.newVersion="${NEXT_VERSION}" \
|
||||
@@ -218,22 +286,28 @@ do
|
||||
-Prelease.pushReleaseVersionBranch="${PUSH_RELEASE_BRANCH}"
|
||||
fi
|
||||
|
||||
git push;
|
||||
# Update the upper bound version of kestra
|
||||
# Push new commits/tags created by the release plugin
|
||||
git push --follow-tags
|
||||
|
||||
# Update the upper bound version of Kestra on the release branch (e.g., [0.21,))
|
||||
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
|
||||
git add ./gradle.properties
|
||||
# Check if there are staged changes
|
||||
|
||||
# Commit only if there are actual changes staged
|
||||
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
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user