From 8a4b323505db6d221c1905a10d6b3646e22b9edf Mon Sep 17 00:00:00 2001 From: Integer Limit <103940576+IntegerLimit@users.noreply.github.com> Date: Mon, 4 Dec 2023 21:56:24 +1100 Subject: [PATCH] Improve Build CI/CD System (#552) This improves the Build CI/CD System and the Release Commit Workflows. The CD system now builds and zips the pack in parallel, increasing the speed twofold. The CI system now does not produce double zips, but remains the same speed, thanks to parallel processing. The CI system now also changes server.properties and random patches config files for the build, and the buildscript has been edited for that. Since the CI system replaces the nightly task, the nightly workflow has been deleted. The makeArtifactNames task is now used, and has been changed to remove usage of deprecated features. The release commit workflows now supports updating files without version input, and the version is grabbed from versions.txt.' The code for the release commit workflows has also been greatly cleaned up. The changes made to the random patches template files have also been updated. The changes made incorrectly to the issue templates in #487 have also been fixed. The README badges have also been changed. The issue badge has been replaced by a nightly builds badge. Finally, this changes the forge download process to try again if the response is null, resulting in a decrease, to almost none, test build pack and build pack failures. [INTERNAL] [IGNORE] checks = { compareNot = "1.7-alpha-1" } [IGNORE] --- .github/ISSUE_TEMPLATE/001-bug-report.yml | 2 +- .../ISSUE_TEMPLATE/002-feature-request.yml | 2 +- .github/workflows/buildpack.yml | 324 ++++++++++++++++-- .github/workflows/nightly.yml.disabled | 104 ------ .github/workflows/releasechangelog.yml | 2 +- .github/workflows/releasecommit.yml | 130 ++----- .github/workflows/releasedeploy.yml | 2 +- .github/workflows/testbuildpack.yml | 4 +- README.md | 6 +- .../config-overrides/expert/randompatches.cfg | 4 +- .../config-overrides/normal/randompatches.cfg | 4 +- overrides/config/randompatches.cfg | 4 +- tools/gulpfile.ts | 37 +- tools/package-lock.json | 97 ++++++ tools/package.json | 1 + tools/tasks/changelog/changelogData.ts | 2 +- tools/tasks/lang/index.ts | 2 +- tools/tasks/misc/gha.ts | 4 +- .../{releaseCommit.ts => transformFiles.ts} | 151 ++++---- tools/tasks/misc/zip.ts | 2 +- tools/tasks/shared/index.ts | 2 + tools/tasks/shared/transformVersion.ts | 2 - tools/templates/001-bug-report.yml | 11 +- tools/templates/002-feature-request.yml | 4 +- tools/templates/mainmenu.json | 2 +- tools/templates/randompatches.cfg | 2 +- tools/templates/server_expert.properties | 2 +- tools/templates/server_normal.properties | 2 +- tools/types/transformFiles.ts | 46 +++ tools/util/util.ts | 6 +- 30 files changed, 620 insertions(+), 343 deletions(-) delete mode 100644 .github/workflows/nightly.yml.disabled rename tools/tasks/misc/{releaseCommit.ts => transformFiles.ts} (61%) create mode 100644 tools/types/transformFiles.ts diff --git a/.github/ISSUE_TEMPLATE/001-bug-report.yml b/.github/ISSUE_TEMPLATE/001-bug-report.yml index 5d953d7..b8112d8 100644 --- a/.github/ISSUE_TEMPLATE/001-bug-report.yml +++ b/.github/ISSUE_TEMPLATE/001-bug-report.yml @@ -11,7 +11,7 @@ body: id: version attributes: label: Nomi CEu Version - description: The version of Nomi CEu you were using when this bug was encountered. If you do not know what it is, check the title of your instance window. If you do not see your version here, please update to the newest alpha, beta or release of the pack. + description: The version of Nomi CEu you were using when this bug was encountered. If you do not know what it is, check the title of your instance window. If you do not see your version here, please update to the newest alpha, beta or release of the pack. options: - 1.7-alpha-1 - 1.6.1a diff --git a/.github/ISSUE_TEMPLATE/002-feature-request.yml b/.github/ISSUE_TEMPLATE/002-feature-request.yml index c1ff5ea..7e484fa 100644 --- a/.github/ISSUE_TEMPLATE/002-feature-request.yml +++ b/.github/ISSUE_TEMPLATE/002-feature-request.yml @@ -11,7 +11,7 @@ body: id: version attributes: label: Nomi CEu Version - description: The version of Nomi CEu you were using when this bug was encountered. If you do not know what it is, check the title of your instance window. If you do not see your version here, please update to the newest alpha, beta or release of the pack. + description: The version of Nomi CEu you are using as the basis for this feature request. If you do not know what it is, check the title of your instance window. f you do not see your version here, please update to the newest alpha, beta or release of the pack. options: - 1.7-alpha-1 - 1.6.1a diff --git a/.github/workflows/buildpack.yml b/.github/workflows/buildpack.yml index 99bdd4b..f254818 100644 --- a/.github/workflows/buildpack.yml +++ b/.github/workflows/buildpack.yml @@ -78,9 +78,10 @@ on: required: false jobs: - build: + buildSingle: name: Build Pack (${{ inputs.tag }}) runs-on: ubuntu-latest + if: ${{ !inputs.separate_upload }} env: GITHUB_TAG: ${{ inputs.tag }} RELEASE_TYPE: ${{ inputs.release_type }} @@ -124,9 +125,9 @@ jobs: CURSEFORGE_API_TOKEN: ${{ secrets.CURSEFORGE_API_TOKEN }} CFCORE_API_TOKEN: ${{ secrets.CFCORE_API_TOKEN }} - - name: Build Pack + - name: Build and Zip Pack working-directory: ./tools - run: npx gulp buildAll + run: npx gulp env: CFCORE_API_TOKEN: ${{ secrets.CFCORE_API_TOKEN }} CHANGELOG_BRANCH: ${{ inputs.changelog_branch }} @@ -134,13 +135,8 @@ jobs: CHANGELOG_CF_URL: ${{ inputs.changelog_cf_url }} COMPARE_TAG: ${{ inputs.compare_tag }} - - name: Zip Pack - working-directory: ./tools - run: npx gulp zipAll - - name: Upload All Files uses: actions/upload-artifact@v3 - if: ${{ !inputs.separate_upload }} with: name: Built Pack path: | @@ -148,36 +144,320 @@ jobs: ./build/*.md if-no-files-found: error + makeNames: + 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 }} + lang: ${{ steps.artifactNames.outputs.lang }} + mmc: ${{ steps.artifactNames.outputs.mmc }} + steps: + - name: Checkout Ref + uses: actions/checkout@v4 + with: + fetch-depth: 0 + ref: ${{ inputs.tag }} + + - name: Restore Cached Files + uses: actions/cache@v3 + id: cache + with: + path: | + ~/.npm + ./.cache + ./tools/node_modules + key: ${{ runner.os }}-bunny-${{ hashFiles('**/.cache', '**/package-lock.json', '**/manifest.json') }} + restore-keys: ${{ runner.os }}-bunny- + + - name: Setup NodeJS v16 + uses: actions/setup-node@v3 + with: + node-version: "16" + check-latest: true + + - name: Setup NPM Packages + working-directory: ./tools + run: npm ci + + - name: Check Environmental Variables + working-directory: ./tools + run: npx gulp check + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + CURSEFORGE_PROJECT_ID: ${{ secrets.CURSEFORGE_PROJECT_ID }} + CURSEFORGE_API_TOKEN: ${{ secrets.CURSEFORGE_API_TOKEN }} + CFCORE_API_TOKEN: ${{ secrets.CFCORE_API_TOKEN }} + + - name: Make Artifact Names + id: artifactNames + working-directory: ./tools + run: npx gulp makeArtifactNames + + buildClient: + name: Build Pack Client (${{ inputs.tag }}) + 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 + with: + fetch-depth: 0 + ref: ${{ inputs.tag }} + + - name: Restore Cached Files + uses: actions/cache@v3 + id: cache + with: + path: | + ~/.npm + ./.cache + ./tools/node_modules + key: ${{ runner.os }}-bunny-${{ hashFiles('**/.cache', '**/package-lock.json', '**/manifest.json') }} + restore-keys: ${{ runner.os }}-bunny- + + - name: Setup NodeJS v16 + uses: actions/setup-node@v3 + with: + node-version: "16" + check-latest: true + + - name: Setup NPM Packages + working-directory: ./tools + run: npm ci + + - name: Check Environmental Variables + working-directory: ./tools + run: npx gulp check + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + CURSEFORGE_PROJECT_ID: ${{ secrets.CURSEFORGE_PROJECT_ID }} + CURSEFORGE_API_TOKEN: ${{ secrets.CURSEFORGE_API_TOKEN }} + CFCORE_API_TOKEN: ${{ secrets.CFCORE_API_TOKEN }} + + - name: Build Client + working-directory: ./tools + run: npx gulp buildClient + env: + CFCORE_API_TOKEN: ${{ secrets.CFCORE_API_TOKEN }} + CHANGELOG_BRANCH: ${{ inputs.changelog_branch }} + CHANGELOG_URL: ${{ inputs.changelog_url }} + CHANGELOG_CF_URL: ${{ inputs.changelog_cf_url }} + COMPARE_TAG: ${{ inputs.compare_tag }} + - name: Upload Client Zip uses: actions/upload-artifact@v3 if: ${{ inputs.separate_upload }} with: - name: Client Zip - path: ./build/*-client.zip + name: ${{ needs.makeNames.outputs.client }} + path: ./build/client/**/* if-no-files-found: error + buildServer: + name: Build Pack Server (${{ inputs.tag }}) + 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 + with: + fetch-depth: 0 + ref: ${{ inputs.tag }} + + - name: Restore Cached Files + uses: actions/cache@v3 + id: cache + with: + path: | + ~/.npm + ./.cache + ./tools/node_modules + key: ${{ runner.os }}-bunny-${{ hashFiles('**/.cache', '**/package-lock.json', '**/manifest.json') }} + restore-keys: ${{ runner.os }}-bunny- + + - name: Setup NodeJS v16 + uses: actions/setup-node@v3 + with: + node-version: "16" + check-latest: true + + - name: Setup NPM Packages + working-directory: ./tools + run: npm ci + + - name: Check Environmental Variables + working-directory: ./tools + run: npx gulp check + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + CURSEFORGE_PROJECT_ID: ${{ secrets.CURSEFORGE_PROJECT_ID }} + CURSEFORGE_API_TOKEN: ${{ secrets.CURSEFORGE_API_TOKEN }} + CFCORE_API_TOKEN: ${{ secrets.CFCORE_API_TOKEN }} + + - name: Build Server + working-directory: ./tools + run: npx gulp buildServer + env: + CFCORE_API_TOKEN: ${{ secrets.CFCORE_API_TOKEN }} + CHANGELOG_BRANCH: ${{ inputs.changelog_branch }} + CHANGELOG_URL: ${{ inputs.changelog_url }} + CHANGELOG_CF_URL: ${{ inputs.changelog_cf_url }} + COMPARE_TAG: ${{ inputs.compare_tag }} + - name: Upload Server Zip uses: actions/upload-artifact@v3 if: ${{ inputs.separate_upload }} with: - name: Server Zip - path: ./build/*-server.zip + name: ${{ needs.makeNames.outputs.server }} + path: ./build/server/**/* if-no-files-found: error + buildMMC: + name: Build Pack MMC (${{ inputs.tag }}) + 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 + with: + fetch-depth: 0 + ref: ${{ inputs.tag }} + + - name: Restore Cached Files + uses: actions/cache@v3 + id: cache + with: + path: | + ~/.npm + ./.cache + ./tools/node_modules + key: ${{ runner.os }}-bunny-${{ hashFiles('**/.cache', '**/package-lock.json', '**/manifest.json') }} + restore-keys: ${{ runner.os }}-bunny- + + - name: Setup NodeJS v16 + uses: actions/setup-node@v3 + with: + node-version: "16" + check-latest: true + + - name: Setup NPM Packages + working-directory: ./tools + run: npm ci + + - name: Check Environmental Variables + working-directory: ./tools + run: npx gulp check + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + CURSEFORGE_PROJECT_ID: ${{ secrets.CURSEFORGE_PROJECT_ID }} + CURSEFORGE_API_TOKEN: ${{ secrets.CURSEFORGE_API_TOKEN }} + CFCORE_API_TOKEN: ${{ secrets.CFCORE_API_TOKEN }} + + - name: Build MMC + working-directory: ./tools + run: npx gulp buildMMC + env: + CFCORE_API_TOKEN: ${{ secrets.CFCORE_API_TOKEN }} + CHANGELOG_BRANCH: ${{ inputs.changelog_branch }} + CHANGELOG_URL: ${{ inputs.changelog_url }} + CHANGELOG_CF_URL: ${{ inputs.changelog_cf_url }} + COMPARE_TAG: ${{ inputs.compare_tag }} + + - name: Upload MMC Zip + uses: actions/upload-artifact@v3 + if: ${{ inputs.separate_upload }} + with: + name: ${{ needs.makeNames.outputs.mmc }} + path: ./build/mmc/**/* + if-no-files-found: error + + buildLang: + name: Build Pack Lang and Changelogs (${{ inputs.tag }}) + 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 + with: + fetch-depth: 0 + ref: ${{ inputs.tag }} + + - name: Restore Cached Files + uses: actions/cache@v3 + id: cache + with: + path: | + ~/.npm + ./.cache + ./tools/node_modules + key: ${{ runner.os }}-bunny-${{ hashFiles('**/.cache', '**/package-lock.json', '**/manifest.json') }} + restore-keys: ${{ runner.os }}-bunny- + + - name: Setup NodeJS v16 + uses: actions/setup-node@v3 + with: + node-version: "16" + check-latest: true + + - name: Setup NPM Packages + working-directory: ./tools + run: npm ci + + - name: Check Environmental Variables + working-directory: ./tools + run: npx gulp check + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + CURSEFORGE_PROJECT_ID: ${{ secrets.CURSEFORGE_PROJECT_ID }} + CURSEFORGE_API_TOKEN: ${{ secrets.CURSEFORGE_API_TOKEN }} + CFCORE_API_TOKEN: ${{ secrets.CFCORE_API_TOKEN }} + + - name: Build Lang and Changelogs + working-directory: ./tools + run: npx gulp buildLang + env: + CFCORE_API_TOKEN: ${{ secrets.CFCORE_API_TOKEN }} + CHANGELOG_BRANCH: ${{ inputs.changelog_branch }} + CHANGELOG_URL: ${{ inputs.changelog_url }} + CHANGELOG_CF_URL: ${{ inputs.changelog_cf_url }} + COMPARE_TAG: ${{ inputs.compare_tag }} + - name: Upload Lang Zip uses: actions/upload-artifact@v3 if: ${{ inputs.separate_upload }} with: - name: Lang Zip - path: ./build/*-lang.zip - if-no-files-found: error - - - name: Upload MMC Zip - uses: actions/upload-artifact@v3 - if: ${{ inputs.separate_upload }} - with: - name: MMC Zip - path: ./build/*-mmc.zip + name: ${{ needs.makeNames.outputs.lang }} + path: ./build/lang/**/* if-no-files-found: error - name: Upload Changelogs diff --git a/.github/workflows/nightly.yml.disabled b/.github/workflows/nightly.yml.disabled deleted file mode 100644 index d79eca2..0000000 --- a/.github/workflows/nightly.yml.disabled +++ /dev/null @@ -1,104 +0,0 @@ -name: Nightly Builds - -on: - push: - branches: - - dev - tags-ignore: - - '**' - -jobs: - nightly: - runs-on: ubuntu-latest - - steps: - - name: Cancel previous runs - uses: styfle/cancel-workflow-action@0.8.0 - with: - access_token: ${{ secrets.GITHUB_TOKEN }} - - - uses: actions/checkout@v3 - - run: git fetch --prune --unshallow --tags --force - - - name: Restore cached files - uses: actions/cache@v3 - id: cache - with: - path: | - ~/.npm - ./.cache - ./tools/node_modules - key: ${{ runner.os }}-bunny-${{ hashFiles('**/.cache', '**/package-lock.json', '**/manifest.json') }} - restore-keys: ${{ runner.os }}-bunny- - - - name: "Setup NodeJS v16" - uses: actions/setup-node@v3 - with: - node-version: "16" - check-latest: true - - - name: "Download NPM packages" - working-directory: ./tools - run: npm ci - - - name: "Check environmental variables" - working-directory: ./tools - run: npx gulp check - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - CURSEFORGE_PROJECT_ID: ${{ secrets.CURSEFORGE_PROJECT_ID }} - CURSEFORGE_API_TOKEN: ${{ secrets.CURSEFORGE_API_TOKEN }} - CFCORE_API_TOKEN: ${{ secrets.CFCORE_API_TOKEN }} - - - name: "Build everything" - working-directory: ./tools - run: npx gulp buildAll - env: - CFCORE_API_TOKEN: ${{ secrets.CFCORE_API_TOKEN }} - - - name: "Prune cache" - working-directory: ./tools - run: npx gulp pruneCache - - ## - ## Upload artifacts. - ## - - name: "Make artifact names" - id: artifactNames - working-directory: ./tools - run: npx gulp makeArtifactNames - - - name: "Upload client artifact" - uses: actions/upload-artifact@v2 - with: - name: ${{ steps.artifactNames.outputs.client }} - path: | - build/client/**/* - - - name: "Upload server artifact" - uses: actions/upload-artifact@v2 - with: - name: ${{ steps.artifactNames.outputs.server }} - path: | - build/server/**/* - - - name: "Upload lang artifact" - uses: actions/upload-artifact@v2 - with: - name: ${{ steps.artifactNames.outputs.lang }} - path: | - build/lang/**/* - - - name: "Upload changelog artifact" - uses: actions/upload-artifact@v2 - with: - name: changelog - path: | - build/shared/CHANGELOG.md - - - name: "Fire Discord webhook" - working-directory: ./tools - run: npx gulp fireNightlyWebhook - env: - GITHUB_RUN_ID: ${{ github.run_id }} - DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }} diff --git a/.github/workflows/releasechangelog.yml b/.github/workflows/releasechangelog.yml index c9bede7..430287d 100644 --- a/.github/workflows/releasechangelog.yml +++ b/.github/workflows/releasechangelog.yml @@ -27,7 +27,7 @@ jobs: name: Create Release Commit (${{ inputs.tag }}) uses: ./.github/workflows/releasecommit.yml with: - version: ${{ inputs.tag }} + tag: ${{ inputs.tag }} release_type: ${{ inputs.release_type }} secrets: inherit permissions: diff --git a/.github/workflows/releasecommit.yml b/.github/workflows/releasecommit.yml index 826c897..f02b31a 100644 --- a/.github/workflows/releasecommit.yml +++ b/.github/workflows/releasecommit.yml @@ -3,56 +3,57 @@ name: Create Release Commit on: workflow_dispatch: inputs: - version: + tag: description: | - Release Version (aka 1.6.1a, 1.6.1-beta-3, 2.0, etc.). + Tag to release (aka 1.6.1a, 1.6.1-beta-3, 2.0, etc.). - Still important if not a release, and will be used to replace all version fields. - required: true + If this is just a release, then the version will be grabbed from the top line of version.txt. However, this field is needed if version.txt does not exist or is empty. + type: string + required: false release_type: description: 'Release Type. Will be ignored if not a release.' type: choice - required: true + required: false default: 'Release' options: - 'Release' - 'Beta Release' - 'Alpha Release' - is_release: + update_files: description: | - Whether this commit is a release. Usually, leave this set to true. See CONTRIBUTING.md for more details. + Whether this commit is just to update files. version.txt will not be changed. This is used when the templates are changed, and the main files need to be updated. type: boolean required: true - default: true + default: false workflow_call: inputs: - version: + tag: description: | - Release Version (aka 1.6.1a, 1.6.1-beta-3, 2.0, etc.). + Tag to release (aka 1.6.1a, 1.6.1-beta-3, 2.0, etc.). - Still important if not a release, and will be used to replace all version fields. + If this is just a release, then the version will be grabbed from the top line of version.txt. However, this field is needed if version.txt does not exist or is empty. type: string - required: true + required: false release_type: description: 'Release Type. Will be ignored if not a release.' type: string - required: true - is_release: + required: false + update_files: description: | - Whether this commit is a release. See CONTRIBUTING.md for more details. + Whether this commit is just to update files. version.txt will not be changed. This is used when the templates are changed, and the main files need to be updated. type: boolean required: false - default: true + default: false + jobs: - # Release Commit Steps createReleaseCommit: name: Create Release Commit (${{ inputs.version }}) runs-on: ubuntu-latest - if: "${{ inputs.is_release }}" env: - VERSION: "${{ inputs.version }}" - RELEASE_TYPE: "${{ inputs.release_type }}" + UPDATE_FILES: ${{ inputs.update_files }} + GITHUB_TAG: ${{ inputs.tag }} + RELEASE_TYPE: ${{ inputs.release_type }} steps: - name: Checkout Repo @@ -91,84 +92,29 @@ jobs: CURSEFORGE_API_TOKEN: ${{ secrets.CURSEFORGE_API_TOKEN }} CFCORE_API_TOKEN: ${{ secrets.CFCORE_API_TOKEN }} - - name: Set Release Version + - name: Update Files working-directory: ./tools - run: | - npx gulp addVersionAll + run: npx gulp updateFilesAll - name: Commit and Push Release Changes - uses: "stefanzweifel/git-auto-commit-action@v4" - id: "commit-release" + uses: stefanzweifel/git-auto-commit-action@v5 + id: commit-release + if: ${{ !inputs.update_files }} with: - commit_message: "${{ inputs.release_type }} ${{ inputs.version }}\n\n[NO CATEGORY]" - commit_author: "github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>" - tagging_message: "${{ inputs.version }}" + commit_message: "${{ inputs.release_type }} ${{ inputs.tag }}\n\n[NO CATEGORY]" + commit_author: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> + tagging_message: "${{ inputs.tag }}" - - name: Throw Error if No Release Changes were Detected - if: ${{ steps.commit-release.outputs.changes_detected == 'false' }} - run: | - echo "No Changes were Made." - exit 1 - - # Non-Release Commit Steps - updateFilesFromTemplate: - name: Update Files from Templates - runs-on: ubuntu-latest - if: "${{ !inputs.is_release }}" - env: - VERSION: "${{ inputs.version }}" - - steps: - - name: Checkout Repo - uses: actions/checkout@v4 - with: - fetch-depth: 0 - ssh-key: ${{ secrets.SSH_KEY }} - - - name: Restore Cached Files - uses: actions/cache@v3 - id: cache - with: - path: | - ~/.npm - ./.cache - ./tools/node_modules - key: ${{ runner.os }}-bunny-${{ hashFiles('**/.cache', '**/package-lock.json', '**/manifest.json') }} - restore-keys: ${{ runner.os }}-bunny- - - - name: Setup NodeJS v16 - uses: actions/setup-node@v3 - with: - node-version: "16" - check-latest: true - - - name: Setup NPM Packages - working-directory: ./tools - run: npm ci - - - name: Check Environmental Variables - working-directory: ./tools - run: npx gulp check - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - CURSEFORGE_PROJECT_ID: ${{ secrets.CURSEFORGE_PROJECT_ID }} - CURSEFORGE_API_TOKEN: ${{ secrets.CURSEFORGE_API_TOKEN }} - CFCORE_API_TOKEN: ${{ secrets.CFCORE_API_TOKEN }} - - - name: Update Files from Templates - working-directory: ./tools - run: | - npx gulp updateTemplatesAll - - - name: Commit and Push Template Changes - uses: "stefanzweifel/git-auto-commit-action@v4" - id: "commit-template" + - name: Commit and Push Update Changes + uses: stefanzweifel/git-auto-commit-action@v5 + id: commit-update + if: ${{ inputs.update_files }} with: commit_message: "Update Issue, Server and RP Config Files from Templates\n\n[SKIP]" - commit_author: "github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>" - - - name: Throw Error if No Template Changes were Detected - if: ${{ steps.commit-template.outputs.changes_detected == 'false' }} + commit_author: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> + + - name: Throw Error if No Changes were Detected + if: ${{ steps.commit-release.outputs.changes_detected == 'false' || steps.commit-update.outputs.changes_detected == 'false' }} run: | - echo "No Template Changes were detected. This may be an error." + echo "No Changes were Detected. Most likely, this is an error." exit 1 diff --git a/.github/workflows/releasedeploy.yml b/.github/workflows/releasedeploy.yml index e24847f..cbeca68 100644 --- a/.github/workflows/releasedeploy.yml +++ b/.github/workflows/releasedeploy.yml @@ -36,7 +36,7 @@ jobs: name: Create Release Commit (${{ inputs.tag }}) uses: ./.github/workflows/releasecommit.yml with: - version: ${{ inputs.tag }} + tag: ${{ inputs.tag }} release_type: ${{ inputs.release_type }} secrets: inherit permissions: diff --git a/.github/workflows/testbuildpack.yml b/.github/workflows/testbuildpack.yml index 0974efe..f1a3510 100644 --- a/.github/workflows/testbuildpack.yml +++ b/.github/workflows/testbuildpack.yml @@ -3,7 +3,7 @@ name: "[NOT CALLABLE] Test Build Pack" on: push: branches: - - main + - main-int - test_buildscript* pull_request: @@ -16,7 +16,7 @@ concurrency: jobs: build: # Only allow runs from commits to Nomi-CEu Branches or from pull requests from Nomi-CEu repo - if: "${{ github.repository_owner == 'Nomi-CEu' && ( !github.event.pull_request || github.event.pull_request.head.repo.owner.login == 'Nomi-CEu' ) }}" + #if: "${{ github.repository_owner == 'Nomi-CEu' && ( !github.event.pull_request || github.event.pull_request.head.repo.owner.login == 'Nomi-CEu' ) }}" name: Test Build Pack uses: ./.github/workflows/buildpack.yml with: diff --git a/README.md b/README.md index d463aeb..79ffaa7 100644 --- a/README.md +++ b/README.md @@ -2,9 +2,9 @@

Nomifactory CEu

Fork of Nomifactory, using GregTech CEu and its related mods.

- Issues - License - Discord + License + Builds + Discord
CurseForge MC Versions diff --git a/overrides/config-overrides/expert/randompatches.cfg b/overrides/config-overrides/expert/randompatches.cfg index 5e27258..986b016 100644 --- a/overrides/config-overrides/expert/randompatches.cfg +++ b/overrides/config-overrides/expert/randompatches.cfg @@ -146,7 +146,7 @@ misc { # Fixes MC-2025. # More information can be found here: https://www.reddit.com/r/Mojira/comments/8pgd4q/final_and_proper_fix_to_mc2025_simple_reliable/ # Default: true - B:mc2025Fix=true + B:mc2025Fix=false # Fixes MC-64836, which causes non-player entities to be allowed to control minecarts using their AI. # Default: true @@ -154,7 +154,7 @@ misc { # Fixes MC-5694, which causes fast mining to sometimes only destroy blocks client-side only. # Default: true - B:miningGhostBlocksFix=true + B:miningGhostBlocksFix=false # Fixes MC-10369 (server-side particle spawning not creating particles for clients) and MC-93826 (breeding hearts only showing once instead of all of the time an animal can breed). # Default: true diff --git a/overrides/config-overrides/normal/randompatches.cfg b/overrides/config-overrides/normal/randompatches.cfg index 6ab32e2..2fbd597 100644 --- a/overrides/config-overrides/normal/randompatches.cfg +++ b/overrides/config-overrides/normal/randompatches.cfg @@ -146,7 +146,7 @@ misc { # Fixes MC-2025. # More information can be found here: https://www.reddit.com/r/Mojira/comments/8pgd4q/final_and_proper_fix_to_mc2025_simple_reliable/ # Default: true - B:mc2025Fix=true + B:mc2025Fix=false # Fixes MC-64836, which causes non-player entities to be allowed to control minecarts using their AI. # Default: true @@ -154,7 +154,7 @@ misc { # Fixes MC-5694, which causes fast mining to sometimes only destroy blocks client-side only. # Default: true - B:miningGhostBlocksFix=true + B:miningGhostBlocksFix=false # Fixes MC-10369 (server-side particle spawning not creating particles for clients) and MC-93826 (breeding hearts only showing once instead of all of the time an animal can breed). # Default: true diff --git a/overrides/config/randompatches.cfg b/overrides/config/randompatches.cfg index 6ab32e2..2fbd597 100644 --- a/overrides/config/randompatches.cfg +++ b/overrides/config/randompatches.cfg @@ -146,7 +146,7 @@ misc { # Fixes MC-2025. # More information can be found here: https://www.reddit.com/r/Mojira/comments/8pgd4q/final_and_proper_fix_to_mc2025_simple_reliable/ # Default: true - B:mc2025Fix=true + B:mc2025Fix=false # Fixes MC-64836, which causes non-player entities to be allowed to control minecarts using their AI. # Default: true @@ -154,7 +154,7 @@ misc { # Fixes MC-5694, which causes fast mining to sometimes only destroy blocks client-side only. # Default: true - B:miningGhostBlocksFix=true + B:miningGhostBlocksFix=false # Fixes MC-10369 (server-side particle spawning not creating particles for clients) and MC-93826 (breeding hearts only showing once instead of all of the time an animal can breed). # Default: true diff --git a/tools/gulpfile.ts b/tools/gulpfile.ts index 027b4c8..f344133 100644 --- a/tools/gulpfile.ts +++ b/tools/gulpfile.ts @@ -1,4 +1,4 @@ -// noinspection JSUnusedGlobalSymbols +// noinspection JSUnusedGlobalSymbols,UnnecessaryLocalVariableJS import * as gulp from "gulp"; @@ -8,23 +8,13 @@ export const pruneCache = pruneCacheTask; import * as quest from "./tasks/github/quest"; export const transformQB = quest.transformQuestBook; -import * as releaseCommit from "./tasks/misc/releaseCommit"; -export const checkRelease = releaseCommit.check; - -// Normal Tasks -export const addVersionIssue = gulp.series(checkRelease, releaseCommit.updateIssueTemplates); -export const addVersionRandomPatches = gulp.series(checkRelease, releaseCommit.updateRandomPatchesConfig); -export const addVersionServer = gulp.series(checkRelease, releaseCommit.updateServerProperties); -export const addVersionMainMenu = gulp.series(checkRelease, releaseCommit.updateMainMenuConfig); -export const addVersionAll = gulp.series(checkRelease, releaseCommit.updateAll); - -// Non Release Tasks -const setNotRelease = releaseCommit.setNotRelease; -export const updateTemplatesIssue = gulp.series(setNotRelease, addVersionIssue); -export const updateTemplatesRandomPatches = gulp.series(setNotRelease, addVersionRandomPatches); -export const updateTemplatesServer = gulp.series(setNotRelease, addVersionServer); -export const updateTemplatesMainMenu = gulp.series(setNotRelease, addVersionMainMenu); -export const updateTemplatesAll = gulp.series(setNotRelease, addVersionAll); +import * as transformFiles from "./tasks/misc/transformFiles"; +export const updateFilesIssue = transformFiles.updateFilesIssue; +export const updateFilesRandomPatches = transformFiles.updateFilesRandomPatches; +export const updateFilesServer = transformFiles.updateFilesServer; +export const updateFilesMainMenu = transformFiles.updateFilesMainMenu; +export const updateFilesBuild = transformFiles.updateFilesBuild; +export const updateFilesAll = transformFiles.updateAll; import * as changelog from "./tasks/changelog/createChangelog"; export const createChangelog = changelog.createRootChangelog; @@ -37,10 +27,13 @@ import mmcTasks from "./tasks/mmc"; import modTasks from "./tasks/misc/downloadMods"; export const buildClient = gulp.series(sharedTasks, clientTasks); -export const buildServer = gulp.series(sharedTasks, modTasks, serverTasks); +export const buildServer = gulp.series(gulp.parallel(sharedTasks, modTasks), serverTasks); export const buildLang = gulp.series(sharedTasks, langTasks); -export const buildMMC = gulp.series(sharedTasks, modTasks, clientTasks, mmcTasks); -export const buildAll = gulp.series(sharedTasks, modTasks, gulp.series(clientTasks, langTasks, serverTasks, mmcTasks)); +export const buildMMC = gulp.series(gulp.parallel(sharedTasks, modTasks), clientTasks, mmcTasks); +export const buildAll = gulp.series( + gulp.parallel(sharedTasks, modTasks), + gulp.series(gulp.parallel(clientTasks, langTasks, serverTasks), mmcTasks), +); import checkTasks from "./tasks/checks"; export const check = gulp.series(checkTasks); @@ -52,6 +45,8 @@ export const zipLang = zip.zipLang; export const zipMMC = zip.zipMMC; export const zipAll = zip.zipAll; +exports.default = gulp.series(buildAll, zipAll); + import * as gha from "./tasks/misc/gha"; export const makeArtifactNames = gha.makeArtifactNames; diff --git a/tools/package-lock.json b/tools/package-lock.json index 796bfa2..d46a819 100644 --- a/tools/package-lock.json +++ b/tools/package-lock.json @@ -9,6 +9,7 @@ "version": "1.2.2", "license": "LGPL-3.0", "dependencies": { + "@actions/core": "^1.10.1", "@egjs/list-differ": "^1.0.1", "@iarna/toml": "^2.2.5", "@types/iarna__toml": "^2.0.5", @@ -61,6 +62,32 @@ "upath": "^2.0.1" } }, + "node_modules/@actions/core": { + "version": "1.10.1", + "resolved": "https://registry.npmjs.org/@actions/core/-/core-1.10.1.tgz", + "integrity": "sha512-3lBR9EDAY+iYIpTnTIXmWcNbX3T2kCkAEQGIQx4NVQ0575nk2k3GRZDTPQG+vVtS2izSLmINlxXf0uLtnrTP+g==", + "dependencies": { + "@actions/http-client": "^2.0.1", + "uuid": "^8.3.2" + } + }, + "node_modules/@actions/core/node_modules/uuid": { + "version": "8.3.2", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz", + "integrity": "sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==", + "bin": { + "uuid": "dist/bin/uuid" + } + }, + "node_modules/@actions/http-client": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/@actions/http-client/-/http-client-2.2.0.tgz", + "integrity": "sha512-q+epW0trjVUUHboliPb4UF9g2msf+w61b32tAkFEwL/IwP0DQWgbCMM0Hbe3e3WXSKz5VcUXbzJQgy8Hkra/Lg==", + "dependencies": { + "tunnel": "^0.0.6", + "undici": "^5.25.4" + } + }, "node_modules/@babel/code-frame": { "version": "7.12.11", "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.12.11.tgz", @@ -210,6 +237,14 @@ "node": ">= 4" } }, + "node_modules/@fastify/busboy": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/@fastify/busboy/-/busboy-2.1.0.tgz", + "integrity": "sha512-+KpH+QxZU7O4675t3mnkQKcZZg56u+K/Ct2K+N2AZYNVK8kyeo/bI18tI8aPm3tvNNRyTWfj6s5tnGNlcbQRsA==", + "engines": { + "node": ">=14" + } + }, "node_modules/@humanwhocodes/config-array": { "version": "0.5.0", "resolved": "https://registry.npmjs.org/@humanwhocodes/config-array/-/config-array-0.5.0.tgz", @@ -11029,6 +11064,14 @@ "typescript": ">=2.8.0 || >= 3.2.0-dev || >= 3.3.0-dev || >= 3.4.0-dev || >= 3.5.0-dev || >= 3.6.0-dev || >= 3.6.0-beta || >= 3.7.0-dev || >= 3.7.0-beta" } }, + "node_modules/tunnel": { + "version": "0.0.6", + "resolved": "https://registry.npmjs.org/tunnel/-/tunnel-0.0.6.tgz", + "integrity": "sha512-1h/Lnq9yajKY2PEbBadPXj3VxsDDu844OnaAo52UVmIzIvwwtBPIuNvkjuzBlTWpfJyUbG3ez0KSBibQkj4ojg==", + "engines": { + "node": ">=0.6.11 <=0.7.0 || >=0.7.3" + } + }, "node_modules/tunnel-agent": { "version": "0.6.0", "resolved": "https://registry.npmjs.org/tunnel-agent/-/tunnel-agent-0.6.0.tgz", @@ -11168,6 +11211,17 @@ "integrity": "sha512-Ia0sQNrMPXXkqVFt6w6M1n1oKo3NfKs+mvaV811Jwir7vAk9a6PVV9VPYf6X3BU97QiLEmuW3uXH9u87zDFfdw==", "dev": true }, + "node_modules/undici": { + "version": "5.28.2", + "resolved": "https://registry.npmjs.org/undici/-/undici-5.28.2.tgz", + "integrity": "sha512-wh1pHJHnUeQV5Xa8/kyQhO7WFa8M34l026L5P/+2TYiakvGy5Rdc8jWZVyG7ieht/0WgJLEd3kcU5gKx+6GC8w==", + "dependencies": { + "@fastify/busboy": "^2.0.0" + }, + "engines": { + "node": ">=14.0" + } + }, "node_modules/union-value": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/union-value/-/union-value-1.0.1.tgz", @@ -11814,6 +11868,31 @@ } }, "dependencies": { + "@actions/core": { + "version": "1.10.1", + "resolved": "https://registry.npmjs.org/@actions/core/-/core-1.10.1.tgz", + "integrity": "sha512-3lBR9EDAY+iYIpTnTIXmWcNbX3T2kCkAEQGIQx4NVQ0575nk2k3GRZDTPQG+vVtS2izSLmINlxXf0uLtnrTP+g==", + "requires": { + "@actions/http-client": "^2.0.1", + "uuid": "^8.3.2" + }, + "dependencies": { + "uuid": { + "version": "8.3.2", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz", + "integrity": "sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==" + } + } + }, + "@actions/http-client": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/@actions/http-client/-/http-client-2.2.0.tgz", + "integrity": "sha512-q+epW0trjVUUHboliPb4UF9g2msf+w61b32tAkFEwL/IwP0DQWgbCMM0Hbe3e3WXSKz5VcUXbzJQgy8Hkra/Lg==", + "requires": { + "tunnel": "^0.0.6", + "undici": "^5.25.4" + } + }, "@babel/code-frame": { "version": "7.12.11", "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.12.11.tgz", @@ -11937,6 +12016,11 @@ } } }, + "@fastify/busboy": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/@fastify/busboy/-/busboy-2.1.0.tgz", + "integrity": "sha512-+KpH+QxZU7O4675t3mnkQKcZZg56u+K/Ct2K+N2AZYNVK8kyeo/bI18tI8aPm3tvNNRyTWfj6s5tnGNlcbQRsA==" + }, "@humanwhocodes/config-array": { "version": "0.5.0", "resolved": "https://registry.npmjs.org/@humanwhocodes/config-array/-/config-array-0.5.0.tgz", @@ -20487,6 +20571,11 @@ "tslib": "^1.8.1" } }, + "tunnel": { + "version": "0.0.6", + "resolved": "https://registry.npmjs.org/tunnel/-/tunnel-0.0.6.tgz", + "integrity": "sha512-1h/Lnq9yajKY2PEbBadPXj3VxsDDu844OnaAo52UVmIzIvwwtBPIuNvkjuzBlTWpfJyUbG3ez0KSBibQkj4ojg==" + }, "tunnel-agent": { "version": "0.6.0", "resolved": "https://registry.npmjs.org/tunnel-agent/-/tunnel-agent-0.6.0.tgz", @@ -20597,6 +20686,14 @@ "integrity": "sha512-UR1khWeAjugW3548EfQmL9Z7pGMlBgXteQpr1IZeZBtnkCJQJIJ1Scj0mb9wQaPvUZ9Q17XqW6TIaPchJkyfqw==", "dev": true }, + "undici": { + "version": "5.28.2", + "resolved": "https://registry.npmjs.org/undici/-/undici-5.28.2.tgz", + "integrity": "sha512-wh1pHJHnUeQV5Xa8/kyQhO7WFa8M34l026L5P/+2TYiakvGy5Rdc8jWZVyG7ieht/0WgJLEd3kcU5gKx+6GC8w==", + "requires": { + "@fastify/busboy": "^2.0.0" + } + }, "union-value": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/union-value/-/union-value-1.0.1.tgz", diff --git a/tools/package.json b/tools/package.json index 835b84b..9f80ad1 100644 --- a/tools/package.json +++ b/tools/package.json @@ -50,6 +50,7 @@ "upath": "^2.0.1" }, "dependencies": { + "@actions/core": "^1.10.1", "@egjs/list-differ": "^1.0.1", "@iarna/toml": "^2.2.5", "@types/iarna__toml": "^2.0.5", diff --git a/tools/tasks/changelog/changelogData.ts b/tools/tasks/changelog/changelogData.ts index d755f6b..a3aa569 100644 --- a/tools/tasks/changelog/changelogData.ts +++ b/tools/tasks/changelog/changelogData.ts @@ -42,7 +42,7 @@ export default class ChangelogData { // See if current run is test if (isEnvVariableSet("TEST_CHANGELOG")) { try { - this.isTest = JSON.parse(process.env.TEST_CHANGELOG); + this.isTest = JSON.parse(process.env.TEST_CHANGELOG.toLowerCase()); } catch (err) { throw new Error("Test Changelog Env Variable set to Invalid Value."); } diff --git a/tools/tasks/lang/index.ts b/tools/tasks/lang/index.ts index b645c74..75612dd 100644 --- a/tools/tasks/lang/index.ts +++ b/tools/tasks/lang/index.ts @@ -7,7 +7,7 @@ import { langDestDirectory, overridesFolder, sharedDestDirectory } from "../../g import fs from "fs"; /** - * Checks and creates all necessary directories so we can build the client safely. + * Checks and creates all necessary directories so we can build the lang safely. */ async function createLangDirs() { if (!fs.existsSync(langDestDirectory)) { diff --git a/tools/tasks/misc/gha.ts b/tools/tasks/misc/gha.ts index 4030816..914909d 100644 --- a/tools/tasks/misc/gha.ts +++ b/tools/tasks/misc/gha.ts @@ -1,6 +1,7 @@ import { modpackManifest } from "../../globals"; import { makeArtifactNameBody } from "../../util/util"; import sanitize from "sanitize-filename"; +import { setOutput } from "@actions/core"; export async function makeArtifactNames(): Promise { const body = makeArtifactNameBody(modpackManifest.name); @@ -8,9 +9,10 @@ export async function makeArtifactNames(): Promise { client: body + "-client", server: body + "-server", lang: body + "-lang", + mmc: body + "-mmc", }; Object.keys(names).forEach((name) => { - console.log(`::set-output name=${name}::${sanitize(names[name].toLowerCase())}`); + setOutput(name, sanitize(names[name].toLowerCase())); }); } diff --git a/tools/tasks/misc/releaseCommit.ts b/tools/tasks/misc/transformFiles.ts similarity index 61% rename from tools/tasks/misc/releaseCommit.ts rename to tools/tasks/misc/transformFiles.ts index 2d519fe..61a4cfd 100644 --- a/tools/tasks/misc/releaseCommit.ts +++ b/tools/tasks/misc/transformFiles.ts @@ -4,90 +4,85 @@ import { configFolder, configOverridesFolder, rootDirectory, templatesFolder } f import mustache from "mustache"; import gulp from "gulp"; import dedent from "dedent-js"; -import { checkEnvironmentalVariables } from "../../util/util"; +import { isEnvVariableSet } from "../../util/util"; import sortedStringify from "json-stable-stringify-without-jsonify"; -import log, { error } from "fancy-log"; +import { error } from "fancy-log"; +import { BuildData } from "../../types/transformFiles"; // This updates all the files, for a release. -// IF DEBUGGING: -// Change debug value to true -// Change version to a string -const debug = false; -const version: string = process.env.VERSION; +// If it is not a release or build, and thus no changes to versions need to be made. +// This occurs when the files are to be updated from the templates outside of a release or a build. +let updateFiles: boolean; +let updateFileVersion: string; +let updateFileTransformedVersion: string; -// If it is not a release, and thus no changes to versions need to be made. -// This occurs when the files are to be updated from the templates outside of a release. -// Optional variable to set. -let notRelease = false; +let buildData: BuildData; -/** - * Checks if env variable are set, creates versions.txt if file does not exist, and checks if new version already exists in versions.txt. - */ -export async function check(): Promise { - if (!debug) { - checkEnvironmentalVariables(["VERSION"]); - } - const versionsFilePath: string = upath.join(templatesFolder, "versions.txt"); - - if (notRelease) { - log("Detected that this is not a release commit."); - log("Version info will not change, but the files will be updated from the template."); - await checkNotRelease(versionsFilePath); - } else { - log("Detected that this is a release commit."); - await checkRelease(versionsFilePath); - } -} - -/** - * Sets this workflow as a non-release. - */ -export async function setNotRelease(): Promise { - notRelease = true; -} - -// Checks for non-release commits -async function checkNotRelease(versionsFilePath: string) { - // Check if versions.txt exists - if (!fs.existsSync(versionsFilePath)) { - error(`Version.txt does not exist. Creating empty file, and adding ${version} to it. This may be an error.`); - - // Create Versions.txt, with version - await fs.promises.writeFile(versionsFilePath, ` - ${version}`); - } else { - // Check for duplicate entries - let versionList = await fs.promises.readFile(versionsFilePath, "utf8"); - - // No Duplicate Key - if (!versionList.includes(version)) { - error(`Version is not in version.txt. Adding ${version} to version.txt. This may be an error.`); - - versionList = ` - ${version}\n${versionList}`; - await fs.promises.writeFile(versionsFilePath, versionList); +async function updateFilesSetup(): Promise { + updateFiles = false; + // See if current run is to update files + if (isEnvVariableSet("UPDATE_FILES")) { + try { + updateFiles = JSON.parse(process.env.UPDATE_FILES.toLowerCase()); + } catch (err) { + throw new Error("Update Files Env Variable set to Invalid Value."); } } -} + buildData = new BuildData(); -// Checks for release Commits -async function checkRelease(versionsFilePath: string) { - // Check if versions.txt exists + const versionsFilePath: string = upath.join(templatesFolder, "versions.txt"); + updateFileVersion = ""; + + if (!buildData.isVersionBuild() && !updateFiles) return; + + // Versions.txt handling if (!fs.existsSync(versionsFilePath)) { + if (updateFiles) { + if (!buildData.isVersionBuild()) + throw new Error( + "In order to update files, needs versions.txt to exist and have values, or the version to be set via the GITHUB_TAG environmental variable.", + ); + updateFileVersion = buildData.rawVersion; + updateFileTransformedVersion = buildData.transformedVersion; + return; + } error("Version.txt does not exist. Creating empty file. This may be an error."); // Create Versions.txt fs.closeSync(fs.openSync(versionsFilePath, "w")); } else { - // Check for duplicate entries const versionList = await fs.promises.readFile(versionsFilePath, "utf8"); + if (updateFiles) { + if (!versionList) { + if (!buildData.isVersionBuild()) + throw new Error( + "In order to update files, needs versions.txt to exist and have values, or the version to be set via the GITHUB_TAG environmental variable.", + ); + updateFileVersion = buildData.rawVersion; + updateFileTransformedVersion = buildData.transformedVersion; + return; + } + updateFileVersion = versionList.split("\n")[0].replace("-", "").trim(); + updateFileTransformedVersion = `v${updateFileVersion}`; + return; + } + // Duplicate Key - if (versionList.includes(`${version}\n`)) { + if (versionList.includes(`${buildData.rawVersion}\n`)) { throw new Error("Version already exists in version.txt. Exiting..."); } } } +async function updateFilesBuildSetup(): Promise { + updateFiles = true; + buildData = new BuildData(); + updateFileVersion = buildData.rawVersion; + updateFileTransformedVersion = buildData.transformedVersion; +} + /** * @param readPath The filepath to read from. (Template) * @param writePaths The filepaths to write to. @@ -114,7 +109,7 @@ async function modifyFile(readPath: string, writePaths: string[], replacementObj } } -export async function updateIssueTemplates(): Promise { +async function updateIssueTemplates(): Promise { // Filenames const fileNames: string[] = ["001-bug-report.yml", "002-feature-request.yml"]; @@ -122,9 +117,13 @@ export async function updateIssueTemplates(): Promise { let versionList: string = await fs.promises.readFile(versionsFilePath, "utf8"); - if (!notRelease) { + if (!updateFiles) { + if (!buildData.isVersionBuild()) + throw new Error( + "In order to update Issue Templates, the version must be set via the GITHUB_TAG environmental variable.", + ); // Add new version to list, with indent - versionList = ` - ${version}\n${versionList}`; + versionList = ` - ${buildData.rawVersion}\n${versionList}`; } // Replacement Object @@ -145,7 +144,7 @@ export async function updateIssueTemplates(): Promise { } } -export async function updateRandomPatchesConfig(): Promise { +async function updateRandomPatchesConfig(): Promise { // Filename & paths const fileName = "randompatches.cfg"; const readPath: string = upath.join(templatesFolder, fileName); @@ -156,7 +155,7 @@ export async function updateRandomPatchesConfig(): Promise { // Replacement object const replacementObject: Record = { - version: version, + versionTitle: updateFiles ? updateFileTransformedVersion : buildData.transformedVersion, mode: "Normal", }; @@ -171,7 +170,7 @@ export async function updateRandomPatchesConfig(): Promise { await modifyFile(readPath, [writePathExpert], replacementObject); } -export async function updateServerProperties(): Promise { +async function updateServerProperties(): Promise { // File name of the output files const fileName = "server.properties"; @@ -183,7 +182,7 @@ export async function updateServerProperties(): Promise { // Replacement Object const replacementObject: Record = { - version: version, + versionTitle: updateFiles ? updateFileTransformedVersion : buildData.transformedVersion, }; // Read and Write paths for normal @@ -204,15 +203,20 @@ export async function updateServerProperties(): Promise { await modifyFile(readPathExpert, [writePathExpert], replacementObject); } -export async function updateMainMenuConfig(): Promise { +async function updateMainMenuConfig(): Promise { // Filename & paths const fileName = "mainmenu.json"; const readPath: string = upath.join(templatesFolder, fileName); const writePath: string = upath.join(rootDirectory, configFolder, "CustomMainMenu", fileName); + if (!updateFiles && !buildData.isVersionBuild()) + throw new Error( + "The main menu should only be updated if the version is set via the GITHUB_TAG environmental variable.", + ); + // Replacement object const replacementObject: Record = { - version: version, + version: updateFiles ? updateFileVersion : buildData.rawVersion, }; // Read file @@ -229,7 +233,14 @@ export async function updateMainMenuConfig(): Promise { return await fs.promises.writeFile(writePath, sortedStringify(modifiedData, { space: 2 }), "utf8"); } +export const updateFilesIssue = gulp.series(updateFilesSetup, updateIssueTemplates); +export const updateFilesRandomPatches = gulp.series(updateFilesSetup, updateRandomPatchesConfig); +export const updateFilesServer = gulp.series(updateFilesSetup, updateServerProperties); +export const updateFilesMainMenu = gulp.series(updateFilesSetup, updateMainMenuConfig); +export const updateFilesBuild = gulp.series(updateFilesBuildSetup, updateRandomPatchesConfig, updateServerProperties); + export const updateAll = gulp.series( + updateFilesSetup, updateIssueTemplates, updateRandomPatchesConfig, updateServerProperties, diff --git a/tools/tasks/misc/zip.ts b/tools/tasks/misc/zip.ts index ec50e64..146e714 100644 --- a/tools/tasks/misc/zip.ts +++ b/tools/tasks/misc/zip.ts @@ -43,4 +43,4 @@ export const zipClient = makeZipper(clientDestDirectory, "Client"); export const zipLang = makeZipper(langDestDirectory, "Lang"); export const zipMMC = makeZipper(mmcDestDirectory, "MMC"); -export const zipAll = gulp.series(zipServer, zipClient, zipLang, zipMMC); +export const zipAll = gulp.parallel(zipServer, zipClient, zipLang, zipMMC); diff --git a/tools/tasks/shared/index.ts b/tools/tasks/shared/index.ts index d09297d..b729e10 100644 --- a/tools/tasks/shared/index.ts +++ b/tools/tasks/shared/index.ts @@ -131,10 +131,12 @@ import transformVersion from "./transformVersion"; import { createBuildChangelog } from "../changelog/createChangelog"; import mustache from "mustache"; import log from "fancy-log"; +import { updateFilesBuild } from "../misc/transformFiles"; export default gulp.series( sharedCleanUp, createSharedDirs, + updateFilesBuild, copyOverrides, fetchOrMakeChangelog, fetchExternalDependencies, diff --git a/tools/tasks/shared/transformVersion.ts b/tools/tasks/shared/transformVersion.ts index f95521c..e135077 100644 --- a/tools/tasks/shared/transformVersion.ts +++ b/tools/tasks/shared/transformVersion.ts @@ -25,6 +25,4 @@ export default async function transformManifestVersion(): Promise { } else { modpackManifest.version = "manual-build"; } - - modpackManifest.name = ""; } diff --git a/tools/templates/001-bug-report.yml b/tools/templates/001-bug-report.yml index c1b38fa..69ad99e 100644 --- a/tools/templates/001-bug-report.yml +++ b/tools/templates/001-bug-report.yml @@ -9,9 +9,9 @@ body: id: version attributes: label: Nomi CEu Version - description: The version of Nomi CEu you were using when this bug was encountered. If you do not know what it is, check the title of your instance window. If you do not see your version here, please update to the newest version of the pack, which currently is 1.6, or the newest alpha/beta, which currently is 1.6.1-beta-2. + description: The version of Nomi CEu you were using when this bug was encountered. If you do not know what it is, check the title of your instance window. If you do not see your version here, please update to the newest alpha, beta or release of the pack. options: -{{versions}} +{{{versions}}} validations: required: true @@ -74,14 +74,17 @@ body: id: reproduction attributes: label: Reproduction Steps - description: "How do you trigger this bug? Please walk us through it step by step." + description: | + How do you trigger this bug? Please walk us through it step by step. + + Please leave this field blank if this is not applicable. (Quest Isuses, JEI Issues, Tooltip Issues, etc.) placeholder: | 1. 2. 3. ... validations: - required: true + required: false - type: textarea id: logs attributes: diff --git a/tools/templates/002-feature-request.yml b/tools/templates/002-feature-request.yml index 4455531..7a54d9c 100644 --- a/tools/templates/002-feature-request.yml +++ b/tools/templates/002-feature-request.yml @@ -9,9 +9,9 @@ body: id: version attributes: label: Nomi CEu Version - description: The version of Nomi CEu you are using as the basis for this feature request. If you do not know what it is, check the title of your instance window. If you do not see your version here, please update to the newest version of the pack, which currently is 1.6, or the newest alpha/beta, which currently is 1.6.1-beta-2. + description: The version of Nomi CEu you are using as the basis for this feature request. If you do not know what it is, check the title of your instance window. f you do not see your version here, please update to the newest alpha, beta or release of the pack. options: -{{versions}} +{{{versions}}} validations: required: true diff --git a/tools/templates/mainmenu.json b/tools/templates/mainmenu.json index 6445d53..89ba541 100644 --- a/tools/templates/mainmenu.json +++ b/tools/templates/mainmenu.json @@ -78,7 +78,7 @@ "alignment": "left_center", "action": { "type": "openLink", - "link": "https://github.com/Nomi-CEu/Nomi-CEu/releases/tag/{{version}}" + "link": "https://github.com/Nomi-CEu/Nomi-CEu/releases/tag/{{{version}}}" } }, "discord": { diff --git a/tools/templates/randompatches.cfg b/tools/templates/randompatches.cfg index 4ecdbff..c0b6c8f 100644 --- a/tools/templates/randompatches.cfg +++ b/tools/templates/randompatches.cfg @@ -110,7 +110,7 @@ client { # The Minecraft window title. # Default: Minecraft 1.12.2 - S:title=Nomifactory CEu, v{{version}}, {{mode}} Mode + S:title=Nomifactory CEu, {{{versionTitle}}}, {{mode}} Mode } } diff --git a/tools/templates/server_expert.properties b/tools/templates/server_expert.properties index c16a01a..f9bd307 100644 --- a/tools/templates/server_expert.properties +++ b/tools/templates/server_expert.properties @@ -27,6 +27,6 @@ max-players=20 spawn-monsters=true view-distance=10 generate-structures=true -motd=Nomi CEu Server, v{{version}}, Expert Mode +motd=Nomi CEu Server, {{{versionTitle}}}, Expert Mode level-type=lostcities generator-settings= diff --git a/tools/templates/server_normal.properties b/tools/templates/server_normal.properties index e11f813..bd5d437 100644 --- a/tools/templates/server_normal.properties +++ b/tools/templates/server_normal.properties @@ -27,6 +27,6 @@ max-players=20 spawn-monsters=true view-distance=10 generate-structures=true -motd=Nomi CEu Server, v{{version}}, Normal Mode +motd=Nomi CEu Server, {{{versionTitle}}}, Normal Mode level-type=lostcities generator-settings= diff --git a/tools/types/transformFiles.ts b/tools/types/transformFiles.ts new file mode 100644 index 0000000..6792a4f --- /dev/null +++ b/tools/types/transformFiles.ts @@ -0,0 +1,46 @@ +export type BuildType = "GITHUB_TAG" | "HEAD_REF" | "GITHUB_SHA" | "MANUAL_BUILD"; + +export class BuildData { + public type: BuildType; + public transformedVersion: string; + public rawVersion: string; + + constructor() { + // We're building a tag/version. + if (process.env.GITHUB_TAG) { + this.type = "GITHUB_TAG"; + this.rawVersion = process.env.GITHUB_TAG.replace(/^v/, ""); + this.transformedVersion = + process.env.GITHUB_TAG.search(/^v/) === -1 ? `v${process.env.GITHUB_TAG}` : process.env.GITHUB_TAG; + } + // 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); + this.type = "HEAD_REF"; + this.rawVersion = `${process.env.GITHUB_HEAD_REF}-${shortCommit}`; + this.transformedVersion = `PR Build (${process.env.GITHUB_HEAD_REF} branch, ${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}`); + } + + this.type = "GITHUB_SHA"; + this.rawVersion = `${branch}-${shortCommit}`; + this.transformedVersion = `Nightly Build (${branch} branch, ${shortCommit})`; + } + // Manual Build + else { + this.type = "MANUAL_BUILD"; + this.rawVersion = "manual-build"; + this.transformedVersion = "Manual Build"; + } + } + + public isVersionBuild(): boolean { + return this.type === "GITHUB_TAG"; + } +} diff --git a/tools/util/util.ts b/tools/util/util.ts index 03f9762..3ca6aed 100644 --- a/tools/util/util.ts +++ b/tools/util/util.ts @@ -149,9 +149,9 @@ export async function downloadOrRetrieveFileDef(fileDef: FileDef): Promise { let hashFailed = false; const retryStrategy = (err: Error, response: http.IncomingMessage, body: unknown) => { - if (response.statusCode === 404) { - throw new Error(`URL ${fileDef.url} returned status 404.`); - } + if (!response) return requestretry.RetryStrategies.HTTPOrNetworkError(err, response, body); + if (response.statusCode === 404) throw new Error(`URL ${fileDef.url} returned status 404.`); + // Verify hashes. if (!err && fileDef.hashes && body) { const success = fileDef.hashes.every((hashDef) => {