generated from hivemq/hivemq-hello-world-extension
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #19 from hivemq/feature/metric-2-topic
#18 Feature/metric 2 topic
- Loading branch information
Showing
15 changed files
with
408 additions
and
59 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
# This workflow uses actions that are not certified by GitHub. | ||
# They are provided by a third-party and are governed by | ||
# separate terms of service, privacy policy, and support | ||
# documentation. | ||
# This workflow will build a Java project with Gradle and cache/restore any dependencies to improve the workflow execution time | ||
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-java-with-gradle | ||
|
||
name: Extension Build and Test | ||
on: | ||
push: | ||
branches: | ||
- feature/** | ||
tags: | ||
- '*' | ||
pull_request: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
build: | ||
|
||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- name: Cache gradle | ||
uses: actions/cache@v3.3.3 | ||
with: | ||
path: | | ||
~/.gradle | ||
key: gradle-${{ hashFiles('**/build.gradle.kts') }} | ||
|
||
- name: Set up JDK 11 | ||
uses: actions/setup-java@v4.0.0 | ||
with: | ||
java-version: '11' | ||
distribution: 'temurin' | ||
check-latest: true | ||
cache: gradle | ||
|
||
- name: Build with Gradle | ||
run: | | ||
./gradlew check test build |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,153 @@ | ||
name: Create Release | ||
on: | ||
workflow_dispatch: | ||
branches: | ||
- main | ||
- feature/** | ||
inputs: | ||
version: | ||
description: 'Version to release (e.g. 0.0.0)' | ||
required: true | ||
default: '4.28.0' | ||
nextVersion: | ||
description: 'Next version for development (e.g. 0.0.0; do not include -SNAPSHOT)' | ||
required: true | ||
default: '4.29.0' | ||
preRelease: | ||
description: 'Is this a pre-release?' | ||
required: true | ||
default: false | ||
# updateWorkflow: | ||
# description: 'Update workflow default versions? NOTE: A personal access token must be available as secret WORKFLOW_TOKEN for this to work!' | ||
# required: false | ||
# default: false | ||
|
||
permissions: | ||
contents: write | ||
actions: write | ||
|
||
jobs: | ||
release: | ||
name: Release | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
|
||
- name: Validate versions | ||
run: | | ||
VERSION_REGEX="^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(-(0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(\.(0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*)?(\+[0-9a-zA-Z-]+(\.[0-9a-zA-Z-]+)*)?$" | ||
echo "Checking if version and nextVersion comply with semantic versioning..." | ||
if [[ ! "${{ github.event.inputs.version }}" =~ $VERSION_REGEX ]] || [[ ! "${{ github.event.inputs.nextVersion }}" =~ $VERSION_REGEX ]]; then | ||
echo "Error: version does not comply with semantic versioning! Use MAJOR.MINOR.PATCH pattern." | ||
exit 1 | ||
fi | ||
echo "Checking if version and nextVersion are identical..." | ||
if [[ ( "${{ github.event.inputs.version }}" == "${{ github.event.inputs.nextVersion }}" ) ]]; then | ||
echo "Error: version and nextVersion may not be identical." | ||
exit 1 | ||
fi | ||
echo "Checking if nextVersion is higher than version..." | ||
IFS='.' read -ra VERSION_ARR <<< "${{ github.event.inputs.version }}" | ||
IFS='.' read -ra NEXT_VERSION_ARR <<< "${{ github.event.inputs.nextVersion }}" | ||
for i in "${!VERSION_ARR[@]}"; do | ||
if (( NEXT_VERSION_ARR[i] < VERSION_ARR[i] )); then | ||
echo "Error: next version needs to be higher than release version" | ||
exit 1 | ||
elif (( NEXT_VERSION_ARR[i] > VERSION_ARR[i] )); then | ||
break | ||
fi | ||
done | ||
echo "Checking if tag v${{ github.event.inputs.version }} already exists..." | ||
if git rev-parse "v${{ github.event.inputs.version }}" >/dev/null 2>&1; then | ||
echo "Tag v${{ github.event.inputs.version }} already exists!" | ||
exit 1 | ||
fi | ||
echo "Creating release with version v${{ github.event.inputs.version }}." | ||
echo "Next version will be v${{ github.event.inputs.nextVersion }}-SNAPSHOT." | ||
echo "VERSION=${{ github.event.inputs.version }}" >> $GITHUB_ENV | ||
echo "NEXT_VERSION=${{ github.event.inputs.nextVersion }}" >> $GITHUB_ENV | ||
echo "BRANCH_NAME=${GITHUB_REF#refs/heads/}" >> $GITHUB_ENV | ||
- name: Check pre-release | ||
run: | | ||
echo "Creating pre-release: ${{ github.event.inputs.preRelease }}" | ||
if [[ ${{ github.event.inputs.preRelease }} == "true" ]]; then | ||
echo "PRE_RELEASE=true" >> $GITHUB_ENV | ||
else | ||
echo "Creating final release from ${{ env.BRANCH_NAME }}." | ||
if [[ "${{ env.BRANCH_NAME }}" != "main" ]]; then | ||
echo "Error: final releases can only be created from main branch." | ||
exit 1 | ||
fi | ||
echo "PRE_RELEASE=false" >> $GITHUB_ENV | ||
fi | ||
- name: Set up JDK 11 | ||
uses: actions/setup-java@v4.0.0 | ||
with: | ||
java-version: '11' | ||
distribution: 'temurin' | ||
check-latest: true | ||
cache: gradle | ||
|
||
- name: Setup Gradle | ||
uses: gradle/gradle-build-action@v3.0.0 | ||
|
||
- name: Setup git config | ||
run: | | ||
git config --global user.name "GitHub Action" | ||
git config --global user.email "<>" | ||
- name: Release with Gradle | ||
run: ./gradlew release -Prelease.useAutomaticVersion=true -Prelease.releaseVersion=${{ env.VERSION }} -Prelease.newVersion=${{ env.NEXT_VERSION }}-SNAPSHOT | ||
|
||
- name: Generate changelog | ||
id: changelog | ||
run: | | ||
CHANGELOG=$(git log $(git describe --tags --abbrev=0)..HEAD --pretty=format:"- %s") | ||
echo "::set-output name=changelog::$CHANGELOG" | ||
- name: Create GitHub Release | ||
uses: softprops/action-gh-release@v1 | ||
with: | ||
name: Release v${{ env.VERSION }} | ||
tag_name: ${{ env.VERSION }} | ||
prerelease: ${{ env.PRE_RELEASE }} | ||
body: ${{ steps.changelog.outputs.changelog }} | ||
files: | | ||
./build/hivemq-extension/hivemq-sparkplug-aware-extension-*.zip | ||
./build/hivemq-extension/hivemq-sparkplug-aware-extension-*.zip.sha256 | ||
# - name: Update workflow | ||
# run: | | ||
# | ||
# if [[ ${{ github.event.inputs.updateWorkflow }} == "false" ]]; then | ||
# echo "Skipping workflow update." | ||
# exit 0 | ||
# fi | ||
# | ||
# IFS='.' read -ra NEXT_VERSION_ARR <<< "${{ env.NEXT_VERSION }}" | ||
# NEXT_VERSION_MINOR=$((NEXT_VERSION_ARR[1] + 1)) | ||
# NEW_NEXT_VERSION="${NEXT_VERSION_ARR[0]}.${NEXT_VERSION_MINOR}.0" | ||
# | ||
# echo $NEW_NEXT_VERSION | ||
# | ||
# set -x | ||
# VERSION=${{ env.NEXT_VERSION }} yq eval '.on.workflow_dispatch.inputs.version.default = env(VERSION)' -i .github/workflows/gradle-release.yml | ||
# NEXT_VERSION=$NEW_NEXT_VERSION yq eval '.on.workflow_dispatch.inputs.nextVersion.default = env(NEXT_VERSION)' -i .github/workflows/gradle-release.yml | ||
# set +x | ||
# | ||
# cat .github/workflows/gradle-release.yml | ||
# | ||
# git config --global user.name "GitHub Action" | ||
# git config --global user.email "<>" | ||
# git add .github/workflows/gradle-release.yml | ||
# git commit -m "Update workflow default versions" | ||
# git push |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,3 +12,6 @@ out/ | |
|
||
.java-version | ||
.DS_Store | ||
|
||
# HiveMQ | ||
hivemq-4.*.0 |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
version=4.24.0 | ||
version=4.28.0 |
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
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
Oops, something went wrong.