Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change the way of release workflow #1434

Merged
merged 7 commits into from
Jan 21, 2022
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions .github/release_drafter.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name-template: 'v$RESOLVED_VERSION'
tag-template: '$RESOLVED_VERSION'
template: |
## Changes
$CHANGES
## Contributors
$CONTRIBUTORS

exclude-labels:
- 'skip-changelog'

categories:
- title: '⚙️Features'
labels:
- 'type/feature'
- title: '🪛Enhancements'
labels:
- 'type/enhancement'
- title: '🔨Bug Fixes'
labels:
- 'type/bug'

change-template: '- $TITLE @$AUTHOR (#$NUMBER)'

version-resolver:
major:
labels:
- 'major'
minor:
labels:
- 'minor'
patch:
labels:
- 'patch'
default: patch
4 changes: 2 additions & 2 deletions .github/workflows/branch-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ jobs:
- name: Build
id: build
run: |
export VERSION=$(mvn -q -Dexec.executable=echo -Dexec.args='${project.version}' --non-recursive exec:exec)
mvn clean package -Pprod -DskipTests -DbuildVersion=$GITHUB_SHA
export VERSION=$(mvn -q -Dexec.executable=echo -Dexec.args='${project.version}' -DbuildVersion=$GITHUB_SHA --non-recursive exec:exec)
echo "::set-output name=version::${VERSION}"
mvn clean package -Pprod -DskipTests
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
- name: Set up Docker Buildx
Expand Down
13 changes: 10 additions & 3 deletions .github/workflows/master.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: latest
name: Master
on:
workflow_dispatch:
push:
Expand All @@ -9,44 +9,51 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

- name: Cache local Maven repository
uses: actions/cache@v2
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-

- name: Set up JDK 1.13
uses: actions/setup-java@v1
with:
java-version: 1.13

- name: Build
id: build
run: |
export VERSION=$(mvn -q -Dexec.executable=echo -Dexec.args='${project.version}' --non-recursive exec:exec)
mvn clean package -Pprod -DskipTests -DbuildVersion=$GITHUB_SHA
export VERSION=$(mvn -q -Dexec.executable=echo -Dexec.args='${project.version}' -DbuildVersion=$GITHUB_SHA --non-recursive exec:exec)
echo "::set-output name=version::${VERSION}"
mvn clean package -Pprod -DskipTests
#################
# #
# Docker images #
# #
#################
- name: Set up QEMU
uses: docker/setup-qemu-action@v1

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1

- name: Cache Docker layers
uses: actions/cache@v2
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-

- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Build and push
id: docker_build_and_push
uses: docker/build-push-action@v2
Expand Down
101 changes: 20 additions & 81 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -1,19 +1,7 @@
name: release
on:
workflow_dispatch:
inputs:
customVersion:
description: 'A new version for release, please provide with -SNAPSHOT suffix'
required: false
default: '0.0.0'
rebuild:
description: 'A tag name for building previously created release'
required: false
default: 'v0.0.0'
extraMavenOptions:
description: 'A extra options for Maven'
required: false
default: ''
name: Release
on:
release:
types: [published]

jobs:
release:
Expand All @@ -24,53 +12,31 @@ jobs:
- uses: actions/checkout@v2
with:
fetch-depth: 0

- run: |
git config user.name github-actions
git config user.email github-actions@github.com

- name: Cache local Maven repository
uses: actions/cache@v2
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-

- name: Set up JDK 1.13
uses: actions/setup-java@v1
with:
java-version: 1.13
- name: Checkout to specific tag
if: github.event.inputs.rebuild != 'v0.0.0'
run: |
git checkout tags/${{ github.event.inputs.rebuild }} -b rebuild-${{ github.event.inputs.rebuild }}
- name: Set custom version
if: github.event.inputs.customVersion != '0.0.0' && github.event.inputs.rebuild == 'v0.0.0'
run: |
mvn -q versions:set -DnewVersion=${{ github.event.inputs.customVersion }}
git add pom.xml **/pom.xml
git commit -m "Increased release"
- name: Update development version
if: github.event.inputs.rebuild == 'v0.0.0'
run: |
mvn -q versions:set -DnextSnapshot
git add pom.xml **/pom.xml
git commit -m "Increased version in pom.xml"
git push -f
git reset --hard HEAD~1
- name: Prepare release
if: github.event.inputs.rebuild == 'v0.0.0'
run: |
mvn -q versions:set -DremoveSnapshot
export VERSION=$(mvn -q -Dexec.executable=echo -Dexec.args='${project.version}' --non-recursive exec:exec)
git add .
git commit -m "release ${VERSION}"
git tag -f v${VERSION}
git push --tags

