Skip to content

Update build.yml

Update build.yml #13

Workflow file for this run

name: Dev Build
on:
push:
branches:
- dev
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: 📦 Checkout Code
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: ☕ Set up Java 21
uses: actions/setup-java@v3
with:
distribution: temurin
java-version: 21
- name: 🏷 Get current base version from pom.xml
id: version
run: |
BASE_VERSION=$(mvn help:evaluate -Dexpression=revision -q -DforceStdout)
echo "BASE_VERSION=${BASE_VERSION%%-DEVBUILD*}" >> $GITHUB_ENV
echo "base_version=${BASE_VERSION%%-DEVBUILD*}" >> $GITHUB_OUTPUT
- name: 🔢 Get dev build number from commit count
id: get-devbuild
run: |
LAST_TAG=$(git describe --tags --match "${{ env.BASE_VERSION }}*" --abbrev=0 2>/dev/null || echo "")
if [ -n "$LAST_TAG" ]; then
BUILD_NUM=$(git rev-list --count "$LAST_TAG"..HEAD)
else
BUILD_NUM=$(git rev-list --count HEAD)
fi
echo "DEVBUILD=$BUILD_NUM" >> $GITHUB_ENV
echo "build_num=$BUILD_NUM" >> $GITHUB_OUTPUT
- name: 🛠 Build with Maven
run: |
VERSION="${{ env.BASE_VERSION }}-DEVBUILD.${{ steps.get-devbuild.outputs.build_num }}"
echo "Building version: $VERSION"
mvn clean package -Drevision=$VERSION
- name: 📦 Rename and move JAR to dist/
run: |
mkdir -p dist
JAR=$(find target -name "AutoPickup-*.jar" ! -name "*-original.jar" | head -n1)
if [ -z "$JAR" ]; then
echo "❌ No JAR found in target/"
ls -l target
exit 1
fi
cp "$JAR" "dist/AutoPickup-${{ env.BASE_VERSION }}-DEVBUILD.${{ steps.get-devbuild.outputs.build_num }}.jar"
- name: 📥 Upload Dev Build Artifact
uses: actions/upload-artifact@v4
with:
name: AutoPickup-${{ env.BASE_VERSION }}-DEVBUILD.${{ steps.get-devbuild.outputs.build_num }}
path: dist/*.jar