mirror of
https://github.com/yairm210/Unciv.git
synced 2025-01-07 05:51:12 +07:00
Documentation for the rollout changes, and replacing the old translation method with the new one
This commit is contained in:
parent
fb058f7849
commit
09ee742833
@ -43,11 +43,13 @@ async function main(){
|
||||
if (commitMessage.startsWith("Merge ") || commitMessage.startsWith("Update ")) return
|
||||
commitMessage = commitMessage.replace(/\(\#\d+\)/,"").replace(/\#\d+/,"") // match PR auto-text, like (#2345) or just #2345
|
||||
if (author != "yairm210"){
|
||||
if (ownerToCommits[author] == undefined) ownerToCommits[author]=[]
|
||||
ownerToCommits[author].push(commitMessage)
|
||||
if (ownerToCommits[author] == undefined) ownerToCommits[author]=[]
|
||||
ownerToCommits[author].push(commitMessage)
|
||||
}
|
||||
else commitSummary += "\n\n" + commitMessage
|
||||
}
|
||||
else commitSummary += "\n\n" + commitMessage
|
||||
});
|
||||
);
|
||||
|
||||
Object.entries(ownerToCommits).forEach(entry => {
|
||||
const [author, commits] = entry;
|
||||
if (commits.length==1) commitSummary += "\n\n" + commits[0] + " - By "+author
|
||||
|
182
.github/workflows/uncivbot.yml
vendored
182
.github/workflows/uncivbot.yml
vendored
@ -5,7 +5,55 @@ on:
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
update_wiki:
|
||||
|
||||
prepare_version_for_rollout:
|
||||
if: github.event_name == 'issue_comment' && (github.event.comment.body == 'summary' || github.event.comment.body == 'prepare version') && 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:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/setup-node@v2
|
||||
- name: Generate new buildConfig.kt and changelog.md files
|
||||
run: |
|
||||
npm i @octokit/rest
|
||||
|
||||
node .github/workflows/incrementVersionAndChangelog.js
|
||||
|
||||
rm -rf node_modules # Now we need to remove extraneous node.js parts before commit
|
||||
rm package-lock.json
|
||||
rm package.json
|
||||
|
||||
- name: Create new branch with changes
|
||||
uses: EndBug/add-and-commit@v8 # You can change this to use a specific version.
|
||||
with:
|
||||
new_branch: version_rollout
|
||||
|
||||
- name: Add translation PRs to the new branch, and PR the new branch to master
|
||||
run: |
|
||||
npm i @octokit/rest
|
||||
node .github/workflows/mergeTranslations.js ${{ secrets.ACTIONS_ACCESS_TOKEN }} ${{ github.event.issue.number }} version_rollout
|
||||
|
||||
|
||||
merge_translations:
|
||||
if: github.event_name == 'workflow_dispatch' || (github.event.comment.body == 'merge translations' && 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:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/setup-node@v2
|
||||
- name: Add translation PRs to the new branch, and PR the new branch to master
|
||||
|
||||
# SO, the story is that when using the default access token you CANNOT merge PRs from forks.
|
||||
# _Badly_ documented in multiple places, including here: https://docs.github.com/en/actions/reference/authentication-in-a-workflow
|
||||
# To get around this, we created a Personal Access Token,
|
||||
# put it as one of the secrets in the repo settings (https://github.com/yairm210/Unciv/settings/secrets/actions),
|
||||
# and use that instead.
|
||||
run: |
|
||||
npm i @octokit/rest
|
||||
node .github/workflows/mergeTranslations.js ${{ secrets.ACTIONS_ACCESS_TOKEN }} ${{ github.event.issue.number }} translations
|
||||
|
||||
|
||||
update_wiki: # This is old and no longer in use but DOES contain some clever gems so I'm leaving this in for now, gfeel free to delete at your leisure
|
||||
if: github.event_name == 'issue_comment' && github.event.issue.pull_request && github.event.comment.body == 'update wiki' && 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: https://docs.github.com/en/graphql/reference/enums#commentauthorassociation
|
||||
runs-on: ubuntu-latest
|
||||
@ -149,135 +197,3 @@ jobs:
|
||||
if (process.env.WIKIBOT_OUTCOME != 'success') {
|
||||
core.setFailed(`Failed at: ${process.env.WIKIBOT_STATUS}.`)
|
||||
}
|
||||
|
||||
prepare_version_for_rollout:
|
||||
if: github.event_name == 'issue_comment' && (github.event.comment.body == 'summary' || github.event.comment.body == 'prepare version') && 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:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/setup-node@v2
|
||||
- run: |
|
||||
npm i @octokit/rest
|
||||
|
||||
node .github/workflows/incrementVersionAndChangelog.js
|
||||
|
||||
rm -rf node_modules # Now we need to remove extraneous node.js parts before commit
|
||||
rm package-lock.json
|
||||
rm package.json
|
||||
|
||||
- uses: EndBug/add-and-commit@v8 # You can change this to use a specific version.
|
||||
with:
|
||||
new_branch: version_rollout
|
||||
|
||||
- name: Add translation PRs to the new branch, and PR the new branch to master
|
||||
run: |
|
||||
npm i @octokit/rest
|
||||
node .github/workflows/mergeTranslations.js ${{ secrets.ACTIONS_ACCESS_TOKEN }} ${{ github.event.issue.number }} version_rollout
|
||||
|
||||
|
||||
merge_translations:
|
||||
if: github.event_name == 'workflow_dispatch' || (github.event.comment.body == 'merge translations' && 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:
|
||||
- uses: actions/github-script@v3
|
||||
with:
|
||||
# SO, the story is that when using the default access token you CANNOT merge PRs from forks.
|
||||
# _Badly_ documented in multiple places, including here: https://docs.github.com/en/actions/reference/authentication-in-a-workflow
|
||||
# To get around this, we created a Personal Access Token,
|
||||
# put it as one of the secrets in the repo settings (https://github.com/yairm210/Unciv/settings/secrets/actions),
|
||||
# and use that instead.
|
||||
github-token: ${{ secrets.ACTIONS_ACCESS_TOKEN }}
|
||||
script: |
|
||||
|
||||
const repo = {
|
||||
owner: context.repo.owner,
|
||||
repo: context.repo.repo }
|
||||
|
||||
async function branchExists(branchName) {
|
||||
try {
|
||||
await github.git.getRef({...repo, ref: 'heads/' + branchName })
|
||||
return true
|
||||
} catch (err) {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
async function getDefaultBranch() {
|
||||
var repoData = await github.repos.get(repo)
|
||||
return repoData.data.default_branch
|
||||
}
|
||||
|
||||
var translations = "translations"
|
||||
|
||||
async function createTranslationBranchIfNeeded() {
|
||||
if (await branchExists(translations)) return
|
||||
var defaultBranch = await getDefaultBranch()
|
||||
|
||||
var currentHead = await github.git.getRef({...repo, ref: 'heads/' + defaultBranch })
|
||||
|
||||
var currentSha = currentHead.data.object.sha
|
||||
console.log("Current sha: " + currentSha)
|
||||
|
||||
await github.git.createRef({...repo,
|
||||
ref: `refs/heads/`+translations,
|
||||
sha: currentSha })
|
||||
|
||||
await github.issues.createComment({...repo,
|
||||
issue_number: context.issue.number,
|
||||
body: 'Translations branch created' })
|
||||
}
|
||||
|
||||
async function mergeExistingTranslationsIntoBranch(){
|
||||
var translationPrs = await github.pulls.list({ ...repo, state: "open" })
|
||||
|
||||
// When we used a forEach loop here, only one merge would happen at each run,
|
||||
// because we essentially started multiple async tasks in parallel and they conflicted.
|
||||
// Instead, we use X of Y as per https://stackoverflow.com/questions/37576685/using-async-await-with-a-foreach-loop
|
||||
for (const pr of translationPrs.data) {
|
||||
if (pr.labels.some(label => label.name == "mergeable translation"))
|
||||
await tryMergePr(pr)
|
||||
}
|
||||
}
|
||||
|
||||
async function tryMergePr(pr){
|
||||
if (pr.base.ref != translations)
|
||||
await github.pulls.update({ ...repo,
|
||||
pull_number: pr.number,
|
||||
base: translations })
|
||||
|
||||
try {
|
||||
await github.pulls.merge({...repo,
|
||||
pull_number: pr.number,
|
||||
merge_method: "squash" })
|
||||
console.log("Merged #"+pr.number+", "+pr.title)
|
||||
} catch (err) {
|
||||
console.log(err)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
async function createTranslationPrIfNeeded() {
|
||||
var translationPulls = await github.pulls.list({...repo,
|
||||
state: "open",
|
||||
head: context.repo.owner + ":" + translations });
|
||||
|
||||
if (translationPulls.data.length == 0) {
|
||||
var defaultBranch = await getDefaultBranch(context);
|
||||
await github.pulls.create({...repo,
|
||||
title: "Translations update",
|
||||
head: translations,
|
||||
base: defaultBranch });
|
||||
|
||||
await github.issues.createComment({...repo,
|
||||
issue_number: context.issue.number,
|
||||
body: 'Translations PR created' });
|
||||
}
|
||||
}
|
||||
|
||||
await createTranslationBranchIfNeeded()
|
||||
await mergeExistingTranslationsIntoBranch()
|
||||
await createTranslationPrIfNeeded()
|
||||
|
||||
|
@ -17,10 +17,11 @@ The process has two major parts, one is "Getting your code in the main repositor
|
||||
## Deploying versions
|
||||
|
||||
When I'm ready to release a new version I:
|
||||
* Comment "merge translations" in one of the open PRs tagged as 'mergeable translation' to trigger the translation branch creation, add a "summary" comment to trigger summary generation, merge the PR and delete the branch (so next version translation branch starts fresh)
|
||||
* Comment "prepare version" in one of the open PRs tagged as 'mergeable translation' to trigger the translation branch creation.
|
||||
This also bumps the versions in the buildConfig.kt file, and generates a starting version summary in changelog.md.
|
||||
Merge the PR and delete the branch (so next version branch starts fresh)
|
||||
* From my workstation - pull the latest changes and run the [translation generation](../Other/Translating.md#translation-generation---for-developers)
|
||||
* Change the versionCode and versionName in the Android build.gradle so that Google Play and F-droid can recognize that it's a different release
|
||||
* Add an entry in the changelog.md done, WITHOUT hashtags, and less than 500 characters (that's the limit for Google play entries). The formatting needs to be exact or the text sent to Discord, the Github release etc. won't be complete.
|
||||
* Edits to the autogenerated version notes in changelog.md to make them less than 500 chars (needed for Google Play) and more user-readable
|
||||
* Add a tag to the commit of the version. When the [Github action](https://github.com/yairm210/Unciv/actions/workflows/buildAndDeploy.yml) sees that we've added a tag, it will run a build, and this time (because of the configuration we put in the [yml file](/.github/workflows/buildAndDeploy.yml) file), it will:
|
||||
* Pack a .jar file, which will work for every operating system with Java
|
||||
* Use Linux and Windows JDKs to create standalone zips for 32 and 64 bit systems, because we can't rely on the fact that users will have a JRE
|
||||
|
Loading…
Reference in New Issue
Block a user