Skip to content

Commit

Permalink
maybe this time
Browse files Browse the repository at this point in the history
  • Loading branch information
Bunnky committed Oct 4, 2024
1 parent 6927060 commit fa8b0b0
Showing 1 changed file with 48 additions and 8 deletions.
56 changes: 48 additions & 8 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,21 +1,61 @@
name: Build
name: Build and Release

on:
workflow_dispatch:

jobs:
build:
name: Build
runs-on: ubuntu-latest

steps:
- uses: actions/[email protected]
# Step 1: Checkout the repository
- name: Checkout repository
uses: actions/checkout@v2

- name: Set up JDK 16
uses: actions/[email protected]
# Step 2: Set up JDK
- name: Set up JDK
uses: actions/setup-java@v2
with:
java-version: 16
distribution: adopt
java-version: '17' # Specify the required Java version

# Step 3: Get the current version from pom.xml
- name: Get current version
id: get_version
run: |
VERSION=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)
echo "Current version: $VERSION"
# Extract the numeric part and increment it
BASE_VERSION=${VERSION#Reborn }
IFS='.' read -r -a version_parts <<< "$BASE_VERSION"
# Increment the last part
LAST_INDEX=${#version_parts[@]}-1
version_parts[$LAST_INDEX]=$((version_parts[$LAST_INDEX]+1))
NEW_VERSION="Reborn ${version_parts[*]}"
echo "NEW_VERSION=$NEW_VERSION" >> $GITHUB_ENV
# Step 4: Update the version in pom.xml
- name: Update version in pom.xml
run: |
mvn versions:set -DnewVersion=${{ env.NEW_VERSION }}
mvn versions:commit
# Step 5: Build the project
- name: Build with Maven
run: mvn package
run: mvn clean package --file pom.xml

# Step 6: Rename the JAR file
- name: Rename JAR file
run: |
mv target/*.jar "target/SensibleToolbox v${{ env.NEW_VERSION }}.jar"
# Step 7: Create a release with the JAR
- name: Create Release
uses: softprops/action-gh-release@v1
with:
tag_name: v${{ env.NEW_VERSION }} # Using the incremented version for the tag
files: target/"SensibleToolbox v${{ env.NEW_VERSION }}.jar" # Use the renamed file
name: SensibleToolbox v${{ env.NEW_VERSION }} # Naming the release
body: |
Release of version v${{ env.NEW_VERSION }}.
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 comments on commit fa8b0b0

Please sign in to comment.