Releases #11
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
# | |
# SPDX-License-Identifier: Apache-2.0 | |
# Copyright (c) StreamThoughts | |
# | |
# Licensed under the Apache Software License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0 | |
# | |
name: Releases | |
on: | |
workflow_dispatch: | |
inputs: | |
newVersion: | |
type: string | |
required: false | |
description: "New version (if null use current version)" | |
createTag: | |
type: boolean | |
required: true | |
description: "Create a Tag" | |
default: true | |
generateDoc: | |
type: boolean | |
required: true | |
description: "Generate doc for release" | |
default: true | |
env: | |
JAVA_VERSION: '11' | |
JAVA_DISTRO: 'zulu' | |
jobs: | |
set-release-version: | |
runs-on: ubuntu-latest | |
name: 'Set Release Version' | |
outputs: | |
HEAD: ${{ steps.version.outputs.HEAD }} | |
RELEASE_VERSION: ${{ steps.version.outputs.RELEASE_VERSION }} | |
steps: | |
- name: 'Checkout GitHub repository' | |
uses: actions/checkout@v4 | |
with: | |
clean: true | |
- name: 'Set up Java' | |
uses: actions/setup-java@v3 | |
with: | |
java-version: ${{ env.JAVA_VERSION }} | |
distribution: ${{ env.JAVA_DISTRO }} | |
check-latest: true | |
cache: maven | |
- name: 'Import GPG key' | |
uses: crazy-max/ghaction-import-gpg@v6 | |
with: | |
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }} | |
passphrase: ${{ secrets.GPG_PASSPHRASE }} | |
- name: 'Grant execute permission to MVN Wrapper' | |
run: chmod +x ./mvnw | |
- name: Update release version | |
if: "${{ github.event.inputs.newVersion == '' }}" | |
run: | | |
echo 'Remove snapshot from maven version' | |
./mvnw -q versions:set -DremoveSnapshot -DprocessAllModules -DgenerateBackupPoms=false | |
- name: Set specific version to release | |
if: "${{ github.event.inputs.newVersion != '' }}" | |
run: | | |
./mvnw -q versions:set -DnewVersion=${{ github.event.inputs.newVersion }} | |
- name: 'Set env RELEASE_VERSION' | |
run: | | |
RELEASE_VERSION=$(./mvnw org.apache.maven.plugins:maven-help-plugin:3.1.0:evaluate -Dexpression=project.version -q -DforceStdout) | |
echo "RELEASE_VERSION=$RELEASE_VERSION" >> $GITHUB_ENV | |
- name: 'Update Documentation' | |
if: "${{ github.event.inputs.generateDoc == 'true' }}" | |
run: | | |
DOC_BASEDIR="./docs/content/en/docs" | |
RELEASE_DOC_VERSION=$(echo ${{ env.RELEASE_VERSION }} | sed 's/\([0-9]\)\s*$/\x/') | |
RELEASE_DOC_DIR="$DOC_BASEDIR/Archives/v${{ env.RELEASE_VERSION }}" | |
RELEASE_DOC_LINK=$(echo ${{ env.RELEASE_VERSION }} | sed -r 's/\.+/-/g') | |
RELEASE_DOC_LINK=${RELEASE_DOC_LINK%??} | |
DIRS=( | |
"Developer Guide" | |
"Examples" | |
"FAQ" | |
"Getting started" | |
"Overview" | |
"Project Info" | |
) | |
echo "Creating release site documentation: v$RELEASE_DOC_VERSION" | |
mkdir -p "$RELEASE_DOC_DIR" | |
for DIR in "${DIRS[@]}"; do | |
echo "Copying $DIR to $DOC_BASEDIR/$DIR"; | |
cp -r "$DOC_BASEDIR/$DIR" "$RELEASE_DOC_DIR"; | |
done | |
echo "Creating $RELEASE_DOC_DIR/_index.md" | |
cat > "$RELEASE_DOC_DIR/_index.md" <<EOF | |
--- | |
title: "Docs Release v$RELEASE_DOC_VERSION" | |
linkTitle: "v$RELEASE_DOC_VERSION" | |
url: "/v$RELEASE_DOC_LINK/docs" | |
--- | |
This section is where the user documentation for Connect File Pulse lives - all the information that users need to understand and successfully use Connect File Pulse. | |
EOF | |
echo "Updating ./docs/config.toml" | |
cat >> "./docs/config.toml" <<EOF | |
[[params.versions]] | |
version = "v$RELEASE_DOC_VERSION" | |
url = "/kafka-connect-file-pulse/v$RELEASE_DOC_LINK/docs" | |
EOF | |
- 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]" | |
- name: 'Push release version' | |
id: version | |
if: "${{ github.event.inputs.createTag == 'true' }}" | |
run: | | |
git add "./docs/*" | |
find . -name 'pom.xml' | xargs git add | |
git commit -m "ci: release version ${{ env.RELEASE_VERSION }} 🎉" | |
git push --atomic origin HEAD:${GITHUB_REF#refs/heads/} | |
HEAD=$(git rev-parse HEAD) | |
echo "HEAD=$HEAD" >> $GITHUB_OUTPUT | |
echo "RELEASE_VERSION=$RELEASE_VERSION" >> $GITHUB_OUTPUT | |
build-distribution: | |
needs: [ set-release-version ] | |
name: 'Build Artifacts' | |
runs-on: ubuntu-latest | |
steps: | |
- name: 'Checkout GitHub repository' | |
uses: actions/checkout@v4 | |
with: | |
ref: ${{ needs.set-release-version.outputs.HEAD }} | |
fetch-depth: 0 | |
clean: true | |
- name: 'Set up Java' | |
uses: actions/setup-java@v3 | |
with: | |
java-version: ${{ env.JAVA_VERSION }} | |
distribution: ${{ env.JAVA_DISTRO }} | |
cache: 'maven' | |
- name: 'Build Distribution' | |
run: | | |
./mvnw -ntp -B --file pom.xml -Pall,dist package | |
- name: 'Upload build artifact' | |
uses: actions/upload-artifact@v3 | |
with: | |
name: artifacts | |
path: | | |
connect-file-pulse-plugin/target/components/packages/*.zip | |
release-artifacts: | |
name: 'Release Artifacts' | |
needs: [ set-release-version, build-distribution ] | |
runs-on: ubuntu-latest | |
steps: | |
- name: 'Checkout GitHub repository' | |
uses: actions/checkout@v4 | |
with: | |
ref: ${{ needs.set-release-version.outputs.HEAD }} | |
fetch-depth: 0 | |
- name: 'Download all artifacts' | |
uses: actions/download-artifact@v3 | |
- name: 'Set up Java' | |
uses: actions/setup-java@v3 | |
with: | |
java-version: ${{ env.JAVA_VERSION }} | |
distribution: ${{ env.JAVA_DISTRO }} | |
- name: 'Cache Maven packages' | |
uses: actions/cache@v4 | |
with: | |
path: ~/.m2 | |
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }} | |
restore-keys: ${{ runner.os }}-m2 | |
- 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]" | |
- name: 'Release with JReleaser' | |
env: | |
JRELEASER_BRANCH: ${{ needs.set-release-version.outputs.HEAD }} | |
JRELEASER_GITHUB_TOKEN: ${{ secrets.PAT }} | |
JRELEASER_GPG_PUBLIC_KEY: ${{ secrets.GPG_PUBLIC_KEY }} | |
JRELEASER_GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }} | |
JRELEASER_GPG_SECRET_KEY: ${{ secrets.GPG_PRIVATE_KEY }} | |
run: ./mvnw -ntp -B --file ./pom.xml -Prelease -DartifactsDir=artifacts jreleaser:full-release | |
- name: 'JReleaser output' | |
if: always() | |
uses: actions/upload-artifact@v3 | |
with: | |
name: jreleaser-logs | |
path: | | |
target/jreleaser/trace.log | |
target/jreleaser/output.properties | |
- name: 'Bump version for next iteration' | |
if: "${{ github.event.inputs.newVersion == '' }}" | |
run: | | |
./mvnw -q build-helper:parse-version versions:set \ | |
-DnewVersion=\${parsedVersion.majorVersion}.\${parsedVersion.nextMinorVersion}.0-SNAPSHOT \ | |
versions:commit | |
NEXT_VERSION=$(./mvnw org.apache.maven.plugins:maven-help-plugin:3.1.0:evaluate -Dexpression=project.version -q -DforceStdout) | |
echo "NEXT_VERSION=$NEXT_VERSION" >> $GITHUB_ENV | |
- name: 'Commit Bump Version' | |
if: "${{ github.event.inputs.newVersion == '' }}" | |
run: | | |
find . -name 'pom.xml' | xargs git add | |
git commit -m "ci: bump version for next iteration to ${{ env.NEXT_VERSION }} 🤖" | |
git push origin HEAD:${{ needs.set-release-version.outputs.HEAD }} |