Added patch automation step!

This commit is contained in:
Yair Morgenstern 2023-11-28 11:06:40 +02:00
parent 18673b02b6
commit 84e1c03547
2 changed files with 32 additions and 4 deletions

View File

@ -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];
}

View File

@ -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))