|
| 1 | +# Performs all releases using a multipart approach |
| 2 | +name: release |
| 3 | + |
| 4 | +env: |
| 5 | + PROJECT_NAME: GraphLib |
| 6 | + JAVADOC_DIR: com/kneelawk/graphlib/graphlib-javadoc-xplat |
| 7 | + MAVEN_IDENTIFIER: 'com.kneelawk.graphlib:graphlib-core-xplat-intermediary' |
| 8 | + ROLE_ID: '1239437674058879047' |
| 9 | + |
| 10 | +# Variant: github, maven+javadoc, discord |
| 11 | + |
| 12 | +# Changes: |
| 13 | +# 2023-04-22 - Kneelawk: Added changes & variant comments. Fixed Grab CF File ID task name. Renamed build job to |
| 14 | +# build-release. Reformatted. |
| 15 | +# 2023-04-22 - Kneelawk: Fix references to build job to point to build-release job. |
| 16 | +# 2023-04-22 - Kneelawk: Copy gradle caches to prevent re-building in publishing jobs. |
| 17 | +# 2023-05-02 - Kneelawk: Added javadoc publishing. Added maven job step for getting proper tag version by removing 'v'. |
| 18 | +# 2023-05-08 - Kneelawk: Combined maven and javadoc steps. |
| 19 | +# 2023-05-10 - Kneelawk: Copy all javadoc directories in the docs directory. |
| 20 | +# 2023-05-10 - Kneelawk: Use regular publish gradle task. |
| 21 | +# 2023-12-12 - Kneelawk: Switch back to single-job system to avoid uploading massive artifacts. |
| 22 | + |
| 23 | +on: |
| 24 | + push: |
| 25 | + tags: |
| 26 | + # matches things like v0.3.3+1.18.2 |
| 27 | + - 'v[0-9]+.[0-9]+.[0-9]+\+[0-9]+.[0-9]+.[0-9]+' |
| 28 | + # matches things like v0.4.0+1.19 |
| 29 | + - 'v[0-9]+.[0-9]+.[0-9]+\+[0-9]+.[0-9]+' |
| 30 | + |
| 31 | +jobs: |
| 32 | + release: |
| 33 | + runs-on: ubuntu-latest |
| 34 | + steps: |
| 35 | + - name: Checkout |
| 36 | + uses: actions/checkout@v4 |
| 37 | + - name: Validate Gradle Wrapper |
| 38 | + uses: gradle/wrapper-validation-action@v1 |
| 39 | + - name: Setup JDK 21 |
| 40 | + uses: actions/setup-java@v4 |
| 41 | + with: |
| 42 | + distribution: 'temurin' |
| 43 | + java-version: 21 |
| 44 | + - name: Make Gradle Wrapper Executable |
| 45 | + run: chmod +x ./gradlew |
| 46 | + - name: Build |
| 47 | + run: ./gradlew build |
| 48 | + env: |
| 49 | + RELEASE_TAG: ${{ github.ref_name }} |
| 50 | + - name: Capture Build Directory |
| 51 | + uses: actions/upload-artifact@v4 |
| 52 | + with: |
| 53 | + name: build-dir |
| 54 | + path: build/ |
| 55 | + - name: Github Release |
| 56 | + uses: softprops/action-gh-release@v2 |
| 57 | + with: |
| 58 | + body_path: changelogs/changelog-${{ github.ref_name }}.md |
| 59 | + files: build/libs/* |
| 60 | + env: |
| 61 | + GITHUB_TOKEN: ${{ secrets.PUBLISH_TOKEN }} |
| 62 | + - name: Maven Release |
| 63 | + run: ./gradlew publish -PkneelawkUsername=${{ secrets.MAVEN_USERNAME }} -PkneelawkPassword=${{ secrets.MAVEN_PASSWORD }} |
| 64 | + env: |
| 65 | + RELEASE_TAG: ${{ github.ref_name }} |
| 66 | + # This is the mess that publishes discord notifications |
| 67 | + - name: Read Changelog File |
| 68 | + uses: juliangruber/read-file-action@v1 |
| 69 | + id: changelog |
| 70 | + with: |
| 71 | + path: changelogs/changelog-${{ github.ref_name }}.md |
| 72 | + - name: Process Changelog for Announcement |
| 73 | + uses: actions/github-script@v7 |
| 74 | + id: announcement_text |
| 75 | + env: |
| 76 | + CHANGELOG: ${{ steps.changelog.outputs.content }} |
| 77 | + TAG_VERSION: ${{ github.ref_name }} |
| 78 | + with: |
| 79 | + script: | |
| 80 | + let fullVersion = process.env.TAG_VERSION; |
| 81 | + let versions = fullVersion.split('+'); |
| 82 | + let mavenVersion = fullVersion.substring(1); |
| 83 | + let lines = process.env.CHANGELOG.split('\n'); |
| 84 | + let changesStart = lines.findIndex(line => line.startsWith('*')); |
| 85 | + lines.splice(0, changesStart); |
| 86 | + lines.unshift(`# ${process.env.PROJECT_NAME} Release`, `**<@&${process.env.ROLE_ID}> ${process.env.PROJECT_NAME} ${versions[0]} has been released for Minecraft ${versions[1]}!**`, '', '__Changes:__'); |
| 87 | + lines.push("Available on Kneelawk's maven: https://maven.kneelawk.com/releases/", `With the identifier: \`${process.env.MAVEN_IDENTIFIER}:${mavenVersion}\``); |
| 88 | + lines.push(`Javadoc available at: https://maven.kneelawk.com/javadoc/releases/${process.env.JAVADOC_DIR}/${mavenVersion}`); |
| 89 | + return lines.join('\n'); |
| 90 | + result-encoding: string |
| 91 | + - name: Make Release Announcement |
| 92 | + uses: Ilshidur/action-discord@0.3.2 |
| 93 | + env: |
| 94 | + DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }} |
| 95 | + with: |
| 96 | + args: ${{ steps.announcement_text.outputs.result }} |
0 commit comments