Skip to content

Birthday [v1.0.2.2] DEV_BUILD #28

Birthday [v1.0.2.2] DEV_BUILD

Birthday [v1.0.2.2] DEV_BUILD #28

name: Build and Release Plugin
on:
push:
branches:
- dev # Trigger only for the 'dev' branch
jobs:
build:
runs-on: ubuntu-latest
steps:
# Step 1: Clone the repository
- name: Checkout Repository
uses: actions/checkout@v3
# Step 2: Set up the Java Development Kit (JDK)
- name: Set Up JDK
uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: '17' # Matches Gradle configuration
# Step 3: Build the plugin using Gradle
- name: Build with Gradle
run: ./gradlew shadowJar
# Step 4: Extract commit message and parse tag
- name: Parse Commit Message for Tag
id: parse_commit_message
run: |
COMMIT_MSG=$(git log -1 --pretty=format:"%s")
echo "commit_message=$COMMIT_MSG" >> $GITHUB_ENV
if [[ "$COMMIT_MSG" =~ \[(.+)\] ]]; then
TAG_NAME="${BASH_REMATCH[1]}"
else
TAG_NAME="default-tag"
fi
echo "tag_name=$TAG_NAME" >> $GITHUB_ENV
# Step 5: Rename the JAR file to match the commit message
- name: Rename JAR File
id: rename_jar
run: |
FILE=$(find build/libs -name '*.jar' | head -n 1)
if [ -z "$FILE" ]; then
echo "[ERROR] JAR file not found in build/libs!"
exit 1
fi
NEW_NAME="${{ env.commit_message }}.jar"
mv "$FILE" "build/libs/$NEW_NAME"
echo "path=build/libs/$NEW_NAME" >> $GITHUB_ENV
# Step 6: Create a GitHub release
- name: Create GitHub Release
id: create_release
uses: actions/create-release@v1
with:
tag_name: ${{ env.tag_name }}
release_name: ${{ env.commit_message }}
body: |
This is an experimental release of the development branch. It is intended for testing purposes and may include incomplete features or bugs. Please use it with caution and provide feedback if you encounter any issues.
draft: false
prerelease: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# Step 7: Upload the JAR file to the release
- name: Upload Plugin JAR
uses: actions/upload-release-asset@v1
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ${{ env.path }}
asset_name: ${{ env.commit_message }}.jar
asset_content_type: application/java-archive
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}