Skip to content

Commit

Permalink
snapshot uploading: do upload the regular Git for Windows versions
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
dscho committed Feb 13, 2025
1 parent 739b2e4 commit c2b466e
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
17 changes: 16 additions & 1 deletion GitForWindowsHelper/finalize-g4w-release.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,5 +58,20 @@ module.exports = async (context, req) => {
force: false // require fast-forward
})

return `Took care of pushing the \`main\` branch to close PR ${prNumber}`
// trigger "upload artifacts" workflow
const { handlePush } = require('./cascading-runs')
const uploadSnapshotAnswer = await handlePush(context, {
body: {
repository: {
owner: {
login: owner,
},
name: repo,
},
ref: 'refs/heads/main',
after: sha,
}
})

return `Took care of pushing the \`main\` branch to close PR ${prNumber}\n${uploadSnapshotAnswer}`
}
7 changes: 5 additions & 2 deletions __tests__/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -943,11 +943,14 @@ test('a completed `release-git` run updates the `main` branch in git-for-windows
try {
expect(await index(context, context.req)).toBeUndefined()
expect(context.res).toEqual({
body: `Took care of pushing the \`main\` branch to close PR 765`,
body: [
'Took care of pushing the `main` branch to close PR 765',
`The 'tag-git' workflow run was started at dispatched-workflow-tag-git.yml`,
].join('\n'),
headers: undefined,
status: undefined
})
expect(mockGitHubApiRequest).toHaveBeenCalledTimes(4)
expect(mockGitHubApiRequest).toHaveBeenCalledTimes(7)
expect(mockGitHubApiRequest.mock.calls[3].slice(1)).toEqual([
'installation-access-token',
'PATCH',
Expand Down

0 comments on commit c2b466e

Please sign in to comment.