Build and Release #14
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
name: Build and Release | |
on: | |
workflow_dispatch: | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v2 | |
- name: Set up JDK | |
uses: actions/setup-java@v2 | |
with: | |
java-version: 16 | |
distribution: adopt | |
- name: Get current version | |
id: get_version | |
run: | | |
VERSION=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout) | |
echo "Current version: $VERSION" | |
BASE_VERSION=${VERSION#Reborn-} | |
IFS='.' read -r -a version_parts <<< "$BASE_VERSION" | |
LAST_INDEX=${#version_parts[@]}-1 | |
version_parts[$LAST_INDEX]=$((version_parts[$LAST_INDEX]+1)) | |
NEW_VERSION="Reborn-${version_parts[0]}.${version_parts[1]}.${version_parts[$LAST_INDEX]}" | |
echo "NEW_VERSION=$NEW_VERSION" >> $GITHUB_ENV | |
- name: Update version in pom.xml | |
run: | | |
mvn versions:set -DnewVersion="${{ env.NEW_VERSION }}" | |
mvn versions:commit | |
- name: Build with Maven | |
run: mvn clean package --file pom.xml | |
- name: Rename JAR file | |
run: | | |
JAR_FILE=$(ls target/*.jar | head -n 1) | |
echo "Found JAR file: $JAR_FILE" | |
mv "$JAR_FILE" "SensibleToolbox v${{ env.NEW_VERSION }}.jar" | |
- name: Create Release | |
uses: softprops/action-gh-release@v1 | |
with: | |
tag_name: "v${{ env.NEW_VERSION }}" | |
files: "SensibleToolbox v${{ env.NEW_VERSION }}.jar" | |
name: "SensibleToolbox v${{ env.NEW_VERSION }}" | |
body: | | |
Release of version v${{ env.NEW_VERSION }}. | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |