mirror of
https://github.com/GeyserMC/Geyser.git
synced 2024-08-14 23:57:35 +00:00
Fix preview workflow
This commit is contained in:
parent
94f664ad8d
commit
79573ac93b
5 changed files with 97 additions and 64 deletions
|
@ -1,13 +1,27 @@
|
||||||
name: Build Pull Request
|
name: Build Remote
|
||||||
|
|
||||||
on:
|
on:
|
||||||
pull_request:
|
workflow_call:
|
||||||
merge_group:
|
inputs:
|
||||||
|
repository:
|
||||||
|
required: true
|
||||||
|
description: 'The repo of the remote'
|
||||||
|
type: string
|
||||||
|
ref:
|
||||||
|
required: true
|
||||||
|
description: 'The ref of the remote'
|
||||||
|
type: string
|
||||||
|
|
||||||
|
permissions: {}
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
|
- name: Set Build Number
|
||||||
|
run: |
|
||||||
|
echo "BUILD_NUMBER=${GITHUB_RUN_NUMBER}" >> $GITHUB_ENV
|
||||||
|
|
||||||
- name: Set up JDK 17
|
- name: Set up JDK 17
|
||||||
# See https://github.com/actions/setup-java/commits
|
# See https://github.com/actions/setup-java/commits
|
||||||
uses: actions/setup-java@387ac29b308b003ca37ba93a6cab5eb57c8f5f93 # v4.0.0
|
uses: actions/setup-java@387ac29b308b003ca37ba93a6cab5eb57c8f5f93 # v4.0.0
|
||||||
|
@ -15,29 +29,12 @@ jobs:
|
||||||
java-version: 17
|
java-version: 17
|
||||||
distribution: temurin
|
distribution: temurin
|
||||||
|
|
||||||
- name: Check if the author has forked the API repo
|
|
||||||
# See https://github.com/Kas-tle/find-forks-action/commits
|
|
||||||
uses: Kas-tle/find-forks-action@1b5447d1e3c7a8ed79583dd817cc5399686eed3a
|
|
||||||
id: find_forks
|
|
||||||
with:
|
|
||||||
owner: GeyserMC
|
|
||||||
repo: api
|
|
||||||
token: ${{ secrets.GITHUB_TOKEN }}
|
|
||||||
|
|
||||||
- name: Use author's API repo if it exists
|
|
||||||
if: ${{ steps.find_forks.outputs.target_branch_found == 'true' }}
|
|
||||||
env:
|
|
||||||
API_FORK_URL: ${{ steps.find_forks.outputs.user_fork_url }}
|
|
||||||
API_FORK_BRANCH: ${{ github.event.pull_request.head.ref }}
|
|
||||||
run: |
|
|
||||||
git clone "${API_FORK_URL}" --single-branch --branch "${API_FORK_BRANCH}" api
|
|
||||||
cd api
|
|
||||||
./gradlew publishToMavenLocal
|
|
||||||
|
|
||||||
- name: Checkout repository and submodules
|
- name: Checkout repository and submodules
|
||||||
# See https://github.com/actions/checkout/commits
|
# See https://github.com/actions/checkout/commits
|
||||||
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
|
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
|
||||||
with:
|
with:
|
||||||
|
repository: ${{ inputs.repository }}
|
||||||
|
ref: ${{ inputs.ref }}
|
||||||
submodules: recursive
|
submodules: recursive
|
||||||
path: geyser
|
path: geyser
|
||||||
|
|
||||||
|
@ -46,11 +43,12 @@ jobs:
|
||||||
uses: gradle/wrapper-validation-action@699bb18358f12c5b78b37bb0111d3a0e2276e0e2 # v2.1.1
|
uses: gradle/wrapper-validation-action@699bb18358f12c5b78b37bb0111d3a0e2276e0e2 # v2.1.1
|
||||||
|
|
||||||
- name: Build Geyser
|
- name: Build Geyser
|
||||||
# See https://github.com/gradle/gradle-build-action/commits
|
# See https://github.com/gradle/actions/commits
|
||||||
uses: gradle/actions/setup-gradle@417ae3ccd767c252f5661f1ace9f835f9654f2b5 # v3.1.0 from https://github.com/gradle/actions/commits
|
uses: gradle/actions/setup-gradle@417ae3ccd767c252f5661f1ace9f835f9654f2b5 # v3.1.0
|
||||||
with:
|
with:
|
||||||
arguments: build
|
arguments: build
|
||||||
build-root-directory: geyser
|
build-root-directory: geyser
|
||||||
|
cache-read-only: true
|
||||||
|
|
||||||
- name: Archive artifacts (Geyser Fabric)
|
- name: Archive artifacts (Geyser Fabric)
|
||||||
# See https://github.com/actions/upload-artifact/commits
|
# See https://github.com/actions/upload-artifact/commits
|
||||||
|
@ -101,22 +99,4 @@ jobs:
|
||||||
with:
|
with:
|
||||||
name: Geyser ViaProxy
|
name: Geyser ViaProxy
|
||||||
path: geyser/bootstrap/viaproxy/build/libs/Geyser-ViaProxy.jar
|
path: geyser/bootstrap/viaproxy/build/libs/Geyser-ViaProxy.jar
|
||||||
if-no-files-found: error
|
if-no-files-found: error
|
||||||
|
|
||||||
- name: Trigger Preview Deployment
|
|
||||||
if: >-
|
|
||||||
contains(github.event.pull_request.labels.*.name, 'PR: Needs Testing')
|
|
||||||
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea
|
|
||||||
with:
|
|
||||||
script: |
|
|
||||||
github.rest.actions.createWorkflowDispatch({
|
|
||||||
owner: context.repo.owner,
|
|
||||||
repo: context.repo.repo,
|
|
||||||
workflow_id: 'preview.yml',
|
|
||||||
ref: 'master',
|
|
||||||
inputs: {
|
|
||||||
runId: '${{ github.run_id }}',
|
|
||||||
build: '${{ github.run_number }}',
|
|
||||||
version: 'pr.${{ github.event.pull_request.number }}'
|
|
||||||
}
|
|
||||||
});
|
|
20
.github/workflows/build.yml
vendored
20
.github/workflows/build.yml
vendored
|
@ -7,8 +7,9 @@ on:
|
||||||
- 'gh-readonly-queue/**'
|
- 'gh-readonly-queue/**'
|
||||||
paths-ignore:
|
paths-ignore:
|
||||||
- '.github/ISSUE_TEMPLATE/*.yml'
|
- '.github/ISSUE_TEMPLATE/*.yml'
|
||||||
- '.github/actions/pullrequest.yml'
|
- '.github/actions/workflows/build-remote.yml'
|
||||||
- '.github/actions/preview.yml'
|
- '.github/actions/workflows//preview.yml'
|
||||||
|
- '.github/actions/workflows//pull-request.yml'
|
||||||
- '.idea/copyright/*.xml'
|
- '.idea/copyright/*.xml'
|
||||||
- '.gitignore'
|
- '.gitignore'
|
||||||
- 'CONTRIBUTING.md'
|
- 'CONTRIBUTING.md'
|
||||||
|
@ -23,6 +24,13 @@ jobs:
|
||||||
env:
|
env:
|
||||||
PROJECT: 'geyser'
|
PROJECT: 'geyser'
|
||||||
steps:
|
steps:
|
||||||
|
- name: Set Build Number
|
||||||
|
env:
|
||||||
|
BUILD_JSON: ${{ vars.RELEASEACTION_PREVRELEASE }}
|
||||||
|
run: |
|
||||||
|
BUILD_NUMBER=$(echo $BUILD_JSON | jq --arg branch "${GITHUB_REF_NAME}" 'if .[$branch] == null then 1 else .[$branch] | .t | tonumber + 1 end // 1')
|
||||||
|
echo "BUILD_NUMBER=${BUILD_NUMBER}" >> $GITHUB_ENV
|
||||||
|
|
||||||
- name: Checkout repository and submodules
|
- name: Checkout repository and submodules
|
||||||
# See https://github.com/actions/checkout/commits
|
# See https://github.com/actions/checkout/commits
|
||||||
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
|
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
|
||||||
|
@ -40,8 +48,8 @@ jobs:
|
||||||
distribution: temurin
|
distribution: temurin
|
||||||
|
|
||||||
- name: Build
|
- name: Build
|
||||||
# See https://github.com/gradle/gradle-build-action/commits
|
# See https://github.com/gradle/actions/commits
|
||||||
uses: gradle/actions/setup-gradle@417ae3ccd767c252f5661f1ace9f835f9654f2b5 # v3.1.0 from https://github.com/gradle/actions/commits
|
uses: gradle/actions/setup-gradle@417ae3ccd767c252f5661f1ace9f835f9654f2b5 # v3.1.0
|
||||||
with:
|
with:
|
||||||
arguments: build
|
arguments: build
|
||||||
gradle-home-cache-cleanup: true
|
gradle-home-cache-cleanup: true
|
||||||
|
@ -108,7 +116,8 @@ jobs:
|
||||||
|
|
||||||
- name: Get Release Metadata
|
- name: Get Release Metadata
|
||||||
if: ${{ success() && github.repository == 'GeyserMC/Geyser' && github.ref_name == 'master' }}
|
if: ${{ success() && github.repository == 'GeyserMC/Geyser' && github.ref_name == 'master' }}
|
||||||
uses: Kas-tle/base-release-action@b863fa0f89bd15267a96a72efb84aec25f168d4c # https://github.com/Kas-tle/base-release-action/releases/tag/main-11
|
# See https://github.com/Kas-tle/base-release-action/releases/tag/main-11
|
||||||
|
uses: Kas-tle/base-release-action@b863fa0f89bd15267a96a72efb84aec25f168d4c # main-11
|
||||||
with:
|
with:
|
||||||
appID: ${{ secrets.RELEASE_APP_ID }}
|
appID: ${{ secrets.RELEASE_APP_ID }}
|
||||||
appPrivateKey: ${{ secrets.RELEASE_APP_PK }}
|
appPrivateKey: ${{ secrets.RELEASE_APP_PK }}
|
||||||
|
@ -134,6 +143,7 @@ jobs:
|
||||||
| .downloads |= map_values({"name", "sha256"})
|
| .downloads |= map_values({"name", "sha256"})
|
||||||
| {$project, "repo", $version, "number": .build, "changes", "downloads"}
|
| {$project, "repo", $version, "number": .build, "changes", "downloads"}
|
||||||
' | tee metadata.json
|
' | tee metadata.json
|
||||||
|
echo
|
||||||
- name: Publish to Downloads API
|
- name: Publish to Downloads API
|
||||||
if: ${{ success() && github.repository == 'GeyserMC/Geyser' && github.ref_name == 'master' }}
|
if: ${{ success() && github.repository == 'GeyserMC/Geyser' && github.ref_name == 'master' }}
|
||||||
shell: bash
|
shell: bash
|
||||||
|
|
44
.github/workflows/preview.yml
vendored
44
.github/workflows/preview.yml
vendored
|
@ -12,23 +12,44 @@ on:
|
||||||
version:
|
version:
|
||||||
required: true
|
required: true
|
||||||
description: 'Version under which to upload to the Downloads API'
|
description: 'Version under which to upload to the Downloads API'
|
||||||
|
workflow_call:
|
||||||
|
inputs:
|
||||||
|
build:
|
||||||
|
required: true
|
||||||
|
description: 'Build number for the release'
|
||||||
|
type: string
|
||||||
|
version:
|
||||||
|
required: true
|
||||||
|
description: 'Version under which to upload to the Downloads API'
|
||||||
|
type: string
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
upload:
|
upload:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
env:
|
env:
|
||||||
PROJECT: 'geyserpreview'
|
PROJECT: 'geyser-preview'
|
||||||
BUILD: ${{ github.event.inputs.build }}
|
|
||||||
VERSION: ${{ github.event.inputs.version }}
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/download-artifact@c850b930e6ba138125429b7e5c93fc707a7f8427 # https://github.com/actions/download-artifact/releases/tag/v4.1.4
|
- name: Set Variables
|
||||||
|
id: setvars
|
||||||
|
run: |
|
||||||
|
if [ "${{ github.event_name }}" == "workflow_dispatch" ]; then
|
||||||
|
echo "BUILD=${{ github.event.inputs.build }}" >> $GITHUB_ENV
|
||||||
|
echo "VERSION=${{ github.event.inputs.version }}" >> $GITHUB_ENV
|
||||||
|
echo "RUN=${{ github.event.inputs.runId }}" >> $GITHUB_OUTPUT
|
||||||
|
else
|
||||||
|
echo "BUILD=${{ inputs.build }}" >> $GITHUB_ENV
|
||||||
|
echo "VERSION=${{ inputs.version }}" >> $GITHUB_ENV
|
||||||
|
echo "RUN=${{ github.run_id }}" >> $GITHUB_OUTPUT
|
||||||
|
fi
|
||||||
|
- uses: actions/download-artifact@c850b930e6ba138125429b7e5c93fc707a7f8427
|
||||||
with:
|
with:
|
||||||
run-id: ${{ github.event.inputs.runId }}
|
run-id: ${{ steps.setvars.outputs.RUN }}
|
||||||
github-token: ${{ secrets.GITHUB_TOKEN }}
|
github-token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
merge-multiple: true
|
merge-multiple: true
|
||||||
- name: Get Preview Metadata
|
- name: Get Preview Metadata
|
||||||
if: success()
|
#if: ${{ success() && github.repository == 'GeyserMC/Geyser' && github.ref_name == 'master' }}
|
||||||
uses: Kas-tle/base-release-action@b863fa0f89bd15267a96a72efb84aec25f168d4c # https://github.com/Kas-tle/base-release-action/releases/tag/main-11
|
# See https://github.com/Kas-tle/base-release-action/releases/tag/main-11
|
||||||
|
uses: Kas-tle/base-release-action@664c39985eb9d0d393ce98e7eb8414d3d98e762a # main-11
|
||||||
with:
|
with:
|
||||||
appID: ${{ secrets.RELEASE_APP_ID }}
|
appID: ${{ secrets.RELEASE_APP_ID }}
|
||||||
appPrivateKey: ${{ secrets.RELEASE_APP_PK }}
|
appPrivateKey: ${{ secrets.RELEASE_APP_PK }}
|
||||||
|
@ -44,7 +65,7 @@ jobs:
|
||||||
saveMetadata: true
|
saveMetadata: true
|
||||||
updateReleaseData: false
|
updateReleaseData: false
|
||||||
- name: Update Generated Metadata
|
- name: Update Generated Metadata
|
||||||
if: success()
|
#if: ${{ success() && github.repository == 'GeyserMC/Geyser' && github.ref_name == 'master' }}
|
||||||
run: |
|
run: |
|
||||||
cat metadata.json
|
cat metadata.json
|
||||||
echo
|
echo
|
||||||
|
@ -54,7 +75,7 @@ jobs:
|
||||||
| {$project, "repo", $version, "number": $number | tonumber, "changes": [], "downloads"}
|
| {$project, "repo", $version, "number": $number | tonumber, "changes": [], "downloads"}
|
||||||
' | tee metadata.json
|
' | tee metadata.json
|
||||||
- name: Publish to Downloads API
|
- name: Publish to Downloads API
|
||||||
if: success()
|
if: ${{ success() && github.repository == 'GeyserMC/Geyser' && github.ref_name == 'master' }}
|
||||||
shell: bash
|
shell: bash
|
||||||
env:
|
env:
|
||||||
DOWNLOADS_USERNAME: ${{ vars.DOWNLOADS_USERNAME }}
|
DOWNLOADS_USERNAME: ${{ vars.DOWNLOADS_USERNAME }}
|
||||||
|
@ -67,7 +88,8 @@ jobs:
|
||||||
# Create the build folder
|
# Create the build folder
|
||||||
ssh -o StrictHostKeyChecking=no -i id_ecdsa $DOWNLOADS_USERNAME@$DOWNLOADS_SERVER_IP mkdir -p "~/uploads/$PROJECT/$BUILD/"
|
ssh -o StrictHostKeyChecking=no -i id_ecdsa $DOWNLOADS_USERNAME@$DOWNLOADS_SERVER_IP mkdir -p "~/uploads/$PROJECT/$BUILD/"
|
||||||
# Copy over artifacts
|
# Copy over artifacts
|
||||||
rsync -P -e "ssh -o StrictHostKeyChecking=no -i id_ecdsa" Geyser-*.jar $DOWNLOADS_USERNAME@$DOWNLOADS_SERVER_IP:~/uploads/$PROJECT/$BUILD/
|
rsync -P -e "ssh -o StrictHostKeyChecking=no -i id_ecdsa" bootstrap/**/build/libs/Geyser-*.jar $DOWNLOADS_USERNAME@$DOWNLOADS_SERVER_IP:~/uploads/$PROJECT/$BUILD/
|
||||||
|
rsync -P -e "ssh -o StrictHostKeyChecking=no -i id_ecdsa" bootstrap/mod/**/build/libs/Geyser-*.jar $DOWNLOADS_USERNAME@$DOWNLOADS_SERVER_IP:~/uploads/$PROJECT/$BUILD/
|
||||||
# Run the build script
|
# Run the build script
|
||||||
# Push the metadata
|
# Push the metadata
|
||||||
rsync -P -e "ssh -o StrictHostKeyChecking=no -i id_ecdsa" metadata.json $DOWNLOADS_USERNAME@$DOWNLOADS_SERVER_IP:~/uploads/$PROJECT/$BUILD/
|
rsync -P -e "ssh -o StrictHostKeyChecking=no -i id_ecdsa" metadata.json $DOWNLOADS_USERNAME@$DOWNLOADS_SERVER_IP:~/uploads/$PROJECT/$BUILD/
|
24
.github/workflows/pull-request.yml
vendored
Normal file
24
.github/workflows/pull-request.yml
vendored
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
name: Process Pull Request
|
||||||
|
|
||||||
|
on:
|
||||||
|
pull_request_target:
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
# Forbid access to secrets nor GH Token perms while building the PR
|
||||||
|
permissions: {}
|
||||||
|
secrets: {}
|
||||||
|
uses: ./.github/workflows/build-remote.yml
|
||||||
|
with:
|
||||||
|
repository: ${{ github.event.pull_request.head.repo.full_name }}
|
||||||
|
ref: ${{ github.event.pull_request.head.sha }}
|
||||||
|
preview:
|
||||||
|
needs: [build]
|
||||||
|
if: >-
|
||||||
|
contains(github.event.pull_request.labels.*.name, 'PR: Needs Testing')
|
||||||
|
# Allow access to secrets if we are uploading a preview
|
||||||
|
secrets: inherit
|
||||||
|
uses: ./.github/workflows/preview.yml
|
||||||
|
with:
|
||||||
|
build: ${{ github.run_number }}
|
||||||
|
version: pr.${{ github.event.pull_request.number }}
|
|
@ -98,7 +98,7 @@ configure<BlossomExtension> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fun Project.buildNumber(): Int =
|
fun Project.buildNumber(): Int =
|
||||||
(System.getenv("GITHUB_RUN_NUMBER") ?: jenkinsBuildNumber())?.let { Integer.parseInt(it) } ?: -1
|
(System.getenv("BUILD_NUMBER"))?.let { Integer.parseInt(it) } ?: -1
|
||||||
|
|
||||||
inner class GitInfo {
|
inner class GitInfo {
|
||||||
val branch: String
|
val branch: String
|
||||||
|
@ -131,9 +131,6 @@ inner class GitInfo {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// todo remove this when we're not using Jenkins anymore
|
|
||||||
fun jenkinsBuildNumber(): String? = System.getenv("BUILD_NUMBER")
|
|
||||||
|
|
||||||
// Manual task to download the bedrock data files from the CloudburstMC/Data repository
|
// Manual task to download the bedrock data files from the CloudburstMC/Data repository
|
||||||
// Invoke with ./gradlew :core:downloadBedrockData --suffix=1_20_70
|
// Invoke with ./gradlew :core:downloadBedrockData --suffix=1_20_70
|
||||||
// Set suffix to the current Bedrock version
|
// Set suffix to the current Bedrock version
|
||||||
|
|
Loading…
Reference in a new issue