Skip to content

Commit

Permalink
feat(ci): add workflows for release process
Browse files Browse the repository at this point in the history
* move scripts to folder dev-tools
* add new workflow gradle-release.yml
* add new workflow setversion-tag.yml
* rename existing workflow
  • Loading branch information
fhussonnois committed Feb 7, 2025
1 parent c8d7e5f commit 480fc75
Show file tree
Hide file tree
Showing 7 changed files with 184 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on:
workflow_dispatch:
inputs:
releaseVersion:
description: 'The release version (e.g., 0.21.0-RC1)'
description: 'The release version (e.g., 0.21.0-rc1)'
required: true
type: string
nextVersion:
Expand Down Expand Up @@ -59,7 +59,7 @@ jobs:
env:
GITHUB_PAT: ${{ secrets.GH_PERSONAL_TOKEN }}
run: |
chmod +x ./release-plugins.sh;
chmod +x ./dev-tools/release-plugins.sh;
./release-plugins.sh \
--release-version=${{github.event.inputs.releaseVersion}} \
--next-version=${{github.event.inputs.nextVersion}} \
Expand All @@ -71,7 +71,7 @@ jobs:
env:
GITHUB_PAT: ${{ secrets.GH_PERSONAL_TOKEN }}
run: |
chmod +x ./release-plugins.sh;
chmod +x ./dev-tools/release-plugins.sh;
./release-plugins.sh \
--release-version=${{github.event.inputs.releaseVersion}} \
--next-version=${{github.event.inputs.nextVersion}} \
Expand Down
89 changes: 89 additions & 0 deletions .github/workflows/gradle-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
name: Run Gradle Release
run-name: "Releasing Kestra ${{ github.event.inputs.releaseVersion }} 🚀"
on:
workflow_dispatch:
inputs:
releaseVersion:
description: 'The release version (e.g., 0.21.0-rc1)'
required: true
type: string
nextVersion:
description: 'The next version (e.g., 0.22.0-SNAPSHOT)'
required: true
type: string
env:
RELEASE_VERSION: "${{ github.event.inputs.releaseVersion }}"
NEXT_VERSION: "${{ github.event.inputs.nextVersion }}"
jobs:
release:
name: Release Kestra
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/develop'
steps:
# Checks
- name: Check Inputs
run: |
if ! [[ "$RELEASE_VERSION" =~ ^[0-9]+(\.[0-9]+)\.0-rc[01](-SNAPSHOT)?$ ]]; then
echo "Invalid release version. Must match regex: ^[0-9]+(\.[0-9]+)\.0-rc[01](-SNAPSHOT)?$"
exit 1
fi
if ! [[ "$NEXT_VERSION" =~ ^[0-9]+(\.[0-9]+)\.0-SNAPSHOT$ ]]; then
echo "Invalid next version. Must match regex: ^[0-9]+(\.[0-9]+)\.0-SNAPSHOT$"
exit 1;
fi
# Checkout
- uses: actions/checkout@v4
with:
fetch-depth: 0

# Checkout GitHub Actions
- uses: actions/checkout@v4
with:
repository: kestra-io/actions
path: actions
ref: main

# Setup build
- uses: ./actions/.github/actions/setup-build
id: build
with:
java-enabled: true
node-enabled: true
python-enabled: true
caches-enabled: true

- 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
env:
GITHUB_PAT: ${{ secrets.GH_PERSONAL_TOKEN }}
run: |
# Extract the major and minor versions
BASE_VERSION=$(echo "$RELEASE_VERSION" | sed -E 's/^([0-9]+\.[0-9]+)\..*/\1/')
PUSH_RELEASE_BRANCH="releases/v${BASE_VERSION}.x"
# Create and push release branch
git checkout -b "$PUSH_RELEASE_BRANCH";
git push -u origin "$PUSH_RELEASE_BRANCH";

# Run gradle release
git checkout develop;

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}" \
-Prelease.pushReleaseVersionBranch="${PUSH_RELEASE_BRANCH}" \
-Prelease.failOnSnapshotDependencies=false
else
./gradlew release -Prelease.useAutomaticVersion=true \
-Prelease.releaseVersion="${RELEASE_VERSION}" \
-Prelease.newVersion="${NEXT_VERSION}" \
-Prelease.pushReleaseVersionBranch="${PUSH_RELEASE_BRANCH}"
fi
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ jobs:
env:
GITHUB_PAT: ${{ secrets.GH_PERSONAL_TOKEN }}
run: |
chmod +x ./tag-release-plugins.sh;
chmod +x ./dev-tools/setversion-tag-plugins.sh;
./tag-release-plugins.sh \
--release-version=${{github.event.inputs.releaseVersion}} \
--yes \
Expand All @@ -66,7 +66,7 @@ jobs:
env:
GITHUB_PAT: ${{ secrets.GH_PERSONAL_TOKEN }}
run: |
chmod +x ./tag-release-plugins.sh;
chmod +x ./dev-tools/setversion-tag-plugins.sh;
./tag-release-plugins.sh \
--release-version=${{github.event.inputs.releaseVersion}} \
--dry-run \
Expand Down
74 changes: 74 additions & 0 deletions .github/workflows/setversion-tag.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
name: Set Version and Tag
run-name: "Set version and Tag Kestra to ${{ github.event.inputs.releaseVersion }} 🚀"
on:
workflow_dispatch:
inputs:
releaseVersion:
description: 'The release version (e.g., 0.21.1)'
required: true
type: string
env:
RELEASE_VERSION: "${{ github.event.inputs.releaseVersion }}"
jobs:
release:
name: Release Kestra
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/heads/releases/v')
steps:
# Checks
- name: Check Inputs
run: |
if ! [[ "$RELEASE_VERSION" =~ ^[0-9]+(\.[0-9]+)(\.[0-9]+)(-rc[0-9])?(-SNAPSHOT)?$ ]]; then
echo "Invalid release version. Must match regex: ^[0-9]+(\.[0-9]+)(\.[0-9]+)-(rc[0-9])?(-SNAPSHOT)?$"
exit 1
fi
CURRENT_BRANCH="{{ github.ref }}"
# Extract the major and minor versions
BASE_VERSION=$(echo "$RELEASE_VERSION" | sed -E 's/^([0-9]+\.[0-9]+)\..*/\1/')
RELEASE_BRANCH="refs/heads/releases/v${BASE_VERSION}.x"
if ! [[ "$CURRENT_BRANCH" == "$RELEASE_BRANCH" ]]; then
echo "Invalid release branch. Expected $RELEASE_BRANCH, was $CURRENT_BRANCH"
exit 1
fi
# Checkout
- uses: actions/checkout@v4
with:
fetch-depth: 0