- name: Build with Maven
id: build
run: |
mvn clean package -Pprod ${{ github.event.inputs.extraMavenOptions }}
export VERSION=$(mvn -q -Dexec.executable=echo -Dexec.args='${project.version}' --non-recursive exec:exec)
mvn clean package -Pprod -DskipTests -DbuildVersion=${{ github.event.release.tag_name }}
export VERSION=$(mvn -q -Dexec.executable=echo -Dexec.args='${project.version}' -DbuildVersion=${{ github.event.release.tag_name }} --non-recursive exec:exec)
echo ::set-output name=version::${VERSION}

- name: Archive JAR
uses: actions/upload-artifact@v2
with:
Expand All @@ -83,21 +49,25 @@ jobs:
#################
- name: Set up QEMU
uses: docker/setup-qemu-action@v1

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1

- name: Cache Docker layers
uses: actions/cache@v2
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-

- name: Login to DockerHub
if: github.ref == 'refs/heads/master'
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Build and push
id: docker_build_and_push
uses: docker/build-push-action@v2
Expand All @@ -113,21 +83,26 @@ jobs:
JAR_FILE=kafka-ui-api-${{ steps.build.outputs.version }}.jar
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache

charts:
runs-on: ubuntu-latest
needs: release
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 1

- run: |
git config user.name github-actions
git config user.email github-actions@github.com

- uses: azure/setup-helm@v1

- name: update appVersion
run: |
export version=${{needs.release.outputs.version}}
sed -i "s/appVersion:.*/appVersion: ${version}/" charts/kafka-ui/Chart.yaml

- name: add chart
run: |
export VERSION=${{needs.release.outputs.version}}
Expand All @@ -139,39 +114,3 @@ jobs:
git add -f ${MSG##*/} index.yaml
git commit -m "release ${VERSION}"
git push
gh-release:
runs-on: ubuntu-latest
needs: release
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- run: |
git config user.name github-actions
git config user.email github-actions@github.com
- id: generate
shell: /usr/bin/bash -x -e {0}
run: |
VERSION=${{needs.release.outputs.version}}
CHANGELOG=$(git --no-pager log --oneline --pretty=format:"- %s" `git tag --sort=-creatordate | grep '^v.*' | head -n2 | tail -n1`.. | uniq | grep -v '^- Merge\|^- skip')
CHANGELOG="${CHANGELOG//'%'/'%25'}"
CHANGELOG="${CHANGELOG//$'\n'/'%0A'}"
CHANGELOG="${CHANGELOG//$'\r'/'%0D'}"
echo ${CHANGELOG}
echo "::set-output name=changelog::${CHANGELOG}"
- name: Download release JAR
uses: actions/download-artifact@v2
with:
name: kafka-ui-${{needs.release.outputs.version}}
path: .
- id: create_release
uses: softprops/action-gh-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
name: ${{needs.release.outputs.version}}
draft: false
tag_name: "v${{needs.release.outputs.version}}"
prerelease: false
files: kafka-ui-api-${{needs.release.outputs.version}}.jar
body: ${{steps.generate.outputs.changelog}}
18 changes: 18 additions & 0 deletions .github/workflows/release_drafter.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: Release Drafter

on:
push:
# branches to consider in the event; optional, defaults to all
branches:
- master

jobs:
update_release_draft:
runs-on: ubuntu-latest
steps:
- uses: release-drafter/release-drafter@v5
with:
config-name: release_drafter.yaml
disable-autolabeler: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
2 changes: 1 addition & 1 deletion kafka-ui-api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<artifactId>kafka-ui</artifactId>
<groupId>com.provectus</groupId>
<version>0.3.2-SNAPSHOT</version>
<version>${buildVersion}</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion kafka-ui-contract/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<artifactId>kafka-ui</artifactId>
<groupId>com.provectus</groupId>
<version>0.3.2-SNAPSHOT</version>
<version>${buildVersion}</version>
</parent>

<modelVersion>4.0.0</modelVersion>
Expand Down
2 changes: 1 addition & 1 deletion kafka-ui-e2e-checks/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>kafka-ui</artifactId>
<groupId>com.provectus</groupId>
<version>0.3.2-SNAPSHOT</version>
<version>${buildVersion}</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
3 changes: 2 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
</frontend-generated-sources-directory>
<sonar.organization>provectus</sonar.organization>
<sonar.host.url>https://sonarcloud.io</sonar.host.url>
<buildVersion>0.0.1-SNAPSHOT</buildVersion>
</properties>

<repositories>
Expand Down Expand Up @@ -84,7 +85,7 @@

<groupId>com.provectus</groupId>
<artifactId>kafka-ui</artifactId>
<version>0.3.2-SNAPSHOT</version>
<version>${buildVersion}</version>
<name>kafka-ui</name>
<description>Kafka metrics for UI panel</description>
</project>