diff --git a/.github/actions/javadocs/action.yaml b/.github/actions/javadocs/action.yaml new file mode 100644 index 000000000..924cc64d4 --- /dev/null +++ b/.github/actions/javadocs/action.yaml @@ -0,0 +1,72 @@ +name: 'Update Javadocs' +description: 'Update the Javadocs.' +inputs: + version: + type: string + required: true + description: 'The version of the source' + github_token: + type: string + required: true + description: 'The GitHub Personal Access Token to use to push changes' +runs: + using: "composite" + steps: + + - name: Checkout javadocs + uses: actions/checkout@v4 + with: + repository: PlazmaMC/Javadocs + ref: ${{ inputs.version }} + token: ${{ inputs.github_token }} + path: javadoc + continue-on-error: true + + - name: Checkout jdportal + uses: actions/checkout@v4 + with: + repository: PlazmaMC/Javadocs + token: ${{ inputs.github_token }} + path: jdmain + + - name: Update Javadoc + shell: bash + run: | + if [ ! -d "javadoc" ]; then + mkdir javadoc && cd javadoc + git init && git branch -m ${{ inputs.version }} + cd .. + fi + + cp -rf Plazma-API/build/docs/javadoc/* javadoc/ + cd javadoc + git add . && git commit -m "Update Javadocs" + continue-on-error: true + + - name: Push source changes (javadoc) + uses: ad-m/github-push-action@master + with: + repository: PlazmaMC/Javadocs + directory: ./javadoc + branch: ${{ inputs.version }} + github_token: ${{ inputs.github_token }} + force: true + + - name: Sync Javadocs Portal + shell: bash + run: | + cd jdmain + if [ ! -d "${{ inputs.version }}" ]; then + git submodule add -b ${{ inputs.version }} https://github.com/PlazmaMC/Javadocs ${{ inputs.version }} + fi + git submodule update + git add . && git commit -m "Update Javadocs" + continue-on-error: true + + - name: Push source changes (jd portal) + uses: ad-m/github-push-action@master + with: + repository: PlazmaMC/Javadocs + directory: ./jdmain + github_token: ${{ inputs.github_token }} + continue-on-error: true diff --git a/.github/actions/release/action.yaml b/.github/actions/release/action.yaml new file mode 100644 index 000000000..14f506194 --- /dev/null +++ b/.github/actions/release/action.yaml @@ -0,0 +1,117 @@ +name: 'Release artifacts' +description: 'Release artifacts to GitHub Releases.' +inputs: + version: + type: string + required: true + description: 'The version of the source' + development: + type: boolean + required: true + description: 'Whether artifacts are in development' + build_number: + type: number + required: false + description: 'The build number of the artifact' + github_token: + type: string + required: true + description: 'The GitHub Personal Access Token to use to push changes' + discord_webhook: + type: string + required: true + description: 'The Discord WebHook URL to send the notification' +defaults: + run: + shell: bash +runs: + using: "composite" + steps: + - run: echo "NOW=$(date --iso-8601=seconds)" >> $GITHUB_ENV + shell: bash + + - if: ${{ inputs.development == 'true' }} + uses: softprops/action-gh-release@v2 + with: + name: "Development Build for ${{ inputs.version }} (Build #${{ inputs.build_number }})" + prerelease: true + make_latest: false + generate_release_notes: true + tag_name: build/${{ inputs.version }}/${{ inputs.build_number }} + target_commitish: dev/${{ inputs.branch }} + files: build/libs/*.jar + fail_on_unmatched_files: true + token: ${{ inputs.github_token }} + + - if: ${{ inputs.development == 'true' }} + uses: softprops/action-gh-release@v2 + with: + name: "Development Build for ${{ inputs.version }} (Build #${{ inputs.build_number }})" + prerelease: true + make_latest: false + generate_release_notes: true + tag_name: build/${{ inputs.version }}/latest + target_commitish: dev/${{ inputs.branch }} + files: build/libs/*.jar + fail_on_unmatched_files: true + token: ${{ inputs.github_token }} + + - if: ${{ inputs.development == 'true' }} + uses: tsickert/discord-webhook@v6.0.0 + with: + wait: true + webhook-url: ${{ inputs.discord_webhook }} + thread-id: 1302596978496114728 + username: "Release Announcements" + avatar-url: "https://cdn.discordapp.com/icons/1083716853928558652/d6b797c80696da4b413fe6d3c1b1f73e.webp" + content: "<@&1302613464946053222>" + embed-timestamp: ${{ env.NOW }} + embed-author-name: "Development Build for ${{ inputs.version }}" + embed-author-url: "https://github.com/PlazmaMC/PlazmaBukkit/releases/tag/build/${{ inputs.version }}/${{ inputs.build_number }}" + embed-title: "The new Plazma ${{ inputs.version }} development build is available!" + embed-color: 15424410 + embed-description: | + *No information provided.* + + - if: ${{ inputs.development != 'true' }} + uses: softprops/action-gh-release@v2 + with: + name: "Plazma ${{ inputs.version }} (Build #${{ inputs.build_number }})" + prerelease: false + make_latest: false + generate_release_notes: true + tag_name: build/${{ inputs.version }}/${{ inputs.build_number }} + target_commitish: ver/${{ inputs.branch }} + files: build/libs/*.jar + fail_on_unmatched_files: true + token: ${{ inputs.github_token }} + + - if: ${{ inputs.development != 'true' }} + uses: softprops/action-gh-release@v2 + with: + name: "Plazma ${{ inputs.version }} (Build #${{ inputs.build_number }})" + prerelease: false + make_latest: true + generate_release_notes: true + tag_name: build/${{ inputs.version }}/latest + target_commitish: ver/${{ inputs.branch }} + files: build/libs/*.jar + fail_on_unmatched_files: true + token: ${{ inputs.github_token }} + + - if: ${{ inputs.development != 'true' }} + uses: tsickert/discord-webhook@v6.0.0 + with: + wait: true + webhook-url: ${{ inputs.discord_webhook }} + thread-id: 1302596978496114728 + username: "Release Announcements" + avatar-url: "https://cdn.discordapp.com/icons/1083716853928558652/d6b797c80696da4b413fe6d3c1b1f73e.webp" + content: "<@&1302613464946053222>" + embed-timestamp: ${{ env.NOW }} + embed-author-name: "Plazma ${{ inputs.version }} (Build #${{ inputs.build_number }})" + embed-author-url: "https://github.com/PlazmaMC/PlazmaBukkit/releases/tag/build/${{ inputs.version }}/${{ inputs.build_number }}" + embed-title: "The new Plazma ${{ inputs.version }} build is available!" + embed-color: 15424410 + embed-description: | + *No information provided.* diff --git a/.github/actions/sources/action.yaml b/.github/actions/sources/action.yaml new file mode 100644 index 000000000..28340fdd0 --- /dev/null +++ b/.github/actions/sources/action.yaml @@ -0,0 +1,49 @@ +name: 'Update internal sources' +description: 'Update the internal sources to the latest.' +inputs: + version: + type: string + required: true + description: 'The version of the source code' + github_token: + type: string + required: true + description: 'The GitHub Personal Access Token to use to push changes' +defaults: + run: + shell: bash +runs: + using: "composite" + steps: + - name: Merge vanilla sources + shell: bash + run: | + cd Plazma-Server + cp -r ./.gradle/caches/paperweight/mc-dev-sources/com ./src/main/java/ + cp -r ./.gradle/caches/paperweight/mc-dev-sources/net ./src/main/java/ + cp -r ./.gradle/caches/paperweight/mc-dev-sources/data ./src/main/resources/ + cp -r ./.gradle/caches/paperweight/mc-dev-sources/assets ./src/main/resources/ + cp -r ./.gradle/caches/paperweight/mc-dev-sources/META-INF ./src/main/resources/ + cp -r ./.gradle/caches/paperweight/mc-dev-sources/*.* ./src/main/resources/ + git add . + git commit --fixup $(git rev-list -n 1 base) + git rebase --autosquash upstream/master + cd .. + + - name: Push source changes (API) + uses: ad-m/github-push-action@master + with: + repository: PlazmaMC/sources-api + directory: ./Plazma-API + branch: plazma/${{ inputs.version }} + github_token: ${{ inputs.github_token }} + force: true + + - name: Push source changes (server) + uses: ad-m/github-push-action@master + with: + repository: PlazmaMC/sources-server + directory: ./Plazma-Server + branch: plazma/${{ inputs.version }} + github_token: ${{ inputs.github_token }} + force: true diff --git a/.github/workflows/global.yaml b/.github/workflows/global.yaml new file mode 100644 index 000000000..1387a971b --- /dev/null +++ b/.github/workflows/global.yaml @@ -0,0 +1,109 @@ +on: + workflow_call: + secrets: + GH_PAT: + required: true + SIG_JAR_ALIAS: + required: true + SIG_JAR_PASS: + required: true + SIG_JAR_STORE: + required: true + SIG_JAR_STORE_PASS: + required: true + SIG_MVN_PGP: + required: true + SIG_MVN_PASS: + required: true + +env: + ORG_GRADLE_PROJECT_ghName: ${{ github.repository_owner }} + ORG_GRADLE_PROJECT_ghToken: ${{ secrets.GH_PAT }} + ORG_GRADLE_PROJECT_signingKey: ${{ secrets.SIG_MVN_PGP }} + ORG_GRADLE_PROJECT_signingPassword: ${{ secrets.SIG_MVN_PASS }} + SIGN_KEY_ALIAS: ${{ secrets.SIG_JAR_ALIAS }} + SIGN_KEY_PASSWORD: ${{ secrets.SIG_JAR_PASS }} + SIGN_KEYSTORE_DATA: ${{ secrets.SIG_JAR_STORE }} + SIGN_KEYSTORE_PASSWORD: ${{ secrets.SIG_JAR_STORE_PASS }} + +jobs: + release: + name: Release Plazma + strategy: + matrix: + base_jdk: [21] + os: [ubuntu-22.04] + + if: "!startsWith(github.event.commits[0].message, '[CI-Skip]')" + runs-on: ${{ matrix.os }} + steps: + - name: Setup workflow + env: + BRANCH: ${{ github.ref_name }} + run: | + VERSION="${BRANCH##*/}" + echo "VERSION=$VERSION" >> $GITHUB_ENV + echo "BUILDID=$(git ls-remote --tags https://github.com/PlazmaMC/PlazmaBukkit | grep "build/$VERSION" | wc -l)" >> $GITHUB_ENV + git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com" + git config --global user.name "github-actions[bot]" + + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Validate Gradle Wrapper + uses: gradle/actions/wrapper-validation@v4 + + - name: Set up GraalVM ${{ matrix.base_jdk }} + uses: graalvm/setup-graalvm@v1 + with: + github-token: ${{ secrets.GH_PAT }} + java-version: ${{ matrix.base_jdk }} + version: latest + cache: 'gradle' + + - name: Apply Patches + run: ./gradlew applyPatches --info --stacktrace + + - name: Build Sources + run: ./gradlew build --info --stacktrace + + - name: Create Re-obfuscated Server Jar + run: ./gradlew createReobfPaperclipJar --info --stacktrace + + - name: Create Mojang-mapped Server Jar + run: ./gradlew createMojmapPaperclipJar --info --stacktrace + + - name: Upload artifacts + uses: actions/upload-artifact@v4 + with: + path: build/libs/*.jar + if-no-files-found: error + compression-level: 9 + + - name: Publish Packages + run: ./gradlew publish --info --stacktrace + if: startsWith(github.ref_name, 'ver/') || startsWith(github.ref_name, 'dev/') + + - name: Update internal sources + uses: PlazmaMC/PlazmaBukkit/.github/actions/sources@main + with: + version: ${{ env.VERSION }} + github_token: ${{ secrets.GH_PAT }} + if: startsWith(github.ref_name, 'ver/') || startsWith(github.ref_name, 'dev/') + + - name: Update Javadocs + uses: PlazmaMC/PlazmaBukkit/.github/actions/javadocs@main + with: + version: ${{ env.VERSION }} + github_token: ${{ secrets.GH_PAT }} + if: startsWith(github.ref_name, 'ver/') || startsWith(github.ref_name, 'dev/') + + - name: Release artifacts + uses: PlazmaMC/PlazmaBukkit/.github/actions/release@main + with: + version: ${{ env.VERSION }} + development: startsWith(github.ref_name, 'dev/') + build_number: ${{ env.BUILDID }} + github_token: ${{ secrets.GH_PAT }} + discord_webhook: ${{ secrets.WEBHOOK_URL }} + if: startsWith(github.ref_name, 'ver/') || startsWith(github.ref_name, 'dev/') diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml new file mode 100644 index 000000000..50240194d --- /dev/null +++ b/.github/workflows/release.yaml @@ -0,0 +1,18 @@ +name: Release Plazma +run-name: Manual release of Plazma on branch ${{ github.ref_name }} + +on: + push: + branches: [ "ver/*", "dev/*", "feat/**/*" ] + paths: + - "patches/api/*" + - "patches/server/*" + - "gradle.properties" + workflow_dispatch: + +jobs: + release: + if: ${{ github.ref_name != "main }} + name: Release Plazma (${{ github.ref_name }}) + uses: PlazmaMC/PlazmaBukkit/.github/workflows/global.yaml@main + secrets: inherit diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml deleted file mode 100644 index 7a0ccbef7..000000000 --- a/.github/workflows/release.yml +++ /dev/null @@ -1,141 +0,0 @@ -name: Release - -on: - push: - branches: [ "ver/*", "dev/*", "feat/**/*" ] - workflow_dispatch: - -env: - ORG_NAME: PlazmaMC - -jobs: - release: - name: Release Plazma - strategy: - matrix: - base_jdk: [21] - os: [ubuntu-22.04] - - if: "!startsWith(github.event.commits[0].message, '[CI-Skip]')" - runs-on: ${{ matrix.os }} - steps: - - name: Setup Variables - id: setup - env: - BRANCH: ${{ github.ref_name }} - run: echo "VERSION=${BRANCH##*/}" >> $GITHUB_ENV - - - name: Checkout repository - uses: actions/checkout@v4 - - - name: Checkout javadocs - uses: actions/checkout@v4 - continue-on-error: true - if: startsWith(github.ref_name, 'ver/') || startsWith(github.ref_name, 'dev/') - with: - repository: PlazmaMC/Javadocs - ref: ${{ env.VERSION }} - token: ${{ secrets.GH_PAT }} - path: javadoc - - - name: Checkout javadocs - uses: actions/checkout@v4 - if: startsWith(github.ref_name, 'ver/') || startsWith(github.ref_name, 'dev/') - with: - repository: PlazmaMC/Javadocs - token: ${{ secrets.GH_PAT }} - path: jdmain - - - name: Validate Gradle Wrapper - uses: gradle/wrapper-validation-action@v1 - - - name: Set up GraalVM ${{ matrix.base_jdk }} - uses: graalvm/setup-graalvm@v1 - with: - github-token: ${{ secrets.GITHUB_TOKEN }} - java-version: ${{ matrix.base_jdk }} - version: latest - cache: 'gradle' - - - name: Configure Git - run: git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com" && git config --global user.name "github-actions[bot]" - - - name: Get Release Number - if: startsWith(github.ref_name, 'ver/') - run: echo "BUILD_NUMBER=$(git ls-remote --tags origin | grep "build/${{ env.VERSION }}" | wc -l)" >> $GITHUB_ENV - - - name: Apply Patches - run: ./gradlew applyPatches --stacktrace - - - name: Build - run: ./gradlew build --stacktrace - - - name: Create Reobf Jar - run: ./gradlew createReobfPaperclipJar --stacktrace - - - name: Create Mojmap Jar - run: ./gradlew createMojmapPaperclipJar --stacktrace - - - name: Publish Packages - if: startsWith(github.ref_name, 'ver/') || startsWith(github.ref_name, 'dev/') - run: | - export GITHUB_USERNAME=${{ env.ORG_NAME }} - export GITHUB_TOKEN=${{ secrets.GITHUB_TOKEN }} - ./gradlew publish --stacktrace - - - name: Update Javadoc - if: startsWith(github.ref_name, 'ver/') || startsWith(github.ref_name, 'dev/') - continue-on-error: true - run: | - if [ ! -d "javadoc" ]; then - SUBMODULE_ADD=true - mkdir javadoc && cd javadoc - git init && git branch -m ${{ env.VERSION }} - git remote add origin https://github.com/PlazmaMC/Javadocs - fi - - cp -rf Plazma-API/build/docs/javadoc/* javadoc/ - cd javadoc - git add . && git commit -m "Update Javadocs" - git push -f origin ${{ env.VERSION }} - - cd ../jdmain - if [ $SUBMODULE_ADD = true ]; then - git submodule add -b ${{ env.VERSION }} https://github.com/PlazmaMC/Javadocs ${{ env.VERSION }} - fi - git submodule update - git add . && git commit -m "Update Javadocs" - git push - - - name: Release Artifacts - if: startsWith(github.ref_name, 'ver/') - uses: softprops/action-gh-release@v0.1.15 - with: - name: "Build #${{ env.BUILD_NUMBER }} for ${{ env.VERSION }}" - tag_name: "build/${{ env.VERSION }}/${{ env.BUILD_NUMBER }}" - target_commitish: ${{ github.ref_name }} - generate_release_notes: true - fail_on_unmatched_files: true - files: build/libs/*.jar - - - name: Release Artifacts (Latest/Stable) - if: startsWith(github.ref_name, 'ver/') - uses: softprops/action-gh-release@v0.1.15 - with: - name: "Build #${{ env.BUILD_NUMBER }} for ${{ env.VERSION }}" - tag_name: "build/${{ github.ref_name }}/latest" - target_commitish: ${{ github.ref_name }} - generate_release_notes: true - fail_on_unmatched_files: true - files: build/libs/*.jar - - - name: Release Artifacts (Latest/Development) - if: startsWith(github.ref_name, 'dev/') - uses: softprops/action-gh-release@v0.1.15 - with: - name: "Development Build for ${{ env.VERSION }}" - tag_name: build/${{ env.VERSION }}/latest - target_commitish: ${{ github.ref_name }} - generate_release_notes: true - fail_on_unmatched_files: true - files: build/libs/*.jar