Check snapshot/1.20/23w45a #51
This file contains 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: Check | |
run-name: Check ${{ inputs.version }} | |
permissions: | |
contents: write | |
on: | |
workflow_call: | |
inputs: | |
branch: | |
required: false | |
type: string | |
version: | |
required: true | |
type: string | |
push_changed: | |
default: true | |
required: false | |
type: boolean | |
publish: | |
default: true | |
required: false | |
type: boolean | |
secrets: | |
MAVEN_USER: | |
required: false | |
MAVEN_PASSWORD: | |
required: false | |
DISCORD_WEBHOOK_URL: | |
required: false | |
workflow_dispatch: | |
inputs: | |
version: | |
description: 'Version' | |
required: true | |
push_changed: | |
description: 'Push changed patches' | |
default: true | |
required: false | |
type: boolean | |
publish: | |
description: 'Publish' | |
default: true | |
required: false | |
type: boolean | |
jobs: | |
common: | |
runs-on: ubuntu-latest | |
outputs: | |
discord_fields: ${{ steps.discord_fields.outputs.discord_fields }} | |
jdk_version: ${{ steps.java_version.outputs.result }} | |
version_type: ${{ fromJson(steps.split_version.outputs.result).version_type }} | |
version_name: ${{ fromJson(steps.split_version.outputs.result).version_name }} | |
steps: | |
- uses: actions/github-script@v6 | |
id: split_version | |
env: | |
VERSION: ${{ inputs.version }} | |
with: | |
script: | | |
const version = process.env.VERSION.split("/"); | |
var returnValue = {version_name: version[version.length - 1], version_type: version[0]} | |
return returnValue; | |
- name: Create discord fields json | |
id: discord_fields | |
run: | | |
echo "discord_fields<<EOF" >> $GITHUB_OUTPUT | |
jq -n '[ | |
{ | |
"name": "Minecraft Version", | |
"value": $ENV.MC_VERSION, | |
"inline": true | |
} | |
]' >> $GITHUB_OUTPUT | |
echo "EOF" >> $GITHUB_OUTPUT | |
env: | |
MC_VERSION: ${{ fromJson(steps.split_version.outputs.result).version_name }} | |
- name: Notify discord of start | |
if: ${{ inputs.publish }} | |
uses: neoforged/action-webhooks@v1 | |
with: | |
webhook_url: ${{ secrets.DISCORD_WEBHOOK }} | |
status: started | |
include_commit_message: 'false' | |
fields: ${{ steps.discord_fields.outputs.discord_fields }} | |
- uses: actions/checkout@v4 | |
with: | |
ref: ${{ inputs.branch || '' }} | |
- uses: actions/cache/restore@v3 | |
name: Restore ${{ fromJson(steps.split_version.outputs.result).version_name }} cache | |
with: | |
path: | | |
build/versions/${{ fromJson(steps.split_version.outputs.result).version_name }}/** | |
versions/${{ inputs.version }}/build/download-task/** | |
key: version-${{ fromJson(steps.split_version.outputs.result).version_name }}- | |
- uses: actions/cache/restore@v3 | |
name: Restore Assets cache | |
with: | |
path: build/assets/** | |
key: minecraft-assets- | |
- uses: actions/cache/restore@v3 | |
name: Restore Libraries cache | |
with: | |
path: | | |
build/libraries/** | |
build/mc-libraries/** | |
key: minecraft-libraries- | |
- uses: actions/cache/restore@v3 | |
name: Restore Version Manifest cache | |
with: | |
path: build/versions/version_manifest.json | |
key: minecraft-version-manifest- | |
- uses: actions/cache/restore@v3 | |
name: Restore BuildSrc cache | |
with: | |
path: | | |
buildSrc/build/** | |
buildSrc/.gradle/** | |
key: buildsrc-build- | |
- uses: actions/cache/restore@v3 | |
name: Restore Other cache | |
with: | |
path: | | |
build/download-task/** | |
.gradle/** | |
key: gradle-other- | |
- run: | | |
git config --global user.name github-actions | |
git config --global user.email 41898282+github-actions[bot]@users.noreply.github.com | |
- name: Apply and Create patches | |
id: patches | |
uses: gradle/gradle-build-action@v2 | |
with: | |
arguments: :${{ fromJson(steps.split_version.outputs.result).version_name }}:projectApplyAll :${{ fromJson(steps.split_version.outputs.result).version_name }}:projectMakeAll -Ptype=${{ fromJson(steps.split_version.outputs.result).version_type }} | |
generate-job-summary: false | |
- name: Check if patches have changed | |
id: check_changes | |
if: ${{ inputs.push_changed }} | |
run: | | |
git add . | |
git diff-index --quiet HEAD || git commit -m "Update patches" && git push | |
- name: Make Zip | |
if: ${{ always() }} | |
uses: gradle/gradle-build-action@v2 | |
with: | |
arguments: :${{ fromJson(steps.split_version.outputs.result).version_name }}:makeZip -Ptype=${{ fromJson(steps.split_version.outputs.result).version_type }} | |
generate-job-summary: false | |
- name: Upload Zip as Artifact | |
if: ${{ always() }} | |
uses: actions/upload-artifact@v3 | |
with: | |
name: neoform-${{ fromJson(steps.split_version.outputs.result).version_name }} | |
path: build/distributions/*.zip | |
- name: Get Java Version | |
id: java_version | |
uses: actions/github-script@v6 | |
env: | |
VERSION: ${{ inputs.version }} | |
PATCHES_OUTCOME: ${{ steps.patches.outcome }} | |
with: | |
result-encoding: "string" | |
script: | | |
if (process.env.PATCHES_OUTCOME != 'success') { | |
return Number.MAX_SAFE_INTEGER; | |
} | |
const fs = require('fs'); | |
const config = JSON.parse(fs.readFileSync('versions/' + process.env.VERSION + '/config.json', 'utf8')) | |
return config.java_target; | |
- uses: actions/cache/save@v3 | |
name: Save ${{ fromJson(steps.split_version.outputs.result).version_name }} cache | |
with: | |
path: | | |
build/versions/${{ fromJson(steps.split_version.outputs.result).version_name }}/** | |
versions/${{ inputs.version }}/build/download-task/** | |
key: version-${{ fromJson(steps.split_version.outputs.result).version_name }}-${{ hashFiles(format('build/versions/{0}/**', fromJson(steps.split_version.outputs.result).version_name), format('versions/{0}/build/download-task/**', inputs.version))}} | |
- uses: actions/cache/save@v3 | |
name: Save Assets cache | |
with: | |
path: build/assets/** | |
key: minecraft-assets-${{ hashFiles('build/assets/**' )}} | |
- uses: actions/cache/save@v3 | |
name: Save Libraries cache | |
with: | |
path: | | |
build/libraries/** | |
build/mc-libraries/** | |
key: minecraft-libraries-${{ hashFiles('build/libraries/**')}} | |
- uses: actions/cache/save@v3 | |
name: Save Version Manifest cache | |
with: | |
path: build/versions/version_manifest.json | |
key: minecraft-version-manifest-${{ hashFiles('build/versions/version_manifest.json')}} | |
- uses: actions/cache/save@v3 | |
name: Save BuildSrc cache | |
with: | |
path: | | |
buildSrc/build/** | |
buildSrc/.gradle/** | |
key: buildsrc-build-${{ hashFiles('buildSrc/build/**', 'buildSrc/.gradle/**')}} | |
- uses: actions/cache/save@v3 | |
name: Save Other cache | |
with: | |
path: | | |
build/download-task/** | |
.gradle/** | |
key: gradle-other-${{ hashFiles('build/download-task/**', '.gradle/**')}} | |
testjdks: | |
name: Test Jdks on side ${{ matrix.side }} using mappings ${{ matrix.mappings }} using java version ${{ matrix.jdk_version }} | |
runs-on: ubuntu-latest | |
needs: common | |
strategy: | |
fail-fast: false | |
matrix: | |
jdk_version: [17, 18, 19, 20, 21] | |
mappings: [HotSpot] | |
side: [Client, Joined, Server] | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
ref: ${{ inputs.branch || '' }} | |
- uses: actions/cache/restore@v3 | |
name: Restore ${{ needs.common.outputs.version_name }} cache | |
with: | |
path: | | |
build/versions/${{ needs.common.outputs.version_name }}/** | |
versions/${{ inputs.version }}/build/download-task/** | |
key: version-${{ needs.common.outputs.version_name }}- | |
- uses: actions/cache/restore@v3 | |
name: Restore Assets cache | |
with: | |
path: build/assets/** | |
key: minecraft-assets- | |
- uses: actions/cache/restore@v3 | |
name: Restore Libraries cache | |
with: | |
path: | | |
build/libraries/** | |
build/mc-libraries/** | |
key: minecraft-libraries- | |
- uses: actions/cache/restore@v3 | |
name: Restore Version Manifest cache | |
with: | |
path: build/versions/version_manifest.json | |
key: minecraft-version-manifest- | |
- uses: actions/cache/restore@v3 | |
name: Restore BuildSrc cache | |
with: | |
path: | | |
buildSrc/build/** | |
buildSrc/.gradle/** | |
key: buildsrc-build- | |
- uses: actions/cache/restore@v3 | |
name: Restore Other cache | |
with: | |
path: | | |
build/download-task/** | |
.gradle/** | |
key: gradle-other- | |
- name: Test jdk | |
if: ${{ matrix.jdk_version >= needs.common.outputs.jdk_version}} | |
uses: gradle/gradle-build-action@v2 | |
with: | |
arguments: :${{ needs.common.outputs.version_name }}:testCompile${{ matrix.side }}${{ matrix.mappings }}${{ matrix.jdk_version }} :${{ needs.common.outputs.version_name }}:testDecompile${{ matrix.side }}${{ matrix.mappings }}${{ matrix.jdk_version }}Compare -Ptype=${{ needs.common.outputs.version_type }} | |
generate-job-summary: false | |
publish: | |
name: Publish to maven | |
runs-on: ubuntu-latest | |
needs: [common, testjdks] | |
outputs: | |
timestamp: ${{ env.GRADLE_TIMESTAMP }} | |
if: ${{ inputs.publish }} | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
ref: ${{ inputs.branch || '' }} | |
- name: Publish | |
uses: gradle/gradle-build-action@v2 | |
with: | |
arguments: getTimestamp :${{ needs.common.outputs.version_name }}:publish -Ptype=${{ needs.common.outputs.version_type }} | |
generate-job-summary: false | |
env: | |
ORG_GRADLE_PROJECT_MAVEN_URL: ${{ vars.MAVEN_URL }} | |
ORG_GRADLE_PROJECT_MAVEN_USER: ${{ secrets.MAVEN_USER }} | |
ORG_GRADLE_PROJECT_MAVEN_PASSWORD: ${{ secrets.MAVEN_PASSWORD }} | |
discord: | |
name: Send status to discord | |
runs-on: ubuntu-latest | |
needs: [common, testjdks, publish] | |
if: ${{ always() && inputs.publish }} | |
steps: | |
- name: Notify discord of finish | |
if: ${{ inputs.publish }} | |
uses: neoforged/action-webhooks@v1 | |
with: | |
webhook_url: ${{ secrets.DISCORD_WEBHOOK }} | |
status: ${{ needs.common.result == 'success' && needs.testjdks.result == 'success' && needs.publish.result || needs.common.result == 'success' && needs.testjdks.result || needs.common.result }} | |
include_commit_message: 'false' | |
version: ${{ needs.publish.result == 'success' && format('{0}-{1}', needs.common.outputs.version_name, needs.publish.outputs.timestamp) || '?' }} | |
fields: ${{ needs.common.outputs.discord_fields }} |