MONOREPO
This commit is contained in:
+2
@@ -0,0 +1,2 @@
|
||||
# These are supported funding model platforms
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
---
|
||||
name: Blank Issue
|
||||
about: Open a new issue
|
||||
---
|
||||
@@ -0,0 +1,14 @@
|
||||
---
|
||||
name: New Version
|
||||
about: Add a new minecraft version to MCD
|
||||
title: 'Add version: '
|
||||
---
|
||||
|
||||
- [ ] Version folder containing "version.json" created
|
||||
- [ ] "version.json" filled out appropriately
|
||||
- [ ] Added version to dataPath.json
|
||||
- [ ] "version" field of dataPath.json points to new version folder
|
||||
- [ ] Version added to common/versions.json
|
||||
- [ ] Version added to ReadMe
|
||||
|
||||
Additional Requirements For This Update:
|
||||
@@ -0,0 +1,93 @@
|
||||
PrismarineJS/minecraft-data holds Minecraft data including game versions, protocol schemas, block/item/entity states, and more. It provides a comprehensive cross-language set of data files combined with schemas that can be consumed in any language.
|
||||
|
||||
## Directory Structure
|
||||
- `.github/`
|
||||
- `workflows/`
|
||||
- `ci.yml` -- Runs CI here (cd tools/js && npm install && npm test)
|
||||
- `bedrock-ci.yml` -- Runs CI for Bedrock Edition via workflow dispatch to PrismarineJS/bedrock-protocol. This allows for testing and validation of Bedrock-specific changes.
|
||||
- `commands.yml` -- Slash commands
|
||||
- `handleMcpcGeneratedArtifacts.js`
|
||||
- `helper-bot/` -- Files for the GitHub Actions cron helper.
|
||||
- `data/`
|
||||
- `dataPaths.json` -- map of { ['pc' | 'bedrock']: { '$version': { 'dataType': 'folderPath' } } }
|
||||
- `[pc | bedrock]/` -- Minecraft Java Edition data
|
||||
- `1.20/` -- Versioned data for Minecraft Java Edition 1.20
|
||||
- `$version/` -- Versioned data for Minecraft Java Edition $version
|
||||
- `common/` -- Common data for all Minecraft Java Edition versions
|
||||
- `protocolVersions.json` -- List of protocol versions for Minecraft Java Edition
|
||||
- `latest/` -- This holds the latest protocol yaml files. They are used to generate the protocol.json files in each versioned folder (more on this below).
|
||||
- `schemas/` -- JSON schemas for validating data files
|
||||
- `tools/js` -- JavaScript utilities for working with repo (holds tests, some data generators and helper scripts)
|
||||
|
||||
## Setup
|
||||
No setup is needed as we just hold data. To set up the development environment that runs tests, run the following commands:
|
||||
|
||||
```bash
|
||||
cd tools/js
|
||||
npm install
|
||||
```
|
||||
|
||||
This will ensure all data matches schema among other checks.
|
||||
|
||||
There are no 'releases' in this repo beyond updating the data itself. Instead, we have a workflow that will automatically create tagged releases if the user runs the /makerelease slash command, so you can inform the user about that if a release is needed.
|
||||
|
||||
## Testing
|
||||
Always run tests after data changes to ensure local tests are passing:
|
||||
|
||||
```sh
|
||||
cd tools/js
|
||||
npm install
|
||||
npm test -- --bail 2>&1 | tail -100
|
||||
```
|
||||
|
||||
## Data
|
||||
|
||||
Most data is generated with data generators. For mcpc, data is generated with [minecraft-data-generator](https://github.com/PrismarineJS/minecraft-data-generator).
|
||||
|
||||
Avoid updating data manually unless necessary, like when specific data is not automated yet (for tips on what is and not, see doc/add-data-new-version.md). Instead, update the data generators or add new ones as needed. Since you don't have capability to make changes outside this repo, please inform the user what changes need to be made and be as detailed as possible.
|
||||
|
||||
Note we do not currently have any automation setup to generate bedrock edition data.
|
||||
|
||||
## Github Workflows
|
||||
|
||||
### Automation
|
||||
|
||||
Our GH Actions workflow (.github/helper-bot) auto updates the pc protocolVersions.json with new detected versions and also auto opens a scaffolding PR.
|
||||
|
||||
cron workflow .github/workflows/update-helper.yml -> .github/helper-bot/.
|
||||
|
||||
helper-bot dispatches to minecraft-data-generator so that it can run data generators for new versions. minecraft-data-generator then sends a workflow dispatch back to us so we can then take its generated artifacts and commit them here.
|
||||
|
||||
.github/workflows/handle-mcpc-generator.yml ->
|
||||
.github/helper-bot/handleMcpcGeneratedArtifacts.js
|
||||
|
||||
## Notes
|
||||
Not all data is generated. Some data (like protocol schemas) is manually curated on both pc and bedrock.
|
||||
|
||||
### Protocol data
|
||||
|
||||
We use a special YAML-like DSL to generate protocol.json files. Refer to doc/protocol.md for info.
|
||||
These files are stored inside proto.yml (and an imported types.yml support file on bedrock) files in the latest/ folder (like bedrock/latest/proto.yml) for the latest version, otherwise in the versioned folder (like pc/1.20/proto.yml).
|
||||
|
||||
👉 Run `npm run build` in tools/js to regenerate protocol.json files after making changes to the protocol yaml files.
|
||||
|
||||
❌ Don't make changes to protocol.json files directly. Instead, update the relevant proto.yml file in latest/ and regenerate protocol.json by running `npm run build` in tools/js.
|
||||
|
||||
If you need to edit many files at once, consider writing a simple Node.js script to replace. E.g., from `cd tools/js && npm i && node __replace_something.js`):
|
||||
```js
|
||||
const cp = require('child_process')
|
||||
const fs = require('fs')
|
||||
const glob = require('glob')
|
||||
const pcVersionsOrdered = require('../../data/pc/common/versions.json')
|
||||
const after1_20_5 = pcVersionsOrdered.slice(pcVersionsOrdered.indexOf('1.20.5')) // everything after 1.20.5...
|
||||
for (const version of pcVersionsOrdered) {
|
||||
// globSync, fs.readFileSync...fs.writeFileSync ; avoid async
|
||||
}
|
||||
```
|
||||
|
||||
When updating, apply minimum required changes when possible.
|
||||
|
||||
1. Do not rename fields or packets unless their value has changed, even if they may have 'officially' changed. If their values *have* significantly changed (varint -> i32 maybe insignificant from primitive standpoint, string to number is), it maybe a good idea to rename the field or packet.
|
||||
2. Do not rename existing enums or other data, even if they were renamed in the game. You may add or remove data as is needed as this does not unnecessarily affect existing code relying on old names.
|
||||
3. Always read the information in doc/protocol.md to understand our YAML format.
|
||||
4. Try to inline types as much as possible--this includes mappers and switch statements. Don't create extra types unless they are actually re-used in multiple places, or very large to warrant seperation.
|
||||
@@ -0,0 +1,113 @@
|
||||
const fs = require('fs')
|
||||
const github = require('gh-helpers')()
|
||||
const { join } = require('path')
|
||||
const { extractPcEntityMetadata } = require('../../tools/js/extractPcEntityMetadata')
|
||||
const { exec, createInitialPR } = require('./utils')
|
||||
|
||||
const artifactsDir = join(__dirname, './artifacts')
|
||||
const root = join(__dirname, '..', '..')
|
||||
|
||||
async function handle (ourPR, genPullNo, version, artifactURL, shouldPull) {
|
||||
const branchNameVersion = version.replace(/[^a-zA-Z0-9]/g, '_').toLowerCase()
|
||||
const branch = ourPR.headBranch || `pc-${branchNameVersion}`
|
||||
if (shouldPull) exec('git', ['pull', 'origin'])
|
||||
|
||||
// if external PR:
|
||||
// const branch = ourPR.headBranch
|
||||
// exec('git', ['remote', 'add', 'fo', ourPR.headCloneURL])
|
||||
// exec('git', ['fetch', 'fo', branch])
|
||||
// exec('git', ['checkout', '-b', branch, `fo/` + branch])
|
||||
|
||||
try {
|
||||
exec('git', ['checkout', branch])
|
||||
} catch (err) {
|
||||
console.error('Error checking out branch:', err)
|
||||
process.exit(1)
|
||||
}
|
||||
|
||||
const dataPaths = require('../../data/dataPaths.json')
|
||||
const dataPath = dataPaths.pc[version]
|
||||
|
||||
const destDir = join(root, `./data/pc/${version}`)
|
||||
if (!fs.existsSync(destDir) || !dataPath) {
|
||||
console.warn(`⚠️ Version ${version} not found (checked ${destDir}) ; cannot continue.`, fs.existsSync(destDir), dataPath)
|
||||
process.exit(1)
|
||||
}
|
||||
|
||||
if (ourPR.body) {
|
||||
await github.updateIssue(ourPR.number, {
|
||||
body: ourPR.body.replace('<!--minecraft-data-generator-placeholder-->', `- https://github.com/PrismarineJS/minecraft-data-generator/pull/${genPullNo}`)
|
||||
})
|
||||
}
|
||||
|
||||
console.log('Handling PR:', ourPR)
|
||||
|
||||
fs.mkdirSync(artifactsDir, { recursive: true })
|
||||
|
||||
// https://github.com/PrismarineJS/minecraft-data-generator/actions/runs/17261281146/artifacts/3861320839
|
||||
const s = artifactURL.split('github.com/')[1]
|
||||
const [ownerName, repoName, _actions, _runs, _runId, _artifacts, artifactId] = s.split('/') // eslint-disable-line
|
||||
console.log('Downloading artifacts', { ownerName, repoName, artifactId, artifactsDir })
|
||||
await github.artifacts.downloadIdFrom(ownerName, repoName, artifactId, artifactsDir)
|
||||
|
||||
console.log(fs.readdirSync(artifactsDir))
|
||||
|
||||
// Now copy artifacts/${version}/*.json to data/pc/$version/*.json
|
||||
const versionArtifactsDir = join(artifactsDir, version)
|
||||
for (const file of fs.readdirSync(versionArtifactsDir)) {
|
||||
if (file.endsWith('.json')) {
|
||||
const src = join(versionArtifactsDir, file)
|
||||
const dest = join(destDir, file)
|
||||
fs.mkdirSync(destDir, { recursive: true })
|
||||
console.log(`copy ${src} => ${dest}`)
|
||||
fs.copyFileSync(src, dest)
|
||||
dataPath[file.replace('.json', '')] = 'pc/' + version
|
||||
}
|
||||
}
|
||||
|
||||
// Commit the new dataPath
|
||||
fs.writeFileSync(join(root, 'data', 'dataPaths.json'), JSON.stringify(dataPaths, null, 2))
|
||||
|
||||
try {
|
||||
process.chdir(join(__dirname, '../../tools/js'))
|
||||
extractPcEntityMetadata(version, version, { write: true, cloneIfMissing: true })
|
||||
} catch (e) {
|
||||
console.log('Failed to extract PC entity metadata', e)
|
||||
}
|
||||
|
||||
// Now, we need to commit the changes
|
||||
exec('git', ['config', 'user.name', 'github-actions[bot]'])
|
||||
exec('git', ['config', 'user.email', '41898282+github-actions[bot]@users.noreply.github.com'])
|
||||
exec('git', ['add', '--all'])
|
||||
exec('git', ['commit', '-m', `[Auto] Apply generated data from PrismarineJS/minecraft-data-generator#${genPullNo}`])
|
||||
exec('git', ['push', 'origin', branch])
|
||||
}
|
||||
|
||||
async function main (versions, genPullNo, artifactUrl, createPR) {
|
||||
const version = versions.at(-1)
|
||||
const pr = await github.findPullRequest({ titleIncludes: '🎈', author: null })
|
||||
console.log('Found PR', pr)
|
||||
if (pr && pr.isOpen) {
|
||||
const details = await github.getPullRequest(pr.id)
|
||||
console.log('PR', details)
|
||||
await handle(details, genPullNo, version, artifactUrl, true)
|
||||
} else if (createPR) {
|
||||
const pr = await createInitialPR('pc', '(This issue was created for a minecraft-data-generator PR)', {
|
||||
version,
|
||||
protocolVersion: null
|
||||
})
|
||||
console.log('Created PR', pr)
|
||||
const details = await github.getPullRequest(pr.number)
|
||||
console.log('PR', details)
|
||||
await handle(details, genPullNo, version, artifactUrl, false)
|
||||
} else {
|
||||
process.exit(1)
|
||||
}
|
||||
}
|
||||
|
||||
main(
|
||||
JSON.parse(process.env.TRIGGER_MC_VERSIONS),
|
||||
process.env.TRIGGER_PR_NO,
|
||||
process.env.TRIGGER_ARTIFACT_URL,
|
||||
process.env.CREATE_PR_IF_NONE
|
||||
)
|
||||
+214
@@ -0,0 +1,214 @@
|
||||
/* eslint-disable no-return-assign, no-sequences */
|
||||
const fs = require('fs')
|
||||
const github = require('gh-helpers')()
|
||||
const pcManifestURL = 'https://launchermeta.mojang.com/mc/game/version_manifest.json'
|
||||
const changelogURL = 'https://feedback.minecraft.net/hc/en-us/sections/360001186971-Release-Changelogs'
|
||||
const { exec, createInitialPR } = require('./utils')
|
||||
|
||||
const download = (url, dest) => exec('curl', ['-L', url, '-o', dest])
|
||||
|
||||
function buildFirstIssue (title, result, jarData) {
|
||||
const protocolVersion = jarData?.protocol_version || 'Failed to obtain from JAR'
|
||||
const name = jarData?.name || result.id
|
||||
const date = result.releaseTime
|
||||
|
||||
return {
|
||||
title,
|
||||
body: `
|
||||
A new Minecraft Java Edition version is available (as of ${date}), version **${result.id}**
|
||||
## Official Changelog
|
||||
* ${changelogURL}
|
||||
## Protocol Details
|
||||
(I will close this issue automatically if "${result.id}" is added to data/pc/common/versions.json on "master")
|
||||
<table>
|
||||
<tr><td><b>Name</b></td><td>${name}</td>
|
||||
<tr><td><b>Protocol ID</b></td><td>${protocolVersion}</td>
|
||||
<tr><td><b>Release Date</b></td><td>${date}</td>
|
||||
<tr><td><b>Release Type</b></td><td>${result.type}</td>
|
||||
<tr><td><b>Data Version</b></td><td>${jarData?.world_version}</td>
|
||||
<tr><td><b>Java Version</b></td><td>${jarData?.java_version}</td>
|
||||
</table>
|
||||
|
||||
<hr/>
|
||||
🤖 I am a bot, I check for updates every 2 hours without a trigger. You can close this issue to prevent any further updates.
|
||||
`
|
||||
}
|
||||
}
|
||||
|
||||
const protocolVersions = {
|
||||
pc: require('../../data/pc/common/protocolVersions.json'),
|
||||
bedrock: require('../../data/bedrock/common/protocolVersions.json')
|
||||
}
|
||||
const supportedVersions = {
|
||||
pc: require('../../data/pc/common/versions.json'),
|
||||
bedrock: require('../../data/bedrock/common/versions.json')
|
||||
}
|
||||
|
||||
async function updateManifestPC () {
|
||||
const manifest = await fetch(pcManifestURL).then(res => res.json())
|
||||
// fs.writeFileSync('./manifest.json', JSON.stringify(manifest, null, 2))
|
||||
const knownVersions = protocolVersions.pc.reduce((acc, cur) => (acc[cur.minecraftVersion] = cur, acc), {})
|
||||
const latestVersion = manifest.latest.snapshot
|
||||
const latestReleaseVersion = manifest.latest.release
|
||||
const latestVersionData = manifest.versions.find(v => v.id === latestVersion)
|
||||
const latestVersionIsSnapshot = latestVersionData.type !== 'release'
|
||||
|
||||
const title = `Support Minecraft PC ${latestReleaseVersion}`
|
||||
const issueStatus = await github.findIssue({ titleIncludes: title, author: null }) || {}
|
||||
console.log('issueStatus', issueStatus)
|
||||
|
||||
if (issueStatus?.isOpen) {
|
||||
if (supportedVersions.pc.includes(latestReleaseVersion)) {
|
||||
// If the issue is open and the latest release version is supported, we can close the issue
|
||||
github.close(issueStatus.id, `Closing as PC ${latestReleaseVersion} is now supported`)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
if (latestVersionIsSnapshot) {
|
||||
// don't make issues for snapshots
|
||||
if (supportedVersions.pc.includes(latestVersion) || knownVersions[latestVersion]) {
|
||||
console.log('Latest version is a known snapshot, no work to do')
|
||||
return
|
||||
}
|
||||
} else if (knownVersions[latestVersion]) {
|
||||
console.log(`Latest PC version ${latestVersion} is known in protocolVersions.json, but not in versions.json (protocol version ${knownVersions[latestVersion].version})`)
|
||||
return // We expect to have already handled this version.
|
||||
} else {
|
||||
console.log(`Latest PC version ${latestVersion} is not known in protocolVersions.json, adding and making issue`)
|
||||
}
|
||||
|
||||
let versionJson
|
||||
try {
|
||||
versionJson = await addEntryFor(latestVersion, latestVersionData)
|
||||
} catch (e) {
|
||||
console.error(e)
|
||||
|
||||
if (latestVersionIsSnapshot) {
|
||||
console.warn('Failed to update protocolVersions.json for the snapshot', latestVersion)
|
||||
} else {
|
||||
console.log('Latest PC version is not supported and we failed to load data. Opening issue...')
|
||||
const issuePayload = buildFirstIssue(title, latestVersionData)
|
||||
github.createIssue(issuePayload)
|
||||
|
||||
fs.writeFileSync('./issue.md', issuePayload.body)
|
||||
console.log('OK, wrote to ./issue.md', issuePayload)
|
||||
}
|
||||
}
|
||||
|
||||
if (!latestVersionIsSnapshot && !issueStatus.isOpen && !issueStatus.isClosed) {
|
||||
await openIssueAndDispatch(title, versionJson, latestVersionData, latestVersion)
|
||||
}
|
||||
|
||||
async function addEntryFor (releaseVersion, releaseData) {
|
||||
const latestReleaseManifest = await fetch(releaseData.url).then(res => res.json())
|
||||
// Download client jar
|
||||
if (!fs.existsSync(`./${releaseVersion}.jar`)) {
|
||||
const clientJarUrl = latestReleaseManifest.downloads.client.url
|
||||
console.log('Downloading client jar', clientJarUrl)
|
||||
download(clientJarUrl, `./${releaseVersion}.jar`)
|
||||
}
|
||||
|
||||
// Log the byte size of the client jar
|
||||
const clientJarSize = fs.statSync(`./${releaseVersion}.jar`).size
|
||||
console.log(`Downloaded client jar ${releaseVersion}.jar (${clientJarSize} bytes), extracting its version.json...`)
|
||||
|
||||
// unzip with tar / unzip, Actions image uses 7z
|
||||
if (process.platform === 'win32') exec('tar', ['-xf', `./${releaseVersion}.jar`, 'version.json'])
|
||||
else exec('7z', ['-y', 'e', `./${releaseVersion}.jar`, 'version.json'])
|
||||
const versionJson = require('./version.json')
|
||||
|
||||
let majorVersion
|
||||
if (versionJson.id && versionJson.id.includes('.')) {
|
||||
majorVersion = versionJson.id.split('.', 2).join('.')
|
||||
} else {
|
||||
console.error(`Version '${versionJson.id}' appears to be a snapshot (no dot in name). Using the last known majorVersion in protocolVersions.json for this version (may be incorrect)`)
|
||||
majorVersion = protocolVersions.pc[0].majorVersion
|
||||
}
|
||||
|
||||
const newEntry = {
|
||||
minecraftVersion: versionJson.id,
|
||||
version: versionJson.protocol_version,
|
||||
dataVersion: versionJson.world_version,
|
||||
usesNetty: true,
|
||||
majorVersion,
|
||||
releaseType: latestVersionData.type
|
||||
}
|
||||
console.log('Adding new entry to pc protocolVersions.json', newEntry)
|
||||
const updatedProtocolVersions = [newEntry, ...protocolVersions.pc]
|
||||
fs.writeFileSync('../../data/pc/common/protocolVersions.json', JSON.stringify(updatedProtocolVersions, null, 2))
|
||||
|
||||
if (process.env.CI) {
|
||||
console.log('Committing changes to protocolVersions.json')
|
||||
// https://github.com/actions/checkout/pull/1184
|
||||
exec('git', ['config', 'user.name', 'github-actions[bot]'])
|
||||
exec('git', ['config', 'user.email', '41898282+github-actions[bot]@users.noreply.github.com'])
|
||||
exec('git', ['add', '../../data/pc/common/protocolVersions.json'])
|
||||
exec('git', ['commit', '-m', `Add ${versionJson.id} to pc protocolVersions.json`])
|
||||
exec('git', ['push'])
|
||||
}
|
||||
|
||||
return versionJson
|
||||
}
|
||||
}
|
||||
|
||||
async function openIssueAndDispatch (title, versionJson, latestVersionData, latestVersion) {
|
||||
console.log('Opening issue', versionJson)
|
||||
const issuePayload = buildFirstIssue(title, latestVersionData, versionJson)
|
||||
|
||||
const issue = await github.createIssue(issuePayload)
|
||||
console.log('Created issue', issue)
|
||||
|
||||
// Now create an initial PR with the new version data
|
||||
const pr = await createInitialPR('pc', issue.url, {
|
||||
minecraftVersion: versionJson.id,
|
||||
version: latestVersion,
|
||||
protocolVersion: versionJson.protocol_version
|
||||
})
|
||||
console.log('Created PR', pr)
|
||||
// Ask minecraft-data-generator to handle new update
|
||||
const dispatchPayload = {
|
||||
owner: 'PrismarineJS',
|
||||
repo: 'minecraft-data-generator',
|
||||
workflow: 'handle-mcdata-update.yml',
|
||||
branch: 'main',
|
||||
inputs: {
|
||||
version: latestVersion,
|
||||
issue_number: String(issue?.number),
|
||||
pr_number: String(pr?.number)
|
||||
}
|
||||
}
|
||||
console.log('Sending workflow dispatch', dispatchPayload)
|
||||
await github.sendWorkflowDispatch(dispatchPayload)
|
||||
// Ask node-minecraft-protocol to handle new update
|
||||
const nodeDispatchPayload = {
|
||||
owner: 'PrismarineJS',
|
||||
repo: 'node-minecraft-protocol',
|
||||
workflow: 'update-from-minecraft-data.yml',
|
||||
branch: 'master',
|
||||
inputs: {
|
||||
new_mc_version: latestVersion,
|
||||
mcdata_branch: pr.branchName,
|
||||
mcdata_pr_url: pr.url
|
||||
}
|
||||
}
|
||||
console.log('Sending workflow dispatch', nodeDispatchPayload)
|
||||
await github.sendWorkflowDispatch(nodeDispatchPayload)
|
||||
// node-minecraft-protocol would then dispatch to mineflayer
|
||||
|
||||
return { issue, pr }
|
||||
}
|
||||
|
||||
if (process.env.FORCE_CREATE_PR) {
|
||||
const payload = JSON.parse(process.env.FORCE_CREATE_PR)
|
||||
openIssueAndDispatch(payload.title, payload.versionJson, payload.latestVersionData, payload.latestVersion).then(() => {
|
||||
console.log('Done with manual PR')
|
||||
}).catch(err => {
|
||||
console.error('Failed to do manual PR', err)
|
||||
process.exit(1)
|
||||
})
|
||||
} else {
|
||||
updateManifestPC()
|
||||
}
|
||||
|
||||
module.exports = { openIssueAndDispatch, updateManifestPC }
|
||||
@@ -0,0 +1,11 @@
|
||||
{
|
||||
"scripts": {
|
||||
"fix": "standard --fix"
|
||||
},
|
||||
"dependencies": {
|
||||
"gh-helpers": "^1.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"standard": "^17.1.2"
|
||||
}
|
||||
}
|
||||
+50
@@ -0,0 +1,50 @@
|
||||
const cp = require('child_process')
|
||||
const github = require('gh-helpers')()
|
||||
const path = require('path')
|
||||
|
||||
const pm = process.versions.bun ? process.execPath : 'npm'
|
||||
|
||||
function exec (file, args = [], options = {}) {
|
||||
const opts = { stdio: ['inherit', 'inherit', 'inherit'], ...options }
|
||||
console.log('> ', file, args.join(' '), options.cwd ? `(cwd: ${options.cwd})` : '')
|
||||
return github.mock ? undefined : cp.execFileSync(file, args, opts)
|
||||
}
|
||||
|
||||
const toolsJs = path.join(__dirname, '..', '..', 'tools', 'js')
|
||||
const sanitizeBranch = (branchName) => branchName.replace(/[^a-zA-Z0-9]/g, '_').toLowerCase()
|
||||
|
||||
async function createInitialPR (edition, issueUrl, { version, protocolVersion }) {
|
||||
exec(pm, ['install'], { cwd: toolsJs })
|
||||
if (protocolVersion) exec(pm, ['run', 'version', edition, version, protocolVersion], { cwd: toolsJs })
|
||||
exec(pm, ['run', 'build'], { cwd: toolsJs })
|
||||
const branchNameVersion = sanitizeBranch(version)
|
||||
const branchName = `${edition}_${branchNameVersion}`
|
||||
const title = `🎈 Add Minecraft ${edition} ${version} data`
|
||||
// First, delete any existing branch
|
||||
try {
|
||||
exec('git', ['branch', '-D', branchName])
|
||||
} catch (e) {
|
||||
// Branch doesn't exist, ignore error
|
||||
}
|
||||
exec('git', ['checkout', '-b', branchName])
|
||||
exec('git', ['config', 'user.name', 'github-actions[bot]'])
|
||||
exec('git', ['config', 'user.email', '41898282+github-actions[bot]@users.noreply.github.com'])
|
||||
exec('git', ['add', '--all'])
|
||||
exec('git', ['commit', '--allow-empty', '-m', title])
|
||||
exec('git', ['push', 'origin', branchName, '--force'])
|
||||
const body = `
|
||||
This automated PR sets up the relevant boilerplate for Minecraft ${edition} version ${version}. Fixes ${issueUrl}.
|
||||
|
||||
Related:
|
||||
- Issue: ${issueUrl}
|
||||
- Protocol Version: ${protocolVersion}
|
||||
<!--minecraft-data-generator-placeholder-->
|
||||
|
||||
* You can help contribute to this PR by opening a PR against this <code branch>${branchName}</code> branch instead of <code>master</code>.
|
||||
`
|
||||
const pr = await github.createPullRequest(title, body, branchName, 'master')
|
||||
pr.branchName = branchName
|
||||
return pr
|
||||
}
|
||||
|
||||
module.exports = { createInitialPR, exec }
|
||||
@@ -0,0 +1,59 @@
|
||||
name: bedrock-ci
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ master ]
|
||||
pull_request:
|
||||
branches: [ master ]
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 14
|
||||
|
||||
steps:
|
||||
- name: Use Node.js 22.x
|
||||
uses: actions/setup-node@v1
|
||||
with:
|
||||
node-version: 22.x
|
||||
# Old versions of bedrock use old libssl that Ubuntu no longer ships with; need manual install
|
||||
- name: Install libssl 1.1
|
||||
run: |
|
||||
wget http://archive.ubuntu.com/ubuntu/pool/main/o/openssl/libssl1.1_1.1.1f-1ubuntu2_amd64.deb
|
||||
sudo dpkg -i libssl1.1_1.1.1f-1ubuntu2_amd64.deb
|
||||
- name: Checkout node-minecraft-data
|
||||
uses: actions/checkout@v2
|
||||
with:
|
||||
repository: PrismarineJS/node-minecraft-data
|
||||
submodules: recursive
|
||||
path: node-mcdata
|
||||
# Erase the submodule for minecraft-data with a checkout of the current minecraft-data repo
|
||||
- run: rm -rf node-mcdata/minecraft-data
|
||||
- name: Checkout minecraft-data
|
||||
uses: actions/checkout@v2
|
||||
with:
|
||||
path: node-mcdata/minecraft-data
|
||||
# Now install local node-minecraft-data. Running "prepare" should gen data and types
|
||||
- name: Install minecraft-data
|
||||
run: |
|
||||
cd node-mcdata
|
||||
npm install
|
||||
npm run prepare
|
||||
npm link
|
||||
- name: Checkout bedrock-protocol
|
||||
uses: actions/checkout@v2
|
||||
with:
|
||||
repository: PrismarineJS/bedrock-protocol
|
||||
path: bedrock-protocol
|
||||
# I forget the correct install order, do both
|
||||
- name: Install bedrock-protocol
|
||||
run: |
|
||||
cd bedrock-protocol
|
||||
npm install ../node-mcdata
|
||||
npm i
|
||||
npm install ../node-mcdata
|
||||
- name: Running bedrock-protocol tests
|
||||
run: |
|
||||
curl -o node_modules/protodef/src/serializer.js https://raw.githubusercontent.com/extremeheat/node-protodef/refs/heads/dlog/src/serializer.js && curl -o node_modules/protodef/src/compiler.js https://raw.githubusercontent.com/extremeheat/node-protodef/refs/heads/dlog/src/compiler.js
|
||||
npm test
|
||||
working-directory: bedrock-protocol
|
||||
@@ -0,0 +1,92 @@
|
||||
name: Bedrock Version Bump
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
minecraftVersion:
|
||||
description: 'Bedrock Minecraft version (e.g., 1.21.124)'
|
||||
required: true
|
||||
type: string
|
||||
protocolVersion:
|
||||
description: 'Protocol version number (e.g., 860)'
|
||||
required: true
|
||||
type: string
|
||||
createPr:
|
||||
description: 'Create a pull request with the changes'
|
||||
required: false
|
||||
type: boolean
|
||||
default: true
|
||||
|
||||
jobs:
|
||||
bump-bedrock-version:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
token: ${{ secrets.PAT_PASSWORD || secrets.GITHUB_TOKEN }}
|
||||
|
||||
- name: Set up Node.js
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: 22
|
||||
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
cd tools/js
|
||||
npm install
|
||||
|
||||
- name: Run version bump script
|
||||
run: |
|
||||
cd tools/js
|
||||
npm run version bedrock ${{ github.event.inputs.minecraftVersion }} ${{ github.event.inputs.protocolVersion }}
|
||||
|
||||
- name: Build protocol files
|
||||
run: |
|
||||
cd tools/js
|
||||
npm run build
|
||||
|
||||
- name: Run tests
|
||||
run: |
|
||||
cd tools/js
|
||||
npm test
|
||||
|
||||
- name: Create Pull Request
|
||||
if: ${{ github.event.inputs.createPr == 'true' }}
|
||||
uses: peter-evans/create-pull-request@v6
|
||||
with:
|
||||
token: ${{ secrets.PAT_PASSWORD || secrets.GITHUB_TOKEN }}
|
||||
commit-message: |
|
||||
Add bedrock ${{ github.event.inputs.minecraftVersion }} protocol data
|
||||
|
||||
Updates:
|
||||
- Protocol version → ${{ github.event.inputs.protocolVersion }}
|
||||
- Minecraft version → ${{ github.event.inputs.minecraftVersion }}
|
||||
- Moved previous proto.yml to versioned folder
|
||||
- Updated protocolVersions.json, versions.json, and dataPaths.json
|
||||
- Regenerated protocol.json files
|
||||
branch: bedrock-bump-${{ github.event.inputs.minecraftVersion }}
|
||||
delete-branch: true
|
||||
title: Add bedrock ${{ github.event.inputs.minecraftVersion }} data
|
||||
body: |
|
||||
## Bedrock Version Bump
|
||||
|
||||
This PR adds support for Minecraft Bedrock Edition version **${{ github.event.inputs.minecraftVersion }}** with protocol version **${{ github.event.inputs.protocolVersion }}**.
|
||||
|
||||
### Changes
|
||||
- ✅ Protocol version bumped to ${{ github.event.inputs.protocolVersion }}
|
||||
- ✅ Minecraft version updated to ${{ github.event.inputs.minecraftVersion }}
|
||||
- ✅ Previous proto.yml files moved to versioned folder
|
||||
- ✅ Updated protocolVersions.json and versions.json
|
||||
- ✅ Regenerated all protocol.json files
|
||||
- ✅ All tests passing
|
||||
|
||||
### How this was generated
|
||||
This PR was automatically generated using the bedrock version bump workflow.
|
||||
|
||||
---
|
||||
🤖 Generated by GitHub Actions workflow
|
||||
labels: |
|
||||
bedrock
|
||||
version-bump
|
||||
automated
|
||||
@@ -0,0 +1,22 @@
|
||||
name: Repository Dispatch
|
||||
on:
|
||||
repository_dispatch:
|
||||
types: [node-mcData-release]
|
||||
jobs:
|
||||
myEvent:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
with:
|
||||
fetch-depth: 0
|
||||
ref: web
|
||||
- name: Use Node.js 22.x
|
||||
uses: actions/setup-node@v1
|
||||
with:
|
||||
node-version: 22.x
|
||||
- name: Run tool
|
||||
run: |
|
||||
npm install
|
||||
git config user.name 'rom1504bot'
|
||||
git config user.email 'rom1504bot@users.noreply.github.com'
|
||||
npm run gh-publish
|
||||
+27
@@ -0,0 +1,27 @@
|
||||
name: CI
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ master ]
|
||||
pull_request:
|
||||
branches: [ master ]
|
||||
|
||||
jobs:
|
||||
build:
|
||||
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
strategy:
|
||||
matrix:
|
||||
node-version: [22.x]
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: Use Node.js ${{ matrix.node-version }}
|
||||
uses: actions/setup-node@v1
|
||||
with:
|
||||
node-version: ${{ matrix.node-version }}
|
||||
- run: npm install
|
||||
working-directory: tools/js
|
||||
- run: npm test
|
||||
working-directory: tools/js
|
||||
@@ -0,0 +1,22 @@
|
||||
name: Repo Commands
|
||||
|
||||
on:
|
||||
issue_comment: # Handle comment commands
|
||||
types: [created]
|
||||
pull_request: # Handle renamed PRs
|
||||
types: [edited]
|
||||
|
||||
jobs:
|
||||
comment-trigger:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Check out repository
|
||||
uses: actions/checkout@v3
|
||||
- name: Run command handlers
|
||||
uses: PrismarineJS/prismarine-repo-actions@master
|
||||
with:
|
||||
# NOTE: You must specify a Personal Access Token (PAT) with repo access here. While you can use the default GITHUB_TOKEN, actions taken with it will not trigger other actions, so if you have a CI workflow, commits created by this action will not trigger it.
|
||||
token: ${{ secrets.PAT_PASSWORD }}
|
||||
# See `Options` section below for more info on these options
|
||||
install-command: cd tools/js && npm install
|
||||
/fixlint.fix-command: cd tools/js && npm run fix
|
||||
@@ -0,0 +1,39 @@
|
||||
name: handle-mcpc-generator
|
||||
on:
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
versions:
|
||||
description: 'JSON stringified list of known versions in generator (last is expected to be latest)'
|
||||
required: true
|
||||
default: '["1.21.6"]'
|
||||
mergedArtifactURL:
|
||||
description: 'Merged artifact download URL'
|
||||
required: true
|
||||
prNumber:
|
||||
description: 'Relevant minecraft-data-generator PR #'
|
||||
required: false
|
||||
createPr:
|
||||
description: 'Whether to create a new PR if none exists'
|
||||
required: false
|
||||
default: 'false'
|
||||
|
||||
jobs:
|
||||
update-mcdata:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
submodules: true
|
||||
- uses: oven-sh/setup-bun@v2
|
||||
with:
|
||||
bun-version: latest
|
||||
- run: cd .github/helper-bot && bun install
|
||||
- run: cd tools/js && bun install
|
||||
- run: bun handleMcpcGeneratedArtifacts.js
|
||||
working-directory: .github/helper-bot
|
||||
env:
|
||||
TRIGGER_MC_VERSIONS: ${{ github.event.inputs.versions }}
|
||||
TRIGGER_PR_NO: ${{ github.event.inputs.prNumber }}
|
||||
TRIGGER_ARTIFACT_URL: ${{ github.event.inputs.mergedArtifactURL }}
|
||||
GITHUB_TOKEN: ${{ secrets.PAT_PASSWORD }}
|
||||
CREATE_PR_IF_NONE: ${{ github.event.inputs.createPr }}
|
||||
+34
@@ -0,0 +1,34 @@
|
||||
name: 'tag'
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
jobs:
|
||||
tag:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions-ecosystem/action-regex-match@v2
|
||||
id: regex-match
|
||||
with:
|
||||
text: ${{ github.event.head_commit.message }}
|
||||
regex: '^Release ([0-9]+\.[0-9]+\.[0-9]+)'
|
||||
- name: Create Release
|
||||
if: steps.regex-match.outputs.match != ''
|
||||
id: create_release
|
||||
uses: actions/create-release@v1
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
with:
|
||||
tag_name: ${{ steps.regex-match.outputs.group1 }}
|
||||
release_name: Release ${{ steps.regex-match.outputs.group1 }}
|
||||
body: ${{ steps.regex-match.outputs.group1 }}
|
||||
draft: false
|
||||
prerelease: false
|
||||
- uses: peter-evans/repository-dispatch@v1
|
||||
if: ${{ steps.regex-match.outputs.match != '' }}
|
||||
with:
|
||||
token: ${{ secrets.PAT_PASSWORD }}
|
||||
repository: PrismarineJS/node-minecraft-data
|
||||
event-type: mcData-release
|
||||
client-payload: '{"tag": "${{ steps.regex-match.outputs.group1 }}"}'
|
||||
@@ -0,0 +1,32 @@
|
||||
name: Update Helper
|
||||
on:
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
createPr:
|
||||
description: 'If provided, force create an update PR. JSON encoded payload {title, versionJson, latestVersionData, latestVersion}'
|
||||
required: false
|
||||
default: ''
|
||||
schedule:
|
||||
- cron: "0 */2 * * *"
|
||||
|
||||
jobs:
|
||||
helper:
|
||||
name: update-checker
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@master
|
||||
- name: Set up Node.js
|
||||
uses: actions/setup-node@master
|
||||
with:
|
||||
node-version: 22.0.0
|
||||
- name: Install Github Actions toolkit
|
||||
run: npm i
|
||||
working-directory: .github/helper-bot
|
||||
# The env vars contain the relevant trigger information, so we don't need to pass it
|
||||
- name: Runs helper
|
||||
run: node index.js
|
||||
working-directory: .github/helper-bot
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.PAT_PASSWORD }}
|
||||
FORCE_CREATE_PR: ${{ github.event.inputs.createPr }}
|
||||
Reference in New Issue
Block a user