From 84e1c03547827dac24eefcaf8dfe03ac6ea2cc6a Mon Sep 17 00:00:00 2001 From: Yair Morgenstern Date: Tue, 28 Nov 2023 11:06:40 +0200 Subject: [PATCH] Added patch automation step! --- .github/workflows/releasePatch.js | 10 ++++++---- .github/workflows/uncivbot.yml | 26 ++++++++++++++++++++++++++ 2 files changed, 32 insertions(+), 4 deletions(-) diff --git a/.github/workflows/releasePatch.js b/.github/workflows/releasePatch.js index 9f20a7d1df..ac1fec38fe 100644 --- a/.github/workflows/releasePatch.js +++ b/.github/workflows/releasePatch.js @@ -10,6 +10,7 @@ const fs = require("fs"); (async () => { const [newVersion, newAppCodeNumber] = updateBuildConfig(); updateGameVersion(newVersion, newAppCodeNumber); + console.log(newVersion) })(); //endregion @@ -29,7 +30,7 @@ function updateBuildConfig() { var buildConfigPath = "buildSrc/src/main/kotlin/BuildConfig.kt"; var buildConfigString = fs.readFileSync(buildConfigPath).toString(); - console.log("Original: " + buildConfigString); +// console.log("Original: " + buildConfigString); // Javascript string.match returns a regex string array, where array[0] is the entirety of the captured string, // and array[1] is the first group, array[2] is the second group etc. @@ -37,17 +38,18 @@ function updateBuildConfig() { var appVersionMatch = buildConfigString.match(/appVersion = "(.*)"/); const curVersion = appVersionMatch[1]; const newVersion = getNextPatchVersion(curVersion) +// console.log("New version: "+newVersion) buildConfigString = buildConfigString.replace(appVersionMatch[0], appVersionMatch[0].replace(curVersion, newVersion)); var appCodeNumberMatch = buildConfigString.match(/appCodeNumber = (\d*)/); let currentAppCodeNumber = appCodeNumberMatch[1]; - console.log("Current incremental version: " + currentAppCodeNumber); +// console.log("Current incremental version: " + currentAppCodeNumber); const nextAppCodeNumber = Number(currentAppCodeNumber) + 1; - console.log("Next incremental version: " + nextAppCodeNumber); +// console.log("Next incremental version: " + nextAppCodeNumber); buildConfigString = buildConfigString.replace(appCodeNumberMatch[0], appCodeNumberMatch[0].replace(currentAppCodeNumber, nextAppCodeNumber)); - console.log("Final: " + buildConfigString); +// console.log("Final: " + buildConfigString); fs.writeFileSync(buildConfigPath, buildConfigString); return [newVersion, nextAppCodeNumber]; } diff --git a/.github/workflows/uncivbot.yml b/.github/workflows/uncivbot.yml index fa1fb48e2b..319665bde7 100644 --- a/.github/workflows/uncivbot.yml +++ b/.github/workflows/uncivbot.yml @@ -34,6 +34,32 @@ jobs: npm i @octokit/rest node .github/workflows/mergeTranslations.js ${{ secrets.ACTIONS_ACCESS_TOKEN }} ${{ github.event.issue.number }} version_rollout + release_patch_version: + if: github.event_name == 'issue_comment' && (github.event.comment.body == 'release patch') && contains(fromJSON('["OWNER", "MEMBER", "COLLABORATOR"]'), github.event.comment.author_association) + # This is the only place I could find an apparent list of valid author associations. Also, at least they're not case-sensitive: https://docs.github.com/en/graphql/reference/enums#commentauthorassociation https://docs.github.com/en/actions/learn-github-actions/expressions#contains + runs-on: ubuntu-latest + steps: + + - name: Merge Pull Request + uses: juliangruber/merge-pull-request-action@v1 + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + number: 1 + method: squash + repo: juliangruber/octokit-action + + - uses: actions/checkout@v3 + - uses: actions/setup-node@v2 + + - name: Increment version and release + run: | + export version=$(node .github/workflows/incrementVersionAndChangelog.js) + + git add . + git commit -m "$version" + git tag $version + git push origin --tags + merge_translations: if: github.event_name == 'workflow_dispatch' || (github.event.comment.body == 'merge translations' && contains(fromJSON('["OWNER", "MEMBER", "COLLABORATOR"]'), github.event.comment.author_association))