Skip to content

Commit 091d480

Browse files
committed
ci: update release workflow
1 parent 669a804 commit 091d480

File tree

1 file changed

+65
-79
lines changed

1 file changed

+65
-79
lines changed

.github/workflows/release.yml

Lines changed: 65 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,13 @@ name: Releases
99
on:
1010
workflow_dispatch:
1111
inputs:
12-
newVersion:
12+
version:
1313
type: string
1414
required: false
1515
description: "New version (if null use current version)"
16-
createTag:
17-
type: boolean
18-
required: true
19-
description: "Create a Tag"
20-
default: true
16+
next:
17+
description: "Next version"
18+
required: false
2119
generateDoc:
2220
type: boolean
2321
required: true
@@ -56,78 +54,73 @@ jobs:
5654
- name: 'Grant execute permission to MVN Wrapper'
5755
run: chmod +x ./mvnw
5856

59-
- name: Update release version
60-
if: "${{ github.event.inputs.newVersion == '' }}"
61-
run: |
62-
echo 'Remove snapshot from maven version'
63-
./mvnw -q versions:set -DremoveSnapshot -DprocessAllModules -DgenerateBackupPoms=false
64-
65-
- name: Set specific version to release
66-
if: "${{ github.event.inputs.newVersion != '' }}"
67-
run: |
68-
./mvnw -q versions:set -DnewVersion=${{ github.event.inputs.newVersion }}
69-
70-
- name: 'Set env RELEASE_VERSION'
71-
run: |
72-
RELEASE_VERSION=$(./mvnw org.apache.maven.plugins:maven-help-plugin:3.1.0:evaluate -Dexpression=project.version -q -DforceStdout)
73-
echo "RELEASE_VERSION=$RELEASE_VERSION" >> $GITHUB_ENV
74-
75-
- name: 'Update Documentation'
76-
if: "${{ github.event.inputs.generateDoc == 'true' }}"
77-
run: |
78-
DOC_BASEDIR="./docs/content/en/docs"
79-
RELEASE_DOC_VERSION=$(echo ${{ env.RELEASE_VERSION }} | sed 's/\([0-9]\)\s*$/\x/')
80-
RELEASE_DOC_DIR="$DOC_BASEDIR/Archives/v${{ env.RELEASE_VERSION }}"
81-
RELEASE_DOC_LINK=$(echo ${{ env.RELEASE_VERSION }} | sed -r 's/\.+/-/g')
82-
RELEASE_DOC_LINK=${RELEASE_DOC_LINK%??}
83-
DIRS=(
84-
"Developer Guide"
85-
"Examples"
86-
"FAQ"
87-
"Getting started"
88-
"Overview"
89-
"Project Info"
90-
)
91-
echo "Creating release site documentation: v$RELEASE_DOC_VERSION"
92-
mkdir -p "$RELEASE_DOC_DIR"
93-
for DIR in "${DIRS[@]}"; do
94-
echo "Copying $DIR to $DOC_BASEDIR/$DIR";
95-
cp -r "$DOC_BASEDIR/$DIR" "$RELEASE_DOC_DIR";
96-
done
97-
98-
echo "Creating $RELEASE_DOC_DIR/_index.md"
99-
cat > "$RELEASE_DOC_DIR/_index.md" <<EOF
100-
---
101-
title: "Docs Release v$RELEASE_DOC_VERSION"
102-
linkTitle: "v$RELEASE_DOC_VERSION"
103-
url: "/v$RELEASE_DOC_LINK/docs"
104-
---
105-
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.
106-
EOF
107-
108-
echo "Updating ./docs/config.toml"
109-
cat >> "./docs/config.toml" <<EOF
110-
[[params.versions]]
111-
version = "v$RELEASE_DOC_VERSION"
112-
url = "/kafka-connect-file-pulse/v$RELEASE_DOC_LINK/docs"
113-
EOF
114-
11557
- name: 'Configure Git'
11658
run: |
11759
git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"
11860
git config --global user.name "github-actions[bot]"
11961
120-
- name: 'Push release version'
62+
- name: 'Update Documentation'
63+
if: "${{ github.event.inputs.generateDoc == 'true' }}"
64+
run: |
65+
RELEASE_VERSION=${{ github.event.inputs.version }}
66+
67+
DOC_BASEDIR="./docs/content/en/docs"
68+
RELEASE_DOC_VERSION=$(echo ${{ env.RELEASE_VERSION }} | sed 's/\([0-9]\)\s*$/\x/')
69+
RELEASE_DOC_DIR="$DOC_BASEDIR/Archives/v${{ env.RELEASE_VERSION }}"
70+
RELEASE_DOC_LINK=$(echo ${{ env.RELEASE_VERSION }} | sed -r 's/\.+/-/g')
71+
RELEASE_DOC_LINK=${RELEASE_DOC_LINK%??}
72+
DIRS=(
73+
"Developer Guide"
74+
"Examples"
75+
"FAQ"
76+
"Getting started"
77+
"Overview"
78+
"Project Info"
79+
)
80+
echo "Creating release site documentation: v$RELEASE_DOC_VERSION"
81+
mkdir -p "$RELEASE_DOC_DIR"
82+
for DIR in "${DIRS[@]}"; do
83+
echo "Copying $DIR to $DOC_BASEDIR/$DIR";
84+
cp -r "$DOC_BASEDIR/$DIR" "$RELEASE_DOC_DIR";
85+
done
86+
87+
echo "Creating $RELEASE_DOC_DIR/_index.md"
88+
cat > "$RELEASE_DOC_DIR/_index.md" <<EOF
89+
---
90+
title: "Docs Release v$RELEASE_DOC_VERSION"
91+
linkTitle: "v$RELEASE_DOC_VERSION"
92+
url: "/v$RELEASE_DOC_LINK/docs"
93+
---
94+
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.
95+
EOF
96+
97+
echo "Updating ./docs/config.toml"
98+
cat >> "./docs/config.toml" <<EOF
99+
[[params.versions]]
100+
version = "v$RELEASE_DOC_VERSION"
101+
url = "/kafka-connect-file-pulse/v$RELEASE_DOC_LINK/docs"
102+
EOF
103+
104+
- name: 'Set release version'
121105
id: version
122-
if: "${{ github.event.inputs.createTag == 'true' }}"
123106
run: |
124-
git add "./docs/*"
107+
RELEASE_VERSION=${{ github.event.inputs.version }}
108+
NEXT_VERSION=${{ github.event.inputs.next }}
109+
if [ -z $NEXT_VERSION ]
110+
then
111+
PLAIN_VERSION=`echo ${RELEASE_VERSION} | awk 'match($0, /^(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)/) { print substr($0, RSTART, RLENGTH); }'`
112+
NEXT_VERSION="${PLAIN_VERSION}-SNAPSHOT"
113+
fi
114+
chmod +x ./mvnw
115+
./mvnw -ntp -B versions:set versions:commit -DnewVersion=$RELEASE_VERSION
125116
find . -name 'pom.xml' | xargs git add
126-
git commit -m "ci: release version ${{ env.RELEASE_VERSION }} 🎉"
117+
git commit -m "ci: release version $RELEASE_VERSION 🎉"
127118
git push --atomic origin HEAD:${GITHUB_REF#refs/heads/}
128119
HEAD=$(git rev-parse HEAD)
129120
echo "HEAD=$HEAD" >> $GITHUB_OUTPUT
130121
echo "RELEASE_VERSION=$RELEASE_VERSION" >> $GITHUB_OUTPUT
122+
echo "NEXT_VERSION=$NEXT_VERSION" >> $GITHUB_OUTPUT
123+
131124
132125
build-distribution:
133126
needs: [ set-release-version ]
@@ -200,7 +193,7 @@ jobs:
200193
JRELEASER_GITHUB_TOKEN: ${{ secrets.PAT }}
201194
JRELEASER_GPG_PUBLIC_KEY: ${{ secrets.GPG_PUBLIC_KEY }}
202195
JRELEASER_GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
203-
JRELEASER_GPG_SECRET_KEY: ${{ secrets.GPG_PRIVATE_KEY }}
196+
JRELEASER_GPG_SECRET_KEY: ${{ secrets.GPG_PRIVATE_KEY }}
204197
run: ./mvnw -ntp -B --file ./pom.xml -Prelease -DartifactsDir=artifacts jreleaser:full-release
205198

206199
- name: 'JReleaser output'
@@ -212,18 +205,11 @@ jobs:
212205
target/jreleaser/trace.log
213206
target/jreleaser/output.properties
214207
215-
- name: 'Bump version for next iteration'
216-
if: "${{ github.event.inputs.newVersion == '' }}"
217-
run: |
218-
./mvnw -q build-helper:parse-version versions:set \
219-
-DnewVersion=\${parsedVersion.majorVersion}.\${parsedVersion.nextMinorVersion}.0-SNAPSHOT \
220-
versions:commit
221-
NEXT_VERSION=$(./mvnw org.apache.maven.plugins:maven-help-plugin:3.1.0:evaluate -Dexpression=project.version -q -DforceStdout)
222-
echo "NEXT_VERSION=$NEXT_VERSION" >> $GITHUB_ENV
223-
224-
- name: 'Commit Bump Version'
225-
if: "${{ github.event.inputs.newVersion == '' }}"
208+
- name: 'Commit Next Version'
209+
env:
210+
NEXT_VERSION: ${{ needs.set-release-version.outputs.NEXT_VERSION }}
226211
run: |
212+
./mvnw -ntp -B versions:set versions:commit -DnewVersion=${{ env.NEXT_VERSION }}
227213
find . -name 'pom.xml' | xargs git add
228214
git commit -m "ci: bump version for next iteration to ${{ env.NEXT_VERSION }} 🤖"
229-
git push origin HEAD:${{ needs.set-release-version.outputs.HEAD }}
215+
git push origin HEAD:${GITHUB_REF#refs/heads/}

0 commit comments

Comments
 (0)