Skip to content

Check snapshot/1.20/23w42a #34

Check snapshot/1.20/23w42a

Check snapshot/1.20/23w42a #34

Workflow file for this run

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_embed: ${{ steps.discord_embed.outputs.discord_embed }}
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 embed json
id: discord_embed
run: |
echo "discord_embed<<EOF" >> $GITHUB_OUTPUT
jq -n '[
{
"author": {
"name": $ENV.REPO_NAME,
"url": $ENV.REPO_URL,
"icon_url": "https://avatars.githubusercontent.com/u/138629134"
},
"url": $ENV.RUN_URL,
"fields": [
{
"name": "Build Branch",
"value": $ENV.BRANCH,
"inline": true
},
{
"name": "Minecraft Version",
"value": $ENV.MC_VERSION,
"inline": true
}
]
}
]' >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
env:
REPO_NAME: ${{ github.event.repository.name }}
REPO_URL: ${{ github.server_url }}/${{ github.repository }}
RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
BRANCH: ${{ inputs.branch || github.ref_name }}
MC_VERSION: ${{ fromJson(steps.split_version.outputs.result).version_name }}
- name: Create start discord embed json
id: discord_embed_start
run: |
echo "discord_embed<<EOF" >> $GITHUB_OUTPUT
echo "$DISCORD_EMBED" | jq 'map(. + {"title": "Started", "color": 3224808})' >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
env:
DISCORD_EMBED: ${{ steps.discord_embed.outputs.discord_embed }}
- name: Notify discord of start
if: ${{ inputs.publish }}
uses: Ilshidur/[email protected]
env:
DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK_URL }}
DISCORD_USERNAME: GitHub Actions
DISCORD_AVATAR: https://github.githubassets.com/images/modules/logos_page/GitHub-Mark.png
DISCORD_EMBEDS: ${{ steps.discord_embed_start.outputs.discord_embed }}
- 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: Create finish discord embed json
id: discord_embed_finish
run: |
echo "discord_embed<<EOF" >> $GITHUB_OUTPUT
echo "$DISCORD_EMBED" | jq 'map(. + {"title": $ENV.RESULT, "color": $ENV.COLOR}) | map(.fields += if $ENV.VERSION != "false" then [{"name": "Version", "value": $ENV.VERSION}] else [] end)' >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
env:
RESULT: ${{ needs.common.result == 'success' && needs.testjdks.result == 'success' && needs.publish.result == 'success' && 'Success' || 'Failed' }}
COLOR: ${{ needs.common.result == 'success' && needs.testjdks.result == 'success' && needs.publish.result == 'success' && 0x28F65A || 0xF53B27 }}
VERSION: ${{ needs.publish.result == 'success' && format('{0}-{1}', needs.common.outputs.version_name, needs.publish.outputs.timestamp) }}
DISCORD_EMBED: ${{ needs.common.outputs.discord_embed }}
- name: Notify discord of finish
uses: Ilshidur/[email protected]
env:
DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK_URL }}
DISCORD_USERNAME: GitHub Actions
DISCORD_AVATAR: https://github.githubassets.com/images/modules/logos_page/GitHub-Mark.png
DISCORD_EMBEDS: ${{ steps.discord_embed_finish.outputs.discord_embed }}