This file contains hidden or 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
| on: | |
| workflow_dispatch: | |
| push: | |
| branches: [ main ] | |
| paths: [ src/**, build.gradle.kts, settings.gradle.kts ] | |
| permissions: | |
| contents: write | |
| actions: read | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.ref }} | |
| cancel-in-progress: true | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/setup-java@v4 | |
| with: | |
| distribution: temurin | |
| java-version: 21 | |
| - uses: gradle/actions/setup-gradle@v4 | |
| - run: | | |
| gradle wrapper | |
| chmod +x ./gradlew | |
| ./gradlew shadowJar | |
| - id: vars | |
| run: | | |
| echo "COMMIT_HASH=$(git rev-parse --short HEAD)" >> "$GITHUB_OUTPUT" | |
| ./gradlew -q printVars | sed 's/ = /=/g' >> "$GITHUB_OUTPUT" | |
| - id: ghck | |
| run: | | |
| CODE=$(curl -s -o /dev/null -w "%{http_code}" \ | |
| -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \ | |
| -H "X-GitHub-Api-Version: 2022-11-28" \ | |
| "https://api.github.com/repos/${{ github.repository }}/releases/tags/v${{ steps.vars.outputs.VERS }}") | |
| if [ "$CODE" = "200" ]; then | |
| echo "EXISTS=true" >> "$GITHUB_OUTPUT" | |
| else | |
| echo "EXISTS=false" >> "$GITHUB_OUTPUT" | |
| fi | |
| - id: mrck | |
| run: | | |
| echo "TOKEN=$([ -n "${{ secrets.MODRINTH_TOKEN }}" ] && echo true || echo false)" >> "$GITHUB_OUTPUT" | |
| - id: dist | |
| run: | | |
| echo "TAG_NAME=${{ format('v{0}{1}', steps.vars.outputs.VERS, steps.ghck.outputs.EXISTS == 'true' && format('+{0}', steps.vars.outputs.COMMIT_HASH) || '') }}" >> "$GITHUB_OUTPUT" | |
| echo "REL_NAME=${{ format('{0}{1}', steps.ghck.outputs.EXISTS == 'true' && 'Snapshot ' || 'v', steps.ghck.outputs.EXISTS == 'true' && steps.vars.outputs.COMMIT_HASH || steps.vars.outputs.VERS) }}" >> "$GITHUB_OUTPUT" | |
| echo "ART_NAME=${{ format('{0}{1}.jar', steps.vars.outputs.AFCT, steps.ghck.outputs.EXISTS == 'true' && format('+{0}', steps.vars.outputs.COMMIT_HASH) || '') }}" >> "$GITHUB_OUTPUT" | |
| - run: | | |
| mkdir -p dist | |
| cp "./build/libs/${{ steps.vars.outputs.AFCT }}.jar" ./dist/${{ steps.dist.outputs.ART_NAME }} | |
| - uses: actions/upload-artifact@v4 | |
| with: | |
| path: dist/${{ steps.dist.outputs.ART_NAME }} | |
| name: ${{ steps.dist.outputs.ART_NAME }} | |
| - if: github.event_name == 'push' && github.ref == 'refs/heads/main' | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| tag_name: ${{ steps.dist.outputs.TAG_NAME }} | |
| name: ${{ steps.dist.outputs.REL_NAME }} | |
| files: dist/${{ steps.dist.outputs.ART_NAME }} | |
| prerelease: ${{ steps.ghck.outputs.EXISTS == 'true' }} | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| - if: github.event_name == 'push' && github.ref == 'refs/heads/main' && steps.mrck.outputs.TOKEN == 'true' | |
| uses: cloudnode-pro/modrinth-publish@v2 | |
| with: | |
| token: ${{ secrets.MODRINTH_TOKEN }} | |
| project: WfBtRGYI | |
| version: ${{ steps.dist.outputs.TAG_NAME }} | |
| loaders: '["bukkit", "bungeecord", "paper", "purpur", "spigot", "velocity", "waterfall"]' | |
| game-versions: '["1.8.x", "1.9.x", "1.10.x", "1.11.x", "1.12.x", "1.13.x", "1.14.x", "1.15.x", "1.16.x", "1.17.x", "1.18.x", "1.19.x", "1.20.x", "1.21.x"]' | |
| files: dist/${{ steps.dist.outputs.ART_NAME }} | |
| primary-file: ${{ steps.dist.outputs.ART_NAME }} | |
| name: ${{ steps.dist.outputs.REL_NAME }} | |
| channel: ${{ steps.ghck.outputs.EXISTS == 'true' && 'beta' || 'release' }} | |
| dependencies: |- | |
| [{ | |
| "project_id": "Gtsn3SWv", | |
| "dependency_type": "required" | |
| }] |