Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 9 additions & 10 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
name: Build and Release

on:
workflow_dispatch:
push:
Expand All @@ -10,10 +9,8 @@ on:
pull_request:
branches:
- 'main'

permissions:
contents: write

jobs:
build-maven:
runs-on: ubuntu-latest
Expand All @@ -22,38 +19,35 @@ jobs:
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Setup Java
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '21'

server-id: powernukkitx-releases
server-username: PNX_REPO_USERNAME
server-password: PNX_REPO_PASSWORD
- name: Build with Maven
run: mvn -B package -DskipTests=false -Darguments="-Dmaven.javadoc.skip=true"

- name: Verify artifact
run: |
if [ ! -f target/PlaceholderAPI.jar ]; then
echo "target/PlaceholderAPI.jar was not created"
exit 1
fi

- name: Read project version
if: github.event_name == 'push'
id: project
run: |
VERSION=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
echo "tag=v$VERSION" >> "$GITHUB_OUTPUT"

- name: Upload artifacts
uses: actions/upload-artifact@v4
if: success()
with:
name: PlaceholderAPI
path: target/PlaceholderAPI.jar

- name: Create GitHub release
if: github.event_name == 'push'
env:
Expand All @@ -64,9 +58,14 @@ jobs:
else
RELEASE_TAG="${{ steps.project.outputs.tag }}"
fi

if gh release view "$RELEASE_TAG" >/dev/null 2>&1; then
gh release upload "$RELEASE_TAG" target/PlaceholderAPI.jar --clobber
else
gh release create "$RELEASE_TAG" target/PlaceholderAPI.jar --target "${{ github.sha }}" --title "$RELEASE_TAG" --notes "Automated release for $RELEASE_TAG"
fi
- name: Deploy to PowerNukkitX repository
if: github.event_name == 'push'
run: mvn -B deploy -DskipTests -Darguments="-Dmaven.javadoc.skip=true"
env:
PNX_REPO_USERNAME: ${{ secrets.PNX_REPO_USERNAME }}
PNX_REPO_PASSWORD: ${{ secrets.PNX_REPO_PASSWORD }}
8 changes: 8 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,14 @@
<maven.compiler.proc>none</maven.compiler.proc>
</properties>

<distributionManagement>
<repository>
<id>powernukkitx-releases</id>
<name>PowerNukkitX Releases</name>
<url>https://repo.powernukkitx.org/releases</url>
</repository>
</distributionManagement>

<build>
<finalName>PlaceholderAPI</finalName>
<resources>
Expand Down
Loading