-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
build: add script and github workflow to tag all plugins
- Loading branch information
1 parent
1c08176
commit 64dcc96
Showing
3 changed files
with
238 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
name: Update and Tag Kestra Plugins | ||
|
||
on: | ||
workflow_dispatch: | ||
inputs: | ||
releaseVersion: | ||
description: 'The release version (e.g., 0.21.0)' | ||
required: true | ||
type: string | ||
dryRun: | ||
description: 'Use DRY_RUN mode' | ||
required: false | ||
default: 'false' | ||
jobs: | ||
tag: | ||
name: Release plugins | ||
runs-on: kestra-private-standard | ||
steps: | ||
# Checkout | ||
- uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
|
||
# Get Plugins List | ||
- name: Get Plugins List | ||
uses: ./.github/actions/plugins-list | ||
if: "!startsWith(github.ref, 'refs/tags/v')" | ||
id: plugins-list | ||
with: | ||
plugin-version: 'LATEST' | ||
|
||
# Execute | ||
- name: Tag Plugins | ||
if: ${{ github.event.inputs.dryRun == 'false' }} | ||
env: | ||
GITHUB_PAT: ${{ secrets.GH_PERSONAL_TOKEN }} | ||
run: | | ||
chmod +x ./tag-release-plugins.sh; | ||
./tag-release-plugins.sh \ | ||
--release-version=${{github.event.inputs.releaseVersion}} \ | ||
--yes \ | ||
${{ steps.plugins-list.outputs.repositories }} | ||
- name: Run Gradle Release (DRY_RUN) | ||
if: ${{ github.event.inputs.dryRun == 'true' }} | ||
env: | ||
GITHUB_PAT: ${{ secrets.GH_PERSONAL_TOKEN }} | ||
run: | | ||
chmod +x ./tag-release-plugins.sh; | ||
./tag-release-plugins.sh \ | ||
--release-version=${{github.event.inputs.releaseVersion}} \ | ||
--dry-run \ | ||
--yes \ | ||
${{ steps.plugins-list.outputs.repositories }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,180 @@ | ||
#!/bin/bash | ||
#=============================================================================== | ||
# SCRIPT: tag-release-plugins.sh | ||
# | ||
# DESCRIPTION: | ||
# This script can be used to update and tag plugins from a release branch .e.g., releases/v0.21.x. | ||
# By default, if no `GITHUB_PAT` environment variable exist, the script will attempt to clone GitHub repositories using SSH_KEY. | ||
# | ||
# USAGE: ./tag-release-plugins.sh [options] | ||
# OPTIONS: | ||
# --release-version <version> Specify the release 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 | ||
|
||
# EXAMPLES: | ||
# To release all plugins: | ||
# ./tag-release-plugins.sh --release-version=0.20.0 | ||
# To release a specific plugin: | ||
# ./tag-release-plugins.sh --release-version=0.20.0 plugin-kubernetes | ||
|
||
#=============================================================================== | ||
|
||
set -e; | ||
|
||
############################################################### | ||
# Global vars | ||
############################################################### | ||
BASEDIR=$(dirname "$(readlink -f $0)") | ||
WORKING_DIR=/tmp/kestra-release-plugins-$(date +%s); | ||
PLUGIN_FILE="$BASEDIR/.plugins" | ||
|
||
############################################################### | ||
# Functions | ||
############################################################### | ||
|
||
# Function to display the help message | ||
usage() { | ||
echo "Usage: $0 --release-version <version> [plugin-repositories...]" | ||
echo | ||
echo "Options:" | ||
echo " --release-version <version> Specify the release version (required)." | ||
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 | ||
} | ||
|
||
# Function to ask to continue | ||
function askToContinue() { | ||
read -p "Are you sure you want to continue? [y/N] " confirm | ||
[[ "$confirm" =~ ^[Yy]$ ]] || { echo "Operation cancelled."; exit 1; } | ||
} | ||
|
||
############################################################### | ||
# Options | ||
############################################################### | ||
|
||
PLUGINS_ARGS=() | ||
AUTO_YES=false | ||
DRY_RUN=false | ||
# Get the options | ||
while [[ "$#" -gt 0 ]]; do | ||
case "$1" in | ||
--release-version) | ||
RELEASE_VERSION="$2" | ||
shift 2 | ||
;; | ||
--release-version=*) | ||
RELEASE_VERSION="${1#*=}" | ||
shift | ||
;; | ||
--dry-run) | ||
DRY_RUN=true | ||
shift | ||
;; | ||
-y|--yes) | ||
AUTO_YES=true | ||
shift | ||
;; | ||
-h|--help) | ||
usage | ||
;; | ||
*) | ||
PLUGINS_ARGS+=("$1") | ||
shift | ||
;; | ||
esac | ||
done | ||
|
||
## Check options | ||
if [[ -z "$RELEASE_VERSION" ]]; then | ||
echo -e "Missing required argument: --release-version\n"; | ||
usage | ||
fi | ||
|
||
## Get plugin list | ||
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); | ||
fi | ||
else | ||
PLUGINS_ARRAY=("${PLUGINS_ARGS[@]}") | ||
PLUGINS_COUNT="${#PLUGINS_ARGS[@]}" | ||
fi | ||
|
||
# Extract the major and minor versions | ||
BASE_VERSION=$(echo "$RELEASE_VERSION" | sed -E 's/^([0-9]+\.[0-9]+)\..*/\1/') | ||
RELEASE_BRANCH="releases/v${BASE_VERSION}.x" | ||
|
||
## Get plugin list | ||
echo "RELEASE_VERSION=$RELEASE_VERSION" | ||
echo "RELEASE_BRANCH=$RELEASE_BRANCH" | ||
echo "DRY_RUN=$DRY_RUN" | ||
echo "Found ($PLUGINS_COUNT) plugin repositories:"; | ||
|
||
for PLUGIN in "${PLUGINS_ARRAY[@]}"; do | ||
echo "$PLUGIN" | ||
done | ||
|
||
if [[ "$AUTO_YES" == false ]]; then | ||
askToContinue | ||
fi | ||
|
||
############################################################### | ||
# Main | ||
############################################################### | ||
mkdir -p $WORKING_DIR | ||
|
||
COUNTER=1; | ||
for PLUGIN in "${PLUGINS_ARRAY[@]}" | ||
do | ||
cd $WORKING_DIR; | ||
|
||
echo "---------------------------------------------------------------------------------------" | ||
echo "[$COUNTER/$PLUGINS_COUNT] $PLUGIN" | ||
echo "---------------------------------------------------------------------------------------" | ||
if [[ -z "${GITHUB_PAT}" ]]; then | ||
git clone [email protected]:kestra-io/$PLUGIN | ||
else | ||
echo "Clone git repository using GITHUB PAT" | ||
git clone https://${GITHUB_PAT}@github.com/kestra-io/$PLUGIN.git | ||
fi | ||
|
||
cd "$PLUGIN"; | ||
|
||
git checkout $RELEASE_BRANCH; | ||
|
||
if [[ "$DRY_RUN" == false ]]; then | ||
CURRENT_BRANCH=$(git branch --show-current); | ||
|
||
echo "Update version and tag plugin: $PLUGIN"; | ||
echo "Branch: $CURRENT_BRANCH"; | ||
|
||
if [[ "$AUTO_YES" == false ]]; then | ||
askToContinue | ||
fi | ||
|
||
# Checkout release branch | ||
git checkout "$RELEASE_BRANCH"; | ||
|
||
# Update version | ||
sed -i.bak "s/^version=.*/version=$RELEASE_VERSION/" ./gradle.properties | ||
git add ./gradle.properties | ||
git commit -m"chore(version): update to version 'v$RELEASE_VERSION'." | ||
git push | ||
git tag -a "v$RELEASE_VERSION" -m"v$RELEASE_VERSION" | ||
git push origin "v$RELEASE_VERSION" | ||
|
||
sleep 5; # add a short delay to not spam Maven Central | ||
else | ||
echo "Skip tagging [DRY_RUN=true]"; | ||
fi | ||
COUNTER=$(( COUNTER + 1 )); | ||
done; | ||
|
||
exit 0; |