Skip to content

1.2 - Adding MiniMessage support #14

1.2 - Adding MiniMessage support

1.2 - Adding MiniMessage support #14

Workflow file for this run

name: Package & Release Plugin
on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
release:
types: [ created ]
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
distribution: temurin
java-version: "17"
- name: Set up Gradle
uses: gradle/actions/setup-gradle@v4
with:
gradle-version: "8.11.1"
- name: Build with Gradle (Kotlin DSL)
run: gradle --no-daemon clean shadowJar sourcesJar javadocJar
- name: Upload plugin artifact
uses: actions/upload-artifact@v4
with:
name: Plugin
path: build/libs/${{ github.event.repository.name }}-*.jar
- name: Get Plugin Version
id: version
run: |
JAR_PATH=$(ls build/libs/${{ github.event.repository.name }}-*.jar | grep -vE '(-sources|-javadoc).jar' | head -n 1)
VERSION=$(basename "$JAR_PATH" .jar | sed "s/${{ github.event.repository.name }}-//")
echo "VERSION=$VERSION" >> $GITHUB_ENV
- name: Delete existing GitHub release (if exists)
run: |
RELEASE_ID=$(gh release view ${{ env.VERSION }} --json id -q '.id' || echo "")
if [ -n "$RELEASE_ID" ]; then
echo "Deleting existing release..."
gh release delete ${{ env.VERSION }} --yes
fi
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Delete existing tag (if exists)
run: |
if git rev-parse "${{ env.VERSION }}" >/dev/null 2>&1; then
echo "Deleting existing tag..."
git tag -d ${{ env.VERSION }}
git push origin :refs/tags/${{ env.VERSION }}
fi
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Rename & Upload Latest Release
run: |
JAR_FILE=$(ls build/libs/${{ github.event.repository.name }}-*.jar | grep -vE '(-sources|-javadoc).jar' | head -n 1)
cp "$JAR_FILE" build/libs/${{ github.event.repository.name }}-latest.jar
- name: Create GitHub Release
uses: softprops/action-gh-release@v1
with:
tag_name: ${{ env.VERSION }}
name: Release ${{ env.VERSION }}
draft: false
prerelease: false
files: |
build/libs/${{ github.event.repository.name }}-latest.jar
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Checkout Maven repository
uses: actions/checkout@v4
with:
repository: CroaBeast/repo
path: maven-repo
token: ${{ secrets.MAVEN_DEPLOY_TOKEN }}
- name: Configure Git
run: |
git config --global user.email "github-actions[bot]@users.noreply.github.com"
git config --global user.name "github-actions[bot]"
- name: Deploy to Maven repository
run: |
mkdir -p maven-repo/me/croabeast/${{ github.event.repository.name }}/${{ env.VERSION }}
cp build/libs/${{ github.event.repository.name }}-${{ env.VERSION }}.jar maven-repo/me/croabeast/${{ github.event.repository.name }}/${{ env.VERSION }}/
cp build/libs/${{ github.event.repository.name }}-${{ env.VERSION }}-javadoc.jar maven-repo/me/croabeast/${{ github.event.repository.name }}/${{ env.VERSION }}/
cp build/libs/${{ github.event.repository.name }}-${{ env.VERSION }}-sources.jar maven-repo/me/croabeast/${{ github.event.repository.name }}/${{ env.VERSION }}/
cat > maven-repo/me/croabeast/${{ github.event.repository.name }}/${{ env.VERSION }}/${{ github.event.repository.name }}-${{ env.VERSION }}.pom << EOF
<?xml version="1.0" encoding="UTF-8"?>
<project>
<modelVersion>4.0.0</modelVersion>
<groupId>me.croabeast</groupId>
<artifactId>${{ github.event.repository.name }}</artifactId>
<version>${{ env.VERSION }}</version>
<packaging>jar</packaging>
</project>
EOF
cat > maven-repo/me/croabeast/${{ github.event.repository.name }}/maven-metadata.xml << EOF
<?xml version="1.0" encoding="UTF-8"?>
<metadata>
<groupId>me.croabeast</groupId>
<artifactId>${{ github.event.repository.name }}</artifactId>
<versioning>
<latest>${{ env.VERSION }}</latest>
<release>${{ env.VERSION }}</release>
<versions>
<version>${{ env.VERSION }}</version>
</versions>
<lastUpdated>$(date +%Y%m%d%H%M%S)</lastUpdated>
</versioning>
</metadata>
EOF
cd maven-repo
git add .
git commit -m "Deploy ${{ github.event.repository.name }} ${{ env.VERSION }}"
git push
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}