parent
20e93dd5f2
commit
18b0257aec
31
.github/workflows/buildpack.yml
vendored
31
.github/workflows/buildpack.yml
vendored
@ -77,16 +77,17 @@ on:
|
||||
type: string
|
||||
required: false
|
||||
|
||||
env:
|
||||
GITHUB_TAG: ${{ inputs.tag }}
|
||||
RELEASE_TYPE: ${{ inputs.release_type }}
|
||||
HEAD_REF: ${{ inputs.head_ref }}
|
||||
TRUE_SHA: ${{ inputs.true_sha }}
|
||||
|
||||
jobs:
|
||||
buildSingle:
|
||||
name: Build Pack (${{ inputs.tag }})
|
||||
runs-on: ubuntu-latest
|
||||
if: ${{ !inputs.separate_upload }}
|
||||
env:
|
||||
GITHUB_TAG: ${{ inputs.tag }}
|
||||
RELEASE_TYPE: ${{ inputs.release_type }}
|
||||
GITHUB_HEAD_REF: ${{ inputs.head_ref }}
|
||||
TRUE_SHA: ${{ inputs.true_sha }}
|
||||
|
||||
steps:
|
||||
- name: Checkout Ref
|
||||
@ -158,11 +159,6 @@ jobs:
|
||||
name: Make Artifact Names (${{ inputs.tag }})
|
||||
runs-on: ubuntu-latest
|
||||
if: ${{ inputs.separate_upload }}
|
||||
env:
|
||||
GITHUB_TAG: ${{ inputs.tag }}
|
||||
RELEASE_TYPE: ${{ inputs.release_type }}
|
||||
GITHUB_HEAD_REF: ${{ inputs.head_ref }}
|
||||
TRUE_SHA: ${{ inputs.true_sha }}
|
||||
outputs:
|
||||
client: ${{ steps.artifactNames.outputs.client }}
|
||||
server: ${{ steps.artifactNames.outputs.server }}
|
||||
@ -215,11 +211,6 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
if: ${{ inputs.separate_upload }}
|
||||
needs: makeNames
|
||||
env:
|
||||
GITHUB_TAG: ${{ inputs.tag }}
|
||||
RELEASE_TYPE: ${{ inputs.release_type }}
|
||||
GITHUB_HEAD_REF: ${{ inputs.head_ref }}
|
||||
TRUE_SHA: ${{ inputs.true_sha }}
|
||||
steps:
|
||||
- name: Checkout Ref
|
||||
uses: actions/checkout@v4
|
||||
@ -280,11 +271,6 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
if: ${{ inputs.separate_upload }}
|
||||
needs: makeNames
|
||||
env:
|
||||
GITHUB_TAG: ${{ inputs.tag }}
|
||||
RELEASE_TYPE: ${{ inputs.release_type }}
|
||||
GITHUB_HEAD_REF: ${{ inputs.head_ref }}
|
||||
TRUE_SHA: ${{ inputs.true_sha }}
|
||||
steps:
|
||||
- name: Checkout Ref
|
||||
uses: actions/checkout@v4
|
||||
@ -354,11 +340,6 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
if: ${{ inputs.separate_upload }}
|
||||
needs: makeNames
|
||||
env:
|
||||
GITHUB_TAG: ${{ inputs.tag }}
|
||||
RELEASE_TYPE: ${{ inputs.release_type }}
|
||||
GITHUB_HEAD_REF: ${{ inputs.head_ref }}
|
||||
TRUE_SHA: ${{ inputs.true_sha }}
|
||||
steps:
|
||||
- name: Checkout Ref
|
||||
uses: actions/checkout@v4
|
||||
|
23
.github/workflows/forkprbuildpack.yml
vendored
23
.github/workflows/forkprbuildpack.yml
vendored
@ -22,6 +22,11 @@ concurrency:
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
env:
|
||||
HEAD_REF: ${{ github.head_ref }}
|
||||
HEAD_REPO: ${{ github.event.pull_request.head.repo.owner.login }}
|
||||
TRUE_SHA: ${{ github.event.pull_request.head.sha }}
|
||||
|
||||
jobs:
|
||||
setup:
|
||||
# Only continue if we are in base Nomi-CEu Repo and pull request is from fork
|
||||
@ -29,9 +34,6 @@ jobs:
|
||||
name: Setup (${{ github.event.pull_request.head.sha }})
|
||||
runs-on: ubuntu-latest
|
||||
environment: fork-pr-build-pack
|
||||
env:
|
||||
GITHUB_HEAD_REF: ${{ github.event.pull_request.head.repo.owner.login }}/${{ github.head_ref }}
|
||||
TRUE_SHA: ${{ github.event.pull_request.head.sha }}
|
||||
outputs:
|
||||
client: ${{ steps.artifactNames.outputs.client }}
|
||||
server: ${{ steps.artifactNames.outputs.server }}
|
||||
@ -63,14 +65,9 @@ jobs:
|
||||
run: npm run gulp makeArtifactNames
|
||||
|
||||
buildClient:
|
||||
# Only continue if we are in base Nomi-CEu Repo and pull request is from fork
|
||||
if: "${{ github.repository_owner == 'Nomi-CEu' && github.event.pull_request.head.repo.owner.login != 'Nomi-CEu' }}"
|
||||
name: Build Fork PR Client (${{ github.event.pull_request.head.sha }})
|
||||
runs-on: ubuntu-latest
|
||||
needs: setup
|
||||
env:
|
||||
GITHUB_HEAD_REF: ${{ github.event.pull_request.head.repo.owner.login }}/${{ github.head_ref }}
|
||||
TRUE_SHA: ${{ github.event.pull_request.head.sha }}
|
||||
steps:
|
||||
- name: Checkout Ref
|
||||
uses: actions/checkout@v4
|
||||
@ -106,14 +103,9 @@ jobs:
|
||||
compression-level: 9
|
||||
|
||||
buildServer:
|
||||
# Only continue if we are in base Nomi-CEu Repo and pull request is from fork
|
||||
if: "${{ github.repository_owner == 'Nomi-CEu' && github.event.pull_request.head.repo.owner.login != 'Nomi-CEu' }}"
|
||||
name: Build Fork PR Server (${{ github.event.pull_request.head.sha }})
|
||||
runs-on: ubuntu-latest
|
||||
needs: setup
|
||||
env:
|
||||
GITHUB_HEAD_REF: ${{ github.event.pull_request.head.repo.owner.login }}/${{ github.head_ref }}
|
||||
TRUE_SHA: ${{ github.event.pull_request.head.sha }}
|
||||
steps:
|
||||
- name: Checkout Ref
|
||||
uses: actions/checkout@v4
|
||||
@ -149,14 +141,9 @@ jobs:
|
||||
compression-level: 9
|
||||
|
||||
buildLang:
|
||||
# Only continue if we are in base Nomi-CEu Repo and pull request is from fork
|
||||
if: "${{ github.repository_owner == 'Nomi-CEu' && github.event.pull_request.head.repo.owner.login != 'Nomi-CEu' }}"
|
||||
name: Build Fork PR Lang and Changelogs (${{ github.event.pull_request.head.sha }})
|
||||
runs-on: ubuntu-latest
|
||||
needs: setup
|
||||
env:
|
||||
GITHUB_HEAD_REF: ${{ github.event.pull_request.head.repo.owner.login }}/${{ github.head_ref }}
|
||||
TRUE_SHA: ${{ github.event.pull_request.head.sha }}
|
||||
steps:
|
||||
- name: Checkout Ref
|
||||
uses: actions/checkout@v4
|
||||
|
@ -57,7 +57,7 @@ export const zipAll = zip.zipAll;
|
||||
|
||||
export default gulp.series(buildAll, zipAll);
|
||||
|
||||
import * as gha from "./tasks/misc/gha.ts";
|
||||
import * as gha from "#tasks/misc/makeArtifactNames.ts";
|
||||
export const makeArtifactNames = gha.makeArtifactNames;
|
||||
|
||||
export { deployCurseForge } from "./tasks/deploy/curseforge.ts";
|
||||
|
@ -2,6 +2,7 @@ import { modpackManifest } from "#globals";
|
||||
import { makeArtifactNameBody } from "#utils/util.ts";
|
||||
import sanitize from "sanitize-filename";
|
||||
import { setOutput } from "@actions/core";
|
||||
import logInfo from "#utils/log.js";
|
||||
|
||||
export async function makeArtifactNames(): Promise<void> {
|
||||
const body = makeArtifactNameBody(modpackManifest.name);
|
||||
@ -14,5 +15,6 @@ export async function makeArtifactNames(): Promise<void> {
|
||||
|
||||
Object.keys(names).forEach((name) => {
|
||||
setOutput(name, sanitize(names[name].toLowerCase()));
|
||||
logInfo(`Made Name for Type '${name}': '${names[name].toLowerCase()}'`);
|
||||
});
|
||||
}
|
@ -1,32 +1,9 @@
|
||||
import { modpackManifest } from "#globals";
|
||||
import { BuildData } from "#types/transformFiles.js";
|
||||
|
||||
/**
|
||||
* Transform the version field of manifest.json.
|
||||
*/
|
||||
export default async function transformManifestVersion(): Promise<void> {
|
||||
// We're building a tag.
|
||||
if (process.env.GITHUB_TAG) {
|
||||
modpackManifest.version = process.env.GITHUB_TAG.replace(/^v/, "");
|
||||
}
|
||||
// If Pull Request Branch Name is provided and a 'True SHA' is provided
|
||||
else if (process.env.GITHUB_HEAD_REF && process.env.TRUE_SHA) {
|
||||
const shortCommit = process.env.TRUE_SHA.substring(0, 7);
|
||||
modpackManifest.version = `${process.env.GITHUB_HEAD_REF}-${shortCommit}`;
|
||||
}
|
||||
// If SHA and ref is provided, append both the branch and short SHA.
|
||||
else if (
|
||||
process.env.GITHUB_SHA &&
|
||||
process.env.GITHUB_REF &&
|
||||
process.env.GITHUB_REF.startsWith("refs/heads/")
|
||||
) {
|
||||
const shortCommit = process.env.GITHUB_SHA.substring(0, 7);
|
||||
const branch = /refs\/heads\/(.+)/.exec(process.env.GITHUB_REF)?.[1];
|
||||
if (!branch) {
|
||||
throw new Error(`Invalid git ref: ${process.env.GITHUB_REF}`);
|
||||
}
|
||||
|
||||
modpackManifest.version = `${branch}-${shortCommit}`;
|
||||
} else {
|
||||
modpackManifest.version = "manual-build";
|
||||
}
|
||||
modpackManifest.version = new BuildData().rawVersion;
|
||||
}
|
||||
|
@ -18,16 +18,28 @@ export class BuildData {
|
||||
process.env.GITHUB_TAG.search(/^v/) === -1
|
||||
? `v${process.env.GITHUB_TAG}`
|
||||
: process.env.GITHUB_TAG;
|
||||
return;
|
||||
}
|
||||
|
||||
// If Pull Request Branch Name is provided and a 'True SHA' is provided
|
||||
else if (process.env.GITHUB_HEAD_REF && process.env.TRUE_SHA) {
|
||||
if (process.env.HEAD_REF && process.env.TRUE_SHA) {
|
||||
const shortCommit = process.env.TRUE_SHA.substring(0, 7);
|
||||
this.type = "HEAD_REF";
|
||||
this.rawVersion = `${process.env.GITHUB_HEAD_REF}-${shortCommit}`;
|
||||
this.transformedVersion = `PR Build (${process.env.GITHUB_HEAD_REF} branch, ${shortCommit})`;
|
||||
|
||||
// If Head Repo is provided and this is a Fork PR
|
||||
if (process.env.HEAD_REPO && process.env.HEAD_REPO !== "Nomi-CEu") {
|
||||
this.rawVersion = `[${process.env.HEAD_REPO.toLowerCase()}-${process.env.HEAD_REF}]-${shortCommit}`;
|
||||
this.transformedVersion = `Fork PR Build (${process.env.HEAD_REPO}/${process.env.HEAD_REF} branch, ${shortCommit})`;
|
||||
return;
|
||||
}
|
||||
|
||||
this.rawVersion = `${process.env.HEAD_REF}-${shortCommit}`;
|
||||
this.transformedVersion = `PR Build (${process.env.HEAD_REF} branch, ${shortCommit})`;
|
||||
return;
|
||||
}
|
||||
|
||||
// If SHA and ref is provided, append both the branch and short SHA.
|
||||
else if (
|
||||
if (
|
||||
process.env.GITHUB_SHA &&
|
||||
process.env.GITHUB_REF &&
|
||||
process.env.GITHUB_REF.startsWith("refs/heads/")
|
||||
@ -41,13 +53,13 @@ export class BuildData {
|
||||
this.type = "GITHUB_SHA";
|
||||
this.rawVersion = `${branch}-${shortCommit}`;
|
||||
this.transformedVersion = `Nightly Build (${branch} branch, ${shortCommit})`;
|
||||
return;
|
||||
}
|
||||
|
||||
// Manual Build
|
||||
else {
|
||||
this.type = "MANUAL_BUILD";
|
||||
this.rawVersion = "manual-build";
|
||||
this.transformedVersion = "Manual Build";
|
||||
}
|
||||
this.type = "MANUAL_BUILD";
|
||||
this.rawVersion = "manual-build";
|
||||
this.transformedVersion = "Manual Build";
|
||||
}
|
||||
|
||||
public isVersionBuild(): boolean {
|
||||
|
@ -38,6 +38,7 @@ import axiosRetry, {
|
||||
} from "axios-retry";
|
||||
import stream from "node:stream";
|
||||
import { NomiConfig } from "#types/axios.ts";
|
||||
import { BuildData } from "#types/transformFiles.js";
|
||||
|
||||
const LIBRARY_REG = /^(.+?):(.+?):(.+?)$/;
|
||||
|
||||
@ -314,26 +315,7 @@ function retryOrThrow(
|
||||
* Mostly intended to be called by CI/CD.
|
||||
*/
|
||||
export function makeArtifactNameBody(baseName: string): string {
|
||||
// If the tag is provided by CI, simply just glue it to the base name.
|
||||
if (process.env.GITHUB_TAG) {
|
||||
return `${baseName}-${process.env.GITHUB_TAG}`;
|
||||
}
|
||||
// If Pull Request Branch Name is provided and a 'True SHA' is provided
|
||||
if (process.env.GITHUB_HEAD_REF && process.env.TRUE_SHA) {
|
||||
const shortCommit = process.env.TRUE_SHA.substring(0, 7);
|
||||
return `${baseName}-${process.env.GITHUB_HEAD_REF}-${shortCommit}`;
|
||||
}
|
||||
// If SHA and ref is provided, append both the branch and short SHA.
|
||||
if (
|
||||
process.env.GITHUB_SHA &&
|
||||
process.env.GITHUB_REF &&
|
||||
process.env.GITHUB_REF.startsWith("refs/heads/")
|
||||
) {
|
||||
const shortCommit = process.env.GITHUB_SHA.substring(0, 7);
|
||||
const branch = /refs\/heads\/(.+)/.exec(process.env.GITHUB_REF);
|
||||
if (branch) return `${baseName}-${branch[1]}-${shortCommit}`;
|
||||
}
|
||||
return baseName;
|
||||
return `${baseName}-${new BuildData().rawVersion}`;
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
x
Reference in New Issue
Block a user