Update Maven-BuildAndRealese.yml #2
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 | |
push: | |
branches: [$default-branch] | |
workflow_dispatch: # Allows manual triggering | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
- name: Set up Java | |
uses: actions/setup-java@v3 | |
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@v3 | |
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@v3 | |
- name: Set up Java | |
uses: actions/setup-java@v3 | |
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@v1 | |
with: | |
upload_url: ${{ steps.create_release.outputs.upload_url }} | |
asset_path: target/*.jar | |
asset_name: minecraft-plugin.jar | |
asset_content_type: application/java-archive |