fix: workflow #11
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
| name: Release and Publish | |
| on: | |
| push: | |
| branches: | |
| - main | |
| workflow_dispatch: | |
| env: | |
| APP_SLUG: cloud-api-plugin | |
| REGISTRY_URL: https://registry.simplecloud.app | |
| MINECRAFT_VERSIONS: '["1.20","1.20.1","1.20.2","1.20.3","1.20.4","1.20.5","1.20.6","1.21","1.21.1","1.21.2","1.21.3","1.21.4"]' | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| outputs: | |
| gradle_version: ${{ steps.versions.outputs.gradle_version }} | |
| commit_hash: ${{ steps.versions.outputs.commit_hash }} | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v3 | |
| with: | |
| ref: main | |
| - name: Set up JDK 21 | |
| uses: actions/setup-java@v3 | |
| with: | |
| distribution: 'adopt' | |
| java-version: '21' | |
| - name: Cache Gradle packages | |
| uses: actions/cache@v3 | |
| with: | |
| path: | | |
| ~/.gradle/caches | |
| ~/.gradle/wrapper | |
| key: gradle-${{ runner.os }}-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }} | |
| restore-keys: | | |
| gradle-${{ runner.os }} | |
| - name: Make gradlew executable | |
| run: chmod +x ./gradlew | |
| - name: Get Versions | |
| id: versions | |
| run: | | |
| echo "gradle_version=$(./gradlew properties -q | grep "version:" | awk '{print $2}')" >> $GITHUB_OUTPUT | |
| echo "commit_hash=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT | |
| - name: Build ShadowJars | |
| run: | | |
| ./gradlew clean build shadowJar | |
| mkdir -p artifacts | |
| cp platform/spigot/build/libs/spigot.jar artifacts/ | |
| cp platform/bungeecord/build/libs/bungeecord.jar artifacts/ | |
| cp platform/velocity/build/libs/velocity.jar artifacts/ | |
| - name: Upload artifacts | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: build-artifacts | |
| path: artifacts/*.jar | |
| compression-level: 0 | |
| publish-registry: | |
| needs: build | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Download artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: build-artifacts | |
| path: artifacts | |
| - name: Create Registry Release | |
| id: create_registry_release | |
| run: | | |
| response=$(curl -X POST \ | |
| -H "Authorization: Bearer ${{ secrets.REGISTRY_TOKEN }}" \ | |
| -H "Content-Type: application/json" \ | |
| "${REGISTRY_URL}/v1/applications/${APP_SLUG}/releases" \ | |
| -d '{ | |
| "version": "'"${{ needs.build.outputs.gradle_version }}"'", | |
| "manual_update": false | |
| }') | |
| echo "Response: $response" | |
| APP_ID=$(echo $response | jq -r '.release.application_id') | |
| echo "APP_ID=$APP_ID" >> $GITHUB_ENV | |
| - name: List artifacts directory | |
| run: ls -R artifacts | |
| - name: Upload to Registry | |
| run: | | |
| # Upload Spigot Platform | |
| curl -X POST \ | |
| -H "Authorization: Bearer ${{ secrets.REGISTRY_TOKEN }}" \ | |
| -H "Content-Type: multipart/form-data" \ | |
| -F "file=@artifacts/spigot.jar" \ | |
| -F "platform=minecraft_plugin" \ | |
| -F "arch=spigot" \ | |
| -F "platform_versions=${{ env.MINECRAFT_VERSIONS }}" \ | |
| "${REGISTRY_URL}/v1/applications/${APP_ID}/releases/${{ needs.build.outputs.gradle_version }}/files" | |
| # Upload Paper Platform (same jar as Spigot) | |
| curl -X POST \ | |
| -H "Authorization: Bearer ${{ secrets.REGISTRY_TOKEN }}" \ | |
| -H "Content-Type: multipart/form-data" \ | |
| -F "file=@artifacts/spigot.jar" \ | |
| -F "platform=minecraft_plugin" \ | |
| -F "arch=paper" \ | |
| -F "platform_versions=${{ env.MINECRAFT_VERSIONS }}" \ | |
| "${REGISTRY_URL}/v1/applications/${APP_ID}/releases/${{ needs.build.outputs.gradle_version }}/files" | |
| # Upload BungeeCord Platform | |
| curl -X POST \ | |
| -H "Authorization: Bearer ${{ secrets.REGISTRY_TOKEN }}" \ | |
| -H "Content-Type: multipart/form-data" \ | |
| -F "file=@artifacts/bungeecord.jar" \ | |
| -F "platform=minecraft_plugin" \ | |
| -F "arch=bungeecord" \ | |
| -F "platform_versions=${{ env.MINECRAFT_VERSIONS }}" \ | |
| "${REGISTRY_URL}/v1/applications/${APP_ID}/releases/${{ needs.build.outputs.gradle_version }}/files" | |
| # Upload Velocity Platform | |
| curl -X POST \ | |
| -H "Authorization: Bearer ${{ secrets.REGISTRY_TOKEN }}" \ | |
| -H "Content-Type: multipart/form-data" \ | |
| -F "file=@artifacts/velocity.jar" \ | |
| -F "platform=minecraft_plugin" \ | |
| -F "arch=velocity" \ | |
| -F "platform_versions=${{ env.MINECRAFT_VERSIONS }}" \ | |
| "${REGISTRY_URL}/v1/applications/${APP_ID}/releases/${{ needs.build.outputs.gradle_version }}/files" | |
| publish-maven: | |
| needs: build | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v3 | |
| with: | |
| ref: main | |
| - name: Set up JDK 21 | |
| uses: actions/setup-java@v3 | |
| with: | |
| distribution: 'adopt' | |
| java-version: '21' | |
| - name: Make gradlew executable | |
| run: chmod +x ./gradlew | |
| - name: Publish to SimpleCloud Repository | |
| run: ./gradlew publishMavenJavaPublicationToSimplecloudRepository | |
| env: | |
| COMMIT_HASH: ${{ needs.build.outputs.commit_hash }} | |
| SIMPLECLOUD_USERNAME: ${{ secrets.SIMPLECLOUD_USERNAME }} | |
| SIMPLECLOUD_PASSWORD: ${{ secrets.SIMPLECLOUD_PASSWORD }} | |
| publish-modrinth: | |
| needs: build | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v3 | |
| with: | |
| ref: main | |
| - name: Set up JDK 21 | |
| uses: actions/setup-java@v3 | |
| with: | |
| distribution: 'adopt' | |
| java-version: '21' | |
| - name: Download artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: build-artifacts | |
| path: platform | |
| - name: Make gradlew executable | |
| run: chmod +x ./gradlew | |
| - name: Publish to Modrinth | |
| run: ./gradlew modrinth && ./gradlew modrinthSyncBody | |
| env: | |
| COMMIT_HASH: ${{ needs.build.outputs.commit_hash }} | |
| MODRINTH_TOKEN: ${{ secrets.MODRINTH_TOKEN }} | |
| create-github-release: | |
| needs: [build, publish-registry, publish-maven, publish-modrinth] | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Download artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: build-artifacts | |
| path: artifacts | |
| - name: Create GitHub Release | |
| id: create_release | |
| uses: actions/create-release@v1 | |
| with: | |
| tag_name: v${{ needs.build.outputs.gradle_version }}-dev.${{ needs.build.outputs.commit_hash }} | |
| release_name: v${{ needs.build.outputs.gradle_version }}-dev.${{ needs.build.outputs.commit_hash }} | |
| draft: false | |
| prerelease: true | |
| commitish: main | |
| body: | | |
| This release contains dev builds for all platform modules. | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Upload JARs to GitHub Release | |
| run: | | |
| for jar in $(find ./artifacts -type f -name "*.jar"); do | |
| if [[ $(basename "$jar") =~ -[0-9]+\.[0-9]+ ]]; then | |
| echo "Skipping $jar due to version number" | |
| else | |
| echo "Uploading $jar" | |
| gh release upload v${{ needs.build.outputs.gradle_version }}-dev.${{ needs.build.outputs.commit_hash }} "$jar" | |
| fi | |
| done | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |