mirror of
https://github.com/Kir-Antipov/mc-publish.git
synced 2024-12-04 19:24:46 +01:00
Documented target-specific properties
Also, GitHub should no longer emit warnings when someone uses them. Closes #13
This commit is contained in:
parent
f89c9cab04
commit
7aa44c48ce
7 changed files with 103 additions and 55 deletions
30
README.md
30
README.md
|
@ -124,6 +124,36 @@ jobs:
|
|||
| [retry-attempts](#user-content-retry-attempts) | The maximum number of attempts to publish assets | `2` | `2` <br> `10` <br> `-1` |
|
||||
| [retry-delay](#user-content-retry-delay) | Time delay between attempts to publish assets (in milliseconds) | `10000` | `10000` <br> `60000` <br> `0` |
|
||||
|
||||
Note, that you can use any top-level property *(`name`, `version`, `dependencies`, `files`, etc.)* as a target-specific one. This can help you fine-tune `mc-publish` to suit your tastes and needs. For example, consider the following configuration:
|
||||
|
||||
```yaml
|
||||
# It is a good idea to share the same primary file among different targets
|
||||
files-primary: build/libs/!(*-@(dev\|sources)).jar
|
||||
|
||||
modrinth-id: aaaAAAaa
|
||||
modrinth-token: ${{ secrets.MODRINTH_TOKEN }}
|
||||
# Modrinth-specific name for your mod
|
||||
modrinth-name: Modrinth Mod
|
||||
# Modrinth-specific secondary files
|
||||
modrinth-files-secondary: build/libs/*-@(dev\|sources).jar
|
||||
# Modrinth-specific dependencies
|
||||
# It is possible to use project ids instead of slugs
|
||||
modrinth-dependencies: |
|
||||
AANobbMI | depends | *
|
||||
sodium
|
||||
|
||||
curseforge-id: 0
|
||||
curseforge-token: ${{ secrets.CURSEFORGE_TOKEN }}
|
||||
# CurseForge-specific name for your mod
|
||||
curseforge-name: CurseForge Mod
|
||||
# CurseForge-specific secondary files
|
||||
curseforge-files-secondary: ""
|
||||
# CurseForge-specific dependencies
|
||||
# It is not possible to use project ids instead of slugs
|
||||
curseforge-dependencies: |
|
||||
sodium | depends | *
|
||||
```
|
||||
|
||||
#### modrinth-id
|
||||
|
||||
The ID of the Modrinth project to upload to.
|
||||
|
|
|
@ -5,125 +5,80 @@ branding:
|
|||
color: orange
|
||||
icon: upload
|
||||
inputs:
|
||||
modrinth:
|
||||
publisher: true
|
||||
curseforge:
|
||||
publisher: true
|
||||
github:
|
||||
publisher: true
|
||||
|
||||
modrinth-id:
|
||||
description: The ID of the Modrinth project to upload to
|
||||
required: false
|
||||
default: ${undefined}
|
||||
modrinth-featured:
|
||||
description: Indicates whether the version should be featured on Modrinth or not
|
||||
required: false
|
||||
default: ${undefined}
|
||||
modrinth-unfeature-mode:
|
||||
description: Determines the way automatic unfeaturing of older Modrinth versions works
|
||||
required: false
|
||||
default: ${undefined}
|
||||
modrinth-token:
|
||||
description: A valid token for the Modrinth API
|
||||
required: false
|
||||
default: ${undefined}
|
||||
|
||||
curseforge-id:
|
||||
description: The ID of the CurseForge project to upload to
|
||||
required: false
|
||||
default: ${undefined}
|
||||
curseforge-token:
|
||||
description: A valid token for the CurseForge API
|
||||
required: false
|
||||
default: ${undefined}
|
||||
|
||||
github-tag:
|
||||
description: The tag name of the release to upload assets to
|
||||
required: false
|
||||
default: ${undefined}
|
||||
github-generate-changelog:
|
||||
description: Indicates whether to automatically generate the changelog for this release. If changelog is specified, it will be pre-pended to the automatically generated notes. Unused if the GitHub Release already exists
|
||||
required: false
|
||||
default: ${undefined}
|
||||
github-draft:
|
||||
description: true to create a draft (unpublished) release, false to create a published one. Unused if the GitHub Release already exists
|
||||
required: false
|
||||
default: ${undefined}
|
||||
github-prerelease:
|
||||
description: true to identify the release as a prerelease, false to identify the release as a full release. Unused if the GitHub Release already exists
|
||||
required: false
|
||||
default: ${undefined}
|
||||
github-commitish:
|
||||
description: Specifies the commitish value that determines where the Git tag is created from. Can be any branch or commit SHA. Unused if the Git tag already exists
|
||||
required: false
|
||||
default: ${undefined}
|
||||
github-discussion:
|
||||
description: If specified, a discussion of the specified category is created and linked to the release. Unused if the GitHub Release already exists
|
||||
required: false
|
||||
default: ${undefined}
|
||||
github-token:
|
||||
description: A valid token for the GitHub API
|
||||
required: false
|
||||
default: ${undefined}
|
||||
|
||||
files:
|
||||
description: A glob of the files to upload
|
||||
required: false
|
||||
default: ${undefined}
|
||||
files-primary:
|
||||
description: A glob of the primary files to upload
|
||||
required: false
|
||||
default: ${undefined}
|
||||
files-secondary:
|
||||
description: A glob of the secondary files to upload
|
||||
required: false
|
||||
default: ${undefined}
|
||||
|
||||
name:
|
||||
description: The name of the version
|
||||
required: false
|
||||
default: ${undefined}
|
||||
version:
|
||||
description: The version number
|
||||
required: false
|
||||
default: ${undefined}
|
||||
version-type:
|
||||
description: The type of the release - alpha, beta, or release
|
||||
required: false
|
||||
default: ${undefined}
|
||||
|
||||
changelog:
|
||||
description: The changelog for this version
|
||||
required: false
|
||||
default: ${undefined}
|
||||
changelog-file:
|
||||
description: A glob of the changelog file
|
||||
required: false
|
||||
default: ${undefined}
|
||||
|
||||
loaders:
|
||||
description: A list of supported mod loaders
|
||||
required: false
|
||||
default: ${undefined}
|
||||
game-versions:
|
||||
description: A list of supported Minecraft versions
|
||||
required: false
|
||||
default: ${undefined}
|
||||
dependencies:
|
||||
description: A list of dependencies
|
||||
required: false
|
||||
default: ${undefined}
|
||||
version-resolver:
|
||||
description: Determines the way automatic game-versions resolvement works
|
||||
required: false
|
||||
default: ${undefined}
|
||||
java:
|
||||
description: A list of supported Java versions
|
||||
required: false
|
||||
default: ${undefined}
|
||||
|
||||
retry-attempts:
|
||||
description: The maximum number of attempts to publish assets
|
||||
required: false
|
||||
default: 2
|
||||
unique: true
|
||||
retry-delay:
|
||||
description: Time delay between attempts to publish assets (in milliseconds)
|
||||
required: false
|
||||
default: 10000
|
||||
unique: true
|
||||
runs:
|
||||
using: node12
|
||||
main: dist/index.js
|
6
package-lock.json
generated
6
package-lock.json
generated
|
@ -6481,6 +6481,12 @@
|
|||
"integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==",
|
||||
"dev": true
|
||||
},
|
||||
"yaml": {
|
||||
"version": "2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/yaml/-/yaml-2.0.0.tgz",
|
||||
"integrity": "sha512-JbfdlHKGP2Ik9IHylzWlGd4pPK++EU46/IxMykphS2ZKw7a7h+dHNmcXObLgpRDriBY+rpWslldikckX8oruWQ==",
|
||||
"dev": true
|
||||
},
|
||||
"yargs": {
|
||||
"version": "17.5.1",
|
||||
"resolved": "https://registry.npmjs.org/yargs/-/yargs-17.5.1.tgz",
|
||||
|
|
|
@ -39,6 +39,7 @@
|
|||
"eslint": "^8.16.0",
|
||||
"jest": "^28.1.0",
|
||||
"typescript": "^4.7.2",
|
||||
"yaml": "2.0.0",
|
||||
"yazl": "^2.5.1"
|
||||
},
|
||||
"dependencies": {
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
import fixDeprecatedBuffer from "./buffer-fix";
|
||||
import fixDeprecatedBuffer from "./fixes/buffer-fix";
|
||||
import processActionYamlTemplate from "./templates/action-yml";
|
||||
|
||||
fixDeprecatedBuffer();
|
||||
processActionYamlTemplate();
|
||||
|
|
54
scripts/templates/action-yml.ts
Normal file
54
scripts/templates/action-yml.ts
Normal file
|
@ -0,0 +1,54 @@
|
|||
import fs from "fs";
|
||||
import yaml from "yaml";
|
||||
|
||||
interface ActionInput {
|
||||
description?: string;
|
||||
required?: boolean;
|
||||
default?: string;
|
||||
unique?: boolean;
|
||||
publisher?: boolean;
|
||||
}
|
||||
|
||||
export default function processActionYamlTemplate() {
|
||||
processActionTemplate("./action.template.yml", "./action.yml");
|
||||
}
|
||||
|
||||
function processActionTemplate(pathIn: string, pathOut: string) {
|
||||
const content = fs.readFileSync(pathIn, "utf8");
|
||||
const action = yaml.parse(content) as { inputs?: Record<string, ActionInput> };
|
||||
if (!action.inputs) {
|
||||
action.inputs = {};
|
||||
}
|
||||
|
||||
action.inputs = processInputs(action.inputs);
|
||||
|
||||
const updatedContent = yaml.stringify(action);
|
||||
fs.writeFileSync(pathOut, updatedContent, "utf8");
|
||||
}
|
||||
|
||||
function processInputs(inputs: Record<string, ActionInput>) {
|
||||
const publishers = Object.entries(inputs).filter(([_, input]) => input.publisher).map(([key, _]) => key);
|
||||
const nestedInputs = Object.entries(inputs).filter(([key, input]) => !input.publisher && !input.unique && !publishers.find(p => key.startsWith(p)));
|
||||
|
||||
for (const [key, input] of Object.entries(inputs)) {
|
||||
if (input.publisher) {
|
||||
delete inputs[key];
|
||||
}
|
||||
delete input.unique;
|
||||
|
||||
if (typeof input.required !== "boolean") {
|
||||
input.required = false;
|
||||
}
|
||||
if (input.default === undefined) {
|
||||
input.default = "${undefined}";
|
||||
}
|
||||
}
|
||||
|
||||
for (const publisher of publishers) {
|
||||
for (const [name, input] of nestedInputs) {
|
||||
inputs[`${publisher}-${name}`] = { ...input };
|
||||
}
|
||||
}
|
||||
|
||||
return inputs;
|
||||
}
|
Loading…
Reference in a new issue