Merge pull request #107 from ouchadam/feature/release-syncing

Sync release to main
This commit is contained in:
Adam Brown 2022-08-31 22:50:27 +01:00 committed by GitHub
commit cbad71b015
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 983 additions and 18 deletions

View File

@ -32,8 +32,10 @@ jobs:
mkdir .secrets
touch .secrets/upload-key.jks
touch .secrets/service-account.json
touch .secrets/matrix.json
echo -n '${{ secrets.UPLOAD_KEY }}' | base64 --decode >> .secrets/upload-key.jks
echo -n '${{ secrets.SERVICE_ACCOUNT }}' | base64 --decode >> .secrets/service-account.json
echo -n '${{ secrets.MATRIX }}' | base64 --decode >> .secrets/matrix.json
- name: Assemble release variant
run: ./tools/generate-release.sh ${{ secrets.STORE_PASS }}

View File

@ -6,7 +6,8 @@ const config = {
pathToVersionFile: "version.json",
rcBranchesFrom: "main",
rcMergesTo: "release",
packageName: "app.dapk.st"
packageName: "app.dapk.st",
matrixRoomId: "!jgNenzNPtSpJLjjsxe:matrix.org"
}
const rcBranchName = "release-candidate"
@ -22,14 +23,25 @@ export const startReleaseProcess = async ({ github, context, core }) => {
}
export const publishRelease = async (github, artifacts) => {
const versionFile = await readVersionFile(github, "release")
const versionFile = await readVersionFile(github, config.rcMergesTo)
await release(
github,
versionFile.content,
config.packageName,
artifacts,
config,
).catch((error) => console.log(error))
)
const createdPr = await github.rest.pulls.create({
owner: config.owner,
repo: config.repo,
title: "[Auto] Sync Release",
head: config.rcMergesTo,
base: config.rcBranchesFrom,
body: "Syncing changes from release",
})
await enablePrAutoMerge(createdPr.data.node_id)
}
const isWorkingBranchAhead = async (github) => {
@ -77,7 +89,11 @@ const startRelease = async (github) => {
body: "todo",
})
github.graphql(
await enablePrAutoMerge(createdPr.data.node_id)
}
const enablePrAutoMerge = async (prNodeId) => {
await github.graphql(
`
mutation ($pullRequestId: ID!, $mergeMethod: PullRequestMergeMethod!) {
enablePullRequestAutoMerge(input: {
@ -96,7 +112,7 @@ const startRelease = async (github) => {
}
`,
{
pullRequestId: createdPr.data.node_id,
pullRequestId: prNodeId,
mergeMethod: "MERGE"
}
)

File diff suppressed because it is too large Load Diff

View File

@ -6,6 +6,8 @@
"type": "module",
"private": true,
"dependencies": {
"@googleapis/androidpublisher": "^3.0.0"
"@googleapis/androidpublisher": "^3.0.0",
"matrix-js-sdk": "^19.4.0",
"request": "^2.88.2"
}
}

View File

@ -1,8 +1,13 @@
import * as google from '@googleapis/androidpublisher';
import * as fs from "fs";
import * as http from 'https';
import * as url from 'url';
import * as google from '@googleapis/androidpublisher'
import * as fs from "fs"
import * as http from 'https'
import matrixcs, * as matrix from 'matrix-js-sdk'
import request from 'request'
import * as url from 'url'
matrixcs.request(request)
const matrixAuth = JSON.parse(fs.readFileSync('.secrets/matrix.json'))
const client = matrix.createClient(matrixAuth)
const __dirname = url.fileURLToPath(new URL('.', import.meta.url));
const auth = new google.auth.GoogleAuth({
@ -63,6 +68,14 @@ export const release = async (github, version, applicationId, artifacts, config)
console.log("Promoting beta draft release to live...")
await promoteDraftToLive(applicationId)
const content = {
"body": `New release`,
"format": "org.matrix.custom.html",
"formatted_body": `New release rolling out <a href="${releaseResult.data.url}">${releaseResult.data.tag_name}</a>`,
"msgtype": "m.text"
}
await client.sendEvent(config.matrixRoomId, "m.room.message", content, "")
}
const startPlayRelease = async (applicationId) => {
@ -133,12 +146,6 @@ const dowloadSignedUniversalApk = async (version, applicationId, authToken, outp
})
const apks = apkRes.data.generatedApks
console.log(`found ${apks.length} apks`)
apks.forEach((apk) => {
console.log(apk)
})
const id = apks[0].generatedUniversalApk.downloadId
console.log(`downloading: ${id}`)
@ -198,4 +205,3 @@ const promoteDraftToLive = async (applicationId) => {
packageName: applicationId,
}).catch((error) => Promise.reject(error.response.data))
}