Skip to content

Commit c2b466e

Browse files
committed
snapshot uploading: do upload the regular Git for Windows versions
A regular Git for Windows version is branch-deployed in a Pull Request: It is built via the `/git-artifacts` slash command and then published via the `/release` slash command. Crucially, this build needs to be validated manually between the time when the `git-artifacts` workflows are done and the time when they are uploaded, and during that time window, the artifacts should _not_ be published as snapshots because if validation fails, they need to be rebuilt. The preceding two commits fixed the bug where the `upload-snapshot` workflow was run in that time window by mistake. However, when _do_ we want to upload the freshly-built official version as a new snapshot? Why, of course when the `main` branch is pushed. Except that we do not push at all, the `/release` slash command just updates the `main` ref, knowing fully well that no objects need to be pushed because `main` must fast-forward to the the PR branch when releasing a new Git for Windows version; This is enforced. And updating the ref via the REST API does not trigger the `push` event at all. Therefore we need to manually pretend that a `push` happened, and then all will be good again. Signed-off-by: Johannes Schindelin <[email protected]>
1 parent 739b2e4 commit c2b466e

File tree

2 files changed

+21
-3
lines changed

2 files changed

+21
-3
lines changed

GitForWindowsHelper/finalize-g4w-release.js

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,5 +58,20 @@ module.exports = async (context, req) => {
5858
force: false // require fast-forward
5959
})
6060

61-
return `Took care of pushing the \`main\` branch to close PR ${prNumber}`
61+
// trigger "upload artifacts" workflow
62+
const { handlePush } = require('./cascading-runs')
63+
const uploadSnapshotAnswer = await handlePush(context, {
64+
body: {
65+
repository: {
66+
owner: {
67+
login: owner,
68+
},
69+
name: repo,
70+
},
71+
ref: 'refs/heads/main',
72+
after: sha,
73+
}
74+
})
75+
76+
return `Took care of pushing the \`main\` branch to close PR ${prNumber}\n${uploadSnapshotAnswer}`
6277
}

__tests__/index.test.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -943,11 +943,14 @@ test('a completed `release-git` run updates the `main` branch in git-for-windows
943943
try {
944944
expect(await index(context, context.req)).toBeUndefined()
945945
expect(context.res).toEqual({
946-
body: `Took care of pushing the \`main\` branch to close PR 765`,
946+
body: [
947+
'Took care of pushing the `main` branch to close PR 765',
948+
`The 'tag-git' workflow run was started at dispatched-workflow-tag-git.yml`,
949+
].join('\n'),
947950
headers: undefined,
948951
status: undefined
949952
})
950-
expect(mockGitHubApiRequest).toHaveBeenCalledTimes(4)
953+
expect(mockGitHubApiRequest).toHaveBeenCalledTimes(7)
951954
expect(mockGitHubApiRequest.mock.calls[3].slice(1)).toEqual([
952955
'installation-access-token',
953956
'PATCH',

0 commit comments

Comments
 (0)