Build and Release Minecraft Plugin - Maven #9
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build and Release Minecraft Plugin - Maven | |
on: | |
push: | |
tags: | |
- "v*" # Trigger the workflow on new version tags | |
workflow_dispatch: # Allows manual triggering | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 # Updated to v4 | |
- name: Set up Java | |
uses: actions/setup-java@v4 # Updated to v4 | |
with: | |
distribution: 'temurin' # Use Temurin JDK (formerly AdoptOpenJDK) | |
java-version: '17' # Set your desired Java version here | |
- name: Build with Maven | |
run: mvn clean package | |
- name: Archive built jar | |
uses: actions/upload-artifact@v4 # Updated to v4 | |
with: | |
name: minecraft-plugin | |
path: target/*.jar | |
release: | |
needs: build | |
runs-on: ubuntu-latest | |
if: github.ref_type == 'tag' # Only run on tags (i.e., version releases) | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 # Updated to v4 | |
- name: Set up Java | |
uses: actions/setup-java@v4 # Updated to v4 | |
with: | |
distribution: 'temurin' | |
java-version: '17' | |
- name: Build with Maven | |
run: mvn clean package | |
- name: Create GitHub Release | |
id: create_release | |
uses: actions/create-release@v1 | |
with: | |
tag_name: ${{ github.ref }} | |
release_name: Release ${{ github.ref }} | |
draft: false | |
prerelease: false | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Upload plugin jar to release | |
uses: actions/upload-release-asset@v2 # Updated to v2 | |
with: | |
upload_url: ${{ steps.create_release.outputs.upload_url }} | |
asset_path: target/*.jar | |
asset_name: minecraft-plugin.jar | |
asset_content_type: application/java-archive |