Skip to content

Commit

Permalink
Use reusable workflow (#104)
Browse files Browse the repository at this point in the history
  • Loading branch information
AlphaKR93 authored Nov 3, 2024
1 parent 8f27c26 commit 36944f8
Show file tree
Hide file tree
Showing 6 changed files with 354 additions and 141 deletions.
70 changes: 70 additions & 0 deletions .github/actions/javadocs/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
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
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
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
113 changes: 113 additions & 0 deletions .github/actions/release/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
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'
runs:
using: "composite"
steps:
- run: echo "NOW=$(date --iso-8601=seconds)" >> $GITHUB_ENV

- if: inputs.development
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
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
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
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
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
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.*
45 changes: 45 additions & 0 deletions .github/actions/sources/actions.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
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'
runs:
using: "composite"
steps:
- name: Merge vanilla sources
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
109 changes: 109 additions & 0 deletions .github/workflows/global.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
on:
workflow_call:
secrets:
GH_PAT:
required: true
SIGN_KEY:
required: true
SIGN_PASSWORD:
required: true
SIGN_KEY_ALIAS:
required: true
SIGN_KEY_PASSWORD:
required: true
SIGN_KEYSTORE_DATA:
required: true
SIGN_KEYSTORE_PASSWORD:
required: true

env:
ORG_GRADLE_PROJECT_ghName: ${{ github.repository_owner }}
ORG_GRADLE_PROJECT_ghToken: ${{ secrets.GH_PAT }}
ORG_GRADLE_PROJECT_signingKey: ${{ secrets.SIGN_KEY }}
ORG_GRADLE_PROJECT_signingPassword: ${{ secrets.SIGN_PASSWORD }}
SIGN_KEY_ALIAS: ${{ secrets.SIGN_KEY_ALIAS }}
SIGN_KEY_PASSWORD: ${{ secrets.SIGN_KEY_PASSWORD }}
SIGN_KEYSTORE_DATA: ${{ secrets.SIGN_KEYSTORE_DATA }}
SIGN_KEYSTORE_PASSWORD: ${{ secrets.SIGN_KEYSTORE_PASSWORD }}

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 ${{ github.repositoryUrl }} | 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: ./.github/actions/sources
with:
version: ${{ env.VERSION }}
github_token: ${{ secrets.GH_PAT }}
if: startsWith(github.ref_name, 'ver/') || startsWith(github.ref_name, 'dev/')

- name: Update Javadocs
uses: ./.github/actions/javadocs
with:
version: ${{ env.VERSION }}
github_token: ${{ secrets.GH_PAT }}
if: startsWith(github.ref_name, 'ver/') || startsWith(github.ref_name, 'dev/')

- name: Release artifacts
uses: ./.github/actions/release
with:
version: ${{ env.VERSION }}
development: startsWith(github.ref_name, 'dev/')
build_number: ${{ env.BUILDID }}
github_token: ${{ secrets.GH_PAT }}
discord_webhook: ${{ secrets.WEBHOOK }}
if: startsWith(github.ref_name, 'ver/') || startsWith(github.ref_name, 'dev/')
17 changes: 17 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
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:
name: Release Plazma (${{ github.ref_name }})
uses: PlazmaMC/PlazmaBukkit/.github/workflows/global.yaml@main
secrets: inherit
Loading

0 comments on commit 36944f8

Please sign in to comment.