Skip to content

Build MyPet

Build MyPet #179

Workflow file for this run

name: Build MyPet
on:
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
env:
BUILD_NUMBER: 0
JAR_FILE_NAME: ""
NMS_VERSIONS: ""
PROJECT_VERSION: ""
steps:
- uses: actions/checkout@v3
- name: Set up JDK 21
uses: actions/setup-java@v3
with:
java-version: 21
distribution: 'microsoft'
- name: Cache local Maven repository
uses: actions/cache@v3
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}-${{ hashFiles('**/install_dependencies.sh') }}
restore-keys: |
${{ runner.os }}-maven-
- name: Set build number
env:
NUM: ${{ github.run_number }}
run: |
echo "BUILD_NUMBER=$(($NUM+1592))" >> $GITHUB_ENV
- name: Build and Deploy to GitHub Packages
run: mvn --batch-mode deploy -DGIT_COMMIT=${{ github.sha }} -DBUILD_NUMBER=${{ env.BUILD_NUMBER }}
env:
GITHUB_TOKEN: ${{ secrets.TOKEN_GITHUB }}
- name: Get jar file name
run: |
echo "JAR_FILE_NAME=$(find ./target -maxdepth 1 -regex '.*/MyPet-3\.[0-9]+-?S?N?A?P?S?H?O?T?\.jar' | sed -e 's/"//g')" >> $GITHUB_ENV
- name: Get supported NMS versions
run: |
cd modules/MyPet
echo NMS_VERSIONS=$(mvn help:evaluate -Dexpression=bukkit.packets -q -DforceStdout)
echo NMS_VERSIONS=$(mvn help:evaluate -Dexpression=bukkit.packets -q -DforceStdout) >> $GITHUB_ENV
- name: Get project version
run: |
cd modules/MyPet
echo PROJECT_VERSION=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)
echo PROJECT_VERSION=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout) >> $GITHUB_ENV
- name: Upload artifacts
uses: actions/upload-artifact@v3
with:
name: latest-plugin-jar
path: ${{ env.JAR_FILE_NAME }}
- name: Create release
uses: actions/create-release@v1
id: create_release
with:
draft: false
prerelease: ${{ contains( env.PROJECT_VERSION, 'SNAPSHOT' ) }}
release_name: ${{ env.PROJECT_VERSION }}-B${{ env.BUILD_NUMBER }}
tag_name: ${{ env.PROJECT_VERSION }}-B${{ env.BUILD_NUMBER }}
body: |
Supported NMS Versions: ${{ env.NMS_VERSIONS }}
Download: [MyPet-${{ env.PROJECT_VERSION }}-B${{ env.BUILD_NUMBER }}.jar](https://github.com/MyPetORG/MyPet/releases/download/${{ env.PROJECT_VERSION }}-B${{ env.BUILD_NUMBER }}/MyPet-${{ env.PROJECT_VERSION }}-B${{ env.BUILD_NUMBER }}.jar)
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Upload JAR
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ${{ env.JAR_FILE_NAME }}
asset_name: MyPet-${{ env.PROJECT_VERSION }}-B${{ env.BUILD_NUMBER }}.jar
asset_content_type: application/java-archive
- name: Delete old pre-releases
uses: dev-drprasad/delete-older-releases@v0.2.0
with:
keep_latest: 3
delete_tag_pattern: SNAPSHOT
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}