From ff5cea4d668d22ca79957bb72a7d91de2aa0bf57 Mon Sep 17 00:00:00 2001 From: Florian Hussonnois Date: Fri, 7 Feb 2025 08:43:47 +0100 Subject: [PATCH] feat(ci): add workflows for release process * move scripts to folder dev-tools * add new workflow gradle-release.yml * add new workflow setversion-tag.yml * rename existing workflow --- ...plugins.yml => gradle-release-plugins.yml} | 6 +- .github/workflows/gradle-release.yml | 89 +++++++++++++++++++ ...plugins.yml => setversion-tag-plugins.yml} | 4 +- .github/workflows/setversion-tag.yml | 74 +++++++++++++++ .../check-plugin-artifacts.sh | 12 ++- .../release-plugins.sh | 0 .../setversion-tag-plugins.sh | 10 +-- 7 files changed, 182 insertions(+), 13 deletions(-) rename .github/workflows/{release-plugins.yml => gradle-release-plugins.yml} (93%) create mode 100644 .github/workflows/gradle-release.yml rename .github/workflows/{tag-plugins.yml => setversion-tag-plugins.yml} (94%) create mode 100644 .github/workflows/setversion-tag.yml rename check-plugin-artifacts.sh => dev-tools/check-plugin-artifacts.sh (94%) rename release-plugins.sh => dev-tools/release-plugins.sh (100%) rename tag-release-plugins.sh => dev-tools/setversion-tag-plugins.sh (94%) diff --git a/.github/workflows/release-plugins.yml b/.github/workflows/gradle-release-plugins.yml similarity index 93% rename from .github/workflows/release-plugins.yml rename to .github/workflows/gradle-release-plugins.yml index a65e56a0533..e039ce6ec94 100644 --- a/.github/workflows/release-plugins.yml +++ b/.github/workflows/gradle-release-plugins.yml @@ -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: @@ -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}} \ @@ -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}} \ diff --git a/.github/workflows/gradle-release.yml b/.github/workflows/gradle-release.yml new file mode 100644 index 00000000000..bdedb40c178 --- /dev/null +++ b/.github/workflows/gradle-release.yml @@ -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 \ No newline at end of file diff --git a/.github/workflows/tag-plugins.yml b/.github/workflows/setversion-tag-plugins.yml similarity index 94% rename from .github/workflows/tag-plugins.yml rename to .github/workflows/setversion-tag-plugins.yml index ddd4f7a3a3b..b8d0a9248d5 100644 --- a/.github/workflows/tag-plugins.yml +++ b/.github/workflows/setversion-tag-plugins.yml @@ -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 \ @@ -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 \ diff --git a/.github/workflows/setversion-tag.yml b/.github/workflows/setversion-tag.yml new file mode 100644 index 00000000000..4812666c6d3 --- /dev/null +++ b/.github/workflows/setversion-tag.yml @@ -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" \ No newline at end of file diff --git a/check-plugin-artifacts.sh b/dev-tools/check-plugin-artifacts.sh similarity index 94% rename from check-plugin-artifacts.sh rename to dev-tools/check-plugin-artifacts.sh index f9ad3eff26f..2d075cddb30 100755 --- a/check-plugin-artifacts.sh +++ b/dev-tools/check-plugin-artifacts.sh @@ -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" @@ -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 [--plugin-file]" echo echo "Options:" echo " --plugin-file File containing the plugin list" @@ -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 @@ -150,6 +156,6 @@ do COUNTER=$(( COUNTER + 1 )); done; -echo "✅ Available: $AVAILABLE, ❌ Unavailable: $NOT_AVAILABLE" +echo -e "%n ✅ Available: $AVAILABLE, ❌ Unavailable: $NOT_AVAILABLE %n"; exit 0; diff --git a/release-plugins.sh b/dev-tools/release-plugins.sh similarity index 100% rename from release-plugins.sh rename to dev-tools/release-plugins.sh diff --git a/tag-release-plugins.sh b/dev-tools/setversion-tag-plugins.sh similarity index 94% rename from tag-release-plugins.sh rename to dev-tools/setversion-tag-plugins.sh index 83f39580fc4..58b8987eb52 100755 --- a/tag-release-plugins.sh +++ b/dev-tools/setversion-tag-plugins.sh @@ -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 Specify the release version (required) # --dry-run Specify to run in DRY_RUN. @@ -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;