Skip to content

Commit 79442a7

Browse files
5hin0biHaarolean
andauthored
Change the way of release workflow (#1434)
* use version placeholders in pom.xml files * add release drafter config and workflow * update master workflow * update release workflow * update branch-deploy.yml workflow Co-authored-by: Roman Zabaluev <[email protected]>
1 parent 45b9a10 commit 79442a7

File tree

9 files changed

+90
-90
lines changed

9 files changed

+90
-90
lines changed

.github/release_drafter.yaml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
name-template: 'v$RESOLVED_VERSION'
2+
tag-template: '$RESOLVED_VERSION'
3+
template: |
4+
## Changes
5+
$CHANGES
6+
## Contributors
7+
$CONTRIBUTORS
8+
9+
exclude-labels:
10+
- 'skip-changelog'
11+
12+
categories:
13+
- title: '⚙️Features'
14+
labels:
15+
- 'type/feature'
16+
- title: '🪛Enhancements'
17+
labels:
18+
- 'type/enhancement'
19+
- title: '🔨Bug Fixes'
20+
labels:
21+
- 'type/bug'
22+
23+
change-template: '- $TITLE @$AUTHOR (#$NUMBER)'
24+
25+
version-resolver:
26+
major:
27+
labels:
28+
- 'major'
29+
minor:
30+
labels:
31+
- 'minor'
32+
patch:
33+
labels:
34+
- 'patch'
35+
default: patch

.github/workflows/branch-deploy.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,9 @@ jobs:
3535
- name: Build
3636
id: build
3737
run: |
38-
export VERSION=$(mvn -q -Dexec.executable=echo -Dexec.args='${project.version}' --non-recursive exec:exec)
38+
mvn clean package -Pprod -DskipTests -DbuildVersion=$GITHUB_SHA
39+
export VERSION=$(mvn -q -Dexec.executable=echo -Dexec.args='${project.version}' -DbuildVersion=$GITHUB_SHA --non-recursive exec:exec)
3940
echo "::set-output name=version::${VERSION}"
40-
mvn clean package -Pprod -DskipTests
4141
- name: Set up QEMU
4242
uses: docker/setup-qemu-action@v1
4343
- name: Set up Docker Buildx

.github/workflows/master.yaml

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: latest
1+
name: Master
22
on:
33
workflow_dispatch:
44
push:
@@ -9,44 +9,51 @@ jobs:
99
runs-on: ubuntu-latest
1010
steps:
1111
- uses: actions/checkout@v2
12+
1213
- name: Cache local Maven repository
1314
uses: actions/cache@v2
1415
with:
1516
path: ~/.m2/repository
1617
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
1718
restore-keys: |
1819
${{ runner.os }}-maven-
20+
1921
- name: Set up JDK 1.13
2022
uses: actions/setup-java@v1
2123
with:
2224
java-version: 1.13
25+
2326
- name: Build
2427
id: build
2528
run: |
26-
export VERSION=$(mvn -q -Dexec.executable=echo -Dexec.args='${project.version}' --non-recursive exec:exec)
29+
mvn clean package -Pprod -DskipTests -DbuildVersion=$GITHUB_SHA
30+
export VERSION=$(mvn -q -Dexec.executable=echo -Dexec.args='${project.version}' -DbuildVersion=$GITHUB_SHA --non-recursive exec:exec)
2731
echo "::set-output name=version::${VERSION}"
28-
mvn clean package -Pprod -DskipTests
2932
#################
3033
# #
3134
# Docker images #
3235
# #
3336
#################
3437
- name: Set up QEMU
3538
uses: docker/setup-qemu-action@v1
39+
3640
- name: Set up Docker Buildx
3741
uses: docker/setup-buildx-action@v1
42+
3843
- name: Cache Docker layers
3944
uses: actions/cache@v2
4045
with:
4146
path: /tmp/.buildx-cache
4247
key: ${{ runner.os }}-buildx-${{ github.sha }}
4348
restore-keys: |
4449
${{ runner.os }}-buildx-
50+
4551
- name: Login to DockerHub
4652
uses: docker/login-action@v1
4753
with:
4854
username: ${{ secrets.DOCKERHUB_USERNAME }}
4955
password: ${{ secrets.DOCKERHUB_TOKEN }}
56+
5057
- name: Build and push
5158
id: docker_build_and_push
5259
uses: docker/build-push-action@v2

.github/workflows/release.yaml

Lines changed: 20 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,7 @@
1-
name: release
2-
on:
3-
workflow_dispatch:
4-
inputs:
5-
customVersion:
6-
description: 'A new version for release, please provide with -SNAPSHOT suffix'
7-
required: false
8-
default: '0.0.0'
9-
rebuild:
10-
description: 'A tag name for building previously created release'
11-
required: false
12-
default: 'v0.0.0'
13-
extraMavenOptions:
14-
description: 'A extra options for Maven'
15-
required: false
16-
default: ''
1+
name: Release
2+
on:
3+
release:
4+
types: [published]
175

186
jobs:
197
release:
@@ -24,53 +12,31 @@ jobs:
2412
- uses: actions/checkout@v2
2513
with:
2614
fetch-depth: 0
15+
2716
- run: |
2817
git config user.name github-actions
2918
git config user.email [email protected]
19+
3020
- name: Cache local Maven repository
3121
uses: actions/cache@v2
3222
with:
3323
path: ~/.m2/repository
3424
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
3525
restore-keys: |
3626
${{ runner.os }}-maven-
27+
3728
- name: Set up JDK 1.13
3829
uses: actions/setup-java@v1
3930
with:
4031
java-version: 1.13
41-
- name: Checkout to specific tag
42-
if: github.event.inputs.rebuild != 'v0.0.0'
43-
run: |
44-
git checkout tags/${{ github.event.inputs.rebuild }} -b rebuild-${{ github.event.inputs.rebuild }}
45-
- name: Set custom version
46-
if: github.event.inputs.customVersion != '0.0.0' && github.event.inputs.rebuild == 'v0.0.0'
47-
run: |
48-
mvn -q versions:set -DnewVersion=${{ github.event.inputs.customVersion }}
49-
git add pom.xml **/pom.xml
50-
git commit -m "Increased release"
51-
- name: Update development version
52-
if: github.event.inputs.rebuild == 'v0.0.0'
53-
run: |
54-
mvn -q versions:set -DnextSnapshot
55-
git add pom.xml **/pom.xml
56-
git commit -m "Increased version in pom.xml"
57-
git push -f
58-
git reset --hard HEAD~1
59-
- name: Prepare release
60-
if: github.event.inputs.rebuild == 'v0.0.0'
61-
run: |
62-
mvn -q versions:set -DremoveSnapshot
63-
export VERSION=$(mvn -q -Dexec.executable=echo -Dexec.args='${project.version}' --non-recursive exec:exec)
64-
git add .
65-
git commit -m "release ${VERSION}"
66-
git tag -f v${VERSION}
67-
git push --tags
32+
6833
- name: Build with Maven
6934
id: build
7035
run: |
71-
mvn clean package -Pprod ${{ github.event.inputs.extraMavenOptions }}
72-
export VERSION=$(mvn -q -Dexec.executable=echo -Dexec.args='${project.version}' --non-recursive exec:exec)
36+
mvn clean package -Pprod -DskipTests -DbuildVersion=${{ github.event.release.tag_name }}
37+
export VERSION=$(mvn -q -Dexec.executable=echo -Dexec.args='${project.version}' -DbuildVersion=${{ github.event.release.tag_name }} --non-recursive exec:exec)
7338
echo ::set-output name=version::${VERSION}
39+
7440
- name: Archive JAR
7541
uses: actions/upload-artifact@v2
7642
with:
@@ -83,21 +49,25 @@ jobs:
8349
#################
8450
- name: Set up QEMU
8551
uses: docker/setup-qemu-action@v1
52+
8653
- name: Set up Docker Buildx
8754
uses: docker/setup-buildx-action@v1
55+
8856
- name: Cache Docker layers
8957
uses: actions/cache@v2
9058
with:
9159
path: /tmp/.buildx-cache
9260
key: ${{ runner.os }}-buildx-${{ github.sha }}
9361
restore-keys: |
9462
${{ runner.os }}-buildx-
63+
9564
- name: Login to DockerHub
9665
if: github.ref == 'refs/heads/master'
9766
uses: docker/login-action@v1
9867
with:
9968
username: ${{ secrets.DOCKERHUB_USERNAME }}
10069
password: ${{ secrets.DOCKERHUB_TOKEN }}
70+
10171
- name: Build and push
10272
id: docker_build_and_push
10373
uses: docker/build-push-action@v2
@@ -113,21 +83,26 @@ jobs:
11383
JAR_FILE=kafka-ui-api-${{ steps.build.outputs.version }}.jar
11484
cache-from: type=local,src=/tmp/.buildx-cache
11585
cache-to: type=local,dest=/tmp/.buildx-cache
86+
11687
charts:
11788
runs-on: ubuntu-latest
11889
needs: release
11990
steps:
12091
- uses: actions/checkout@v2
12192
with:
12293
fetch-depth: 1
94+
12395
- run: |
12496
git config user.name github-actions
12597
git config user.email [email protected]
98+
12699
- uses: azure/setup-helm@v1
100+
127101
- name: update appVersion
128102
run: |
129103
export version=${{needs.release.outputs.version}}
130104
sed -i "s/appVersion:.*/appVersion: ${version}/" charts/kafka-ui/Chart.yaml
105+
131106
- name: add chart
132107
run: |
133108
export VERSION=${{needs.release.outputs.version}}
@@ -139,39 +114,3 @@ jobs:
139114
git add -f ${MSG##*/} index.yaml
140115
git commit -m "release ${VERSION}"
141116
git push
142-
gh-release:
143-
runs-on: ubuntu-latest
144-
needs: release
145-
steps:
146-
- uses: actions/checkout@v2
147-
with:
148-
fetch-depth: 0
149-
- run: |
150-
git config user.name github-actions
151-
git config user.email [email protected]
152-
- id: generate
153-
shell: /usr/bin/bash -x -e {0}
154-
run: |
155-
VERSION=${{needs.release.outputs.version}}
156-
CHANGELOG=$(git --no-pager log --oneline --pretty=format:"- %s" `git tag --sort=-creatordate | grep '^v.*' | head -n2 | tail -n1`.. | uniq | grep -v '^- Merge\|^- skip')
157-
CHANGELOG="${CHANGELOG//'%'/'%25'}"
158-
CHANGELOG="${CHANGELOG//$'\n'/'%0A'}"
159-
CHANGELOG="${CHANGELOG//$'\r'/'%0D'}"
160-
echo ${CHANGELOG}
161-
echo "::set-output name=changelog::${CHANGELOG}"
162-
- name: Download release JAR
163-
uses: actions/download-artifact@v2
164-
with:
165-
name: kafka-ui-${{needs.release.outputs.version}}
166-
path: .
167-
- id: create_release
168-
uses: softprops/action-gh-release@v1
169-
env:
170-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
171-
with:
172-
name: ${{needs.release.outputs.version}}
173-
draft: false
174-
tag_name: "v${{needs.release.outputs.version}}"
175-
prerelease: false
176-
files: kafka-ui-api-${{needs.release.outputs.version}}.jar
177-
body: ${{steps.generate.outputs.changelog}}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
name: Release Drafter
2+
3+
on:
4+
push:
5+
# branches to consider in the event; optional, defaults to all
6+
branches:
7+
- master
8+
9+
jobs:
10+
update_release_draft:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: release-drafter/release-drafter@v5
14+
with:
15+
config-name: release_drafter.yaml
16+
disable-autolabeler: true
17+
env:
18+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

kafka-ui-api/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<parent>
55
<artifactId>kafka-ui</artifactId>
66
<groupId>com.provectus</groupId>
7-
<version>0.3.3-SNAPSHOT</version>
7+
<version>${buildVersion}</version>
88
</parent>
99
<modelVersion>4.0.0</modelVersion>
1010

kafka-ui-contract/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<parent>
55
<artifactId>kafka-ui</artifactId>
66
<groupId>com.provectus</groupId>
7-
<version>0.3.3-SNAPSHOT</version>
7+
<version>${buildVersion}</version>
88
</parent>
99

1010
<modelVersion>4.0.0</modelVersion>

kafka-ui-e2e-checks/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<parent>
66
<artifactId>kafka-ui</artifactId>
77
<groupId>com.provectus</groupId>
8-
<version>0.3.3-SNAPSHOT</version>
8+
<version>${buildVersion}</version>
99
</parent>
1010
<modelVersion>4.0.0</modelVersion>
1111

pom.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
</frontend-generated-sources-directory>
4646
<sonar.organization>provectus</sonar.organization>
4747
<sonar.host.url>https://sonarcloud.io</sonar.host.url>
48+
<buildVersion>0.0.1-SNAPSHOT</buildVersion>
4849
</properties>
4950

5051
<repositories>
@@ -84,7 +85,7 @@
8485

8586
<groupId>com.provectus</groupId>
8687
<artifactId>kafka-ui</artifactId>
87-
<version>0.3.3-SNAPSHOT</version>
88+
<version>${buildVersion}</version>
8889
<name>kafka-ui</name>
8990
<description>Kafka metrics for UI panel</description>
9091
</project>

0 commit comments

Comments
 (0)