# Checkout GitHub Actions
- uses: actions/checkout@v4
with:
repository: kestra-io/actions
path: actions
ref: main

# Setup build
- uses: ./actions/.github/actions/setup-build
id: build
with:
java-enabled: true
node-enabled: true
python-enabled: true
caches-enabled: true

- 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
env:
GITHUB_PAT: ${{ secrets.GH_PERSONAL_TOKEN }}
run: |
# Update version
sed -i "s/^version=.*/version=$RELEASE_VERSION/" ./gradle.properties
git add ./gradle.properties
git commit -m"chore(version): update to version '$RELEASE_VERSION'"
git push
git tag -a "v$RELEASE_VERSION" -m"v$RELEASE_VERSION"
git push origin "v$RELEASE_VERSION"
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ set -e;
###############################################################
BASEDIR=$(dirname "$(readlink -f $0)")
WORKING_DIR=/tmp/kestra-plugins;
PLUGIN_FILE="$BASEDIR/.plugins"
PLUGIN_FILE="$BASEDIR/../.plugins"

# Maven Central URL
MAVEN_CENTRAL="https://repo1.maven.org/maven2"
Expand All @@ -37,7 +37,7 @@ SONATYPE_SNAPSHOT="https://s01.oss.sonatype.org/content/repositories/snapshots"

# Function to display the help message
usage() {
echo "Usage: $0 [--working-dir /tmp/kestra] [--plugin-file]"
echo "Usage: $0 --version <version> [--plugin-file]"
echo
echo "Options:"
echo " --plugin-file File containing the plugin list"
Expand Down Expand Up @@ -92,6 +92,12 @@ while [[ "$#" -gt 0 ]]; do
esac
done

## Check options
if [[ -z "$VERSION" ]]; then
echo -e "Missing required argument: --version\n";
usage
fi

## Get plugin list
if [[ "${#PLUGINS_ARGS[@]}" -eq 0 ]]; then
if [ -f "$PLUGIN_FILE" ]; then
Expand Down Expand Up @@ -150,6 +156,6 @@ do
COUNTER=$(( COUNTER + 1 ));
done;

echo "✅ Available: $AVAILABLE, ❌ Unavailable: $NOT_AVAILABLE"
echo -e "\n\n✅ Available: $AVAILABLE, ❌ Unavailable: $NOT_AVAILABLE";

exit 0;
2 changes: 1 addition & 1 deletion release-plugins.sh → dev-tools/release-plugins.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ set -e;
###############################################################
BASEDIR=$(dirname "$(readlink -f $0)")
WORKING_DIR=/tmp/kestra-release-plugins-$(date +%s);
PLUGIN_FILE="$BASEDIR/.plugins"
PLUGIN_FILE="$BASEDIR/../.plugins"
GIT_BRANCH=master

###############################################################
Expand Down
12 changes: 6 additions & 6 deletions tag-release-plugins.sh → dev-tools/setversion-tag-plugins.sh
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
#!/bin/bash
#===============================================================================
# SCRIPT: tag-release-plugins.sh
# SCRIPT: setversion-tag-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]
# USAGE: ./setversion-tag-plugins.sh [options]
# OPTIONS:
# --release-version <version> Specify the release version (required)
# --dry-run Specify to run in DRY_RUN.
Expand All @@ -15,11 +15,11 @@

# EXAMPLES:
# To release all plugins:
# ./tag-release-plugins.sh --release-version=0.20.0
# ./setversion-tag-plugins.sh --release-version=0.20.0
# To release a specific plugin:
# ./tag-release-plugins.sh --release-version=0.20.0 plugin-kubernetes
# ./setversion-tag-plugins.sh --release-version=0.20.0 plugin-kubernetes
# To release specific plugins from file:
# ./tag-release-plugins.sh --release-version=0.20.0 --plugin-file .plugins
# ./setversion-tag-plugins.sh --release-version=0.20.0 --plugin-file .plugins
#===============================================================================

set -e;
Expand All @@ -29,7 +29,7 @@ set -e;
###############################################################
BASEDIR=$(dirname "$(readlink -f $0)")
WORKING_DIR=/tmp/kestra-release-plugins-$(date +%s);
PLUGIN_FILE="$BASEDIR/.plugins"
PLUGIN_FILE="$BASEDIR/../.plugins"

###############################################################
# Functions
Expand Down

0 comments on commit 480fc75

Please sign in to comment.