Skip to content

Commit 3a61ae7

Browse files
committed
Extract "Upgrade Git for Windows" to a composite action
Although this is -- currently, and in the immediately foreseeable future -- only used in one place, it's cumbersome and also something that we've removed and reintroduced before. Making it a composite action may make it reasonable to keep it around for next time it is needed. It had previously been removed based on the idea that it wasn't clear what form it would need to be in if needed again. Now that it is needed again, the current form as well as the form that seems most likely for future needs is to install the latest stable release of Git for Windows -- rather than a release candidate, hard coded version, etc. Note that this should still not be used habitually, as the Git for Windows installation that ships preinstalled on a runner image should be preferred except when insufficient. See GitoxideLabs#1870, GitoxideLabs#1892, GitoxideLabs#1920, and the recent commit that reintroduced this logic, for background. This may be a bit complicated to get working, because we want to run the composite action before we have used `actions/checkout`. This is so `actions/checkout` can use and therefore verify that the new Git for Windows version works, and so we don't leave any dangling subprocesses or otherwise open files that would keep the new Git for Windows's Inno Setup installer from removing or replacing the old Git for Windows. But to run a composite action from a`./` path, one ordinarily needs to have checked out the repository already. A composite action can of course be run from a specified ref on a specified repository. But unless we're actually spinning it out to be a general reusable action that versions separately from workflows here such as `ci.yml`, we would always want to run the composite action as defined at the same commit we are at. (The effect of modifying it on a feature branch is othewise cumbersome and unintuitive.) This same commit is often pointed to by the same remote ref -- but not always, because the `pull_request` trigger runs workflows on a temporary merge commit.
1 parent d88ad03 commit 3a61ae7

File tree

2 files changed

+54
-32
lines changed

2 files changed

+54
-32
lines changed
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
name: upgrade-git-for-windows
2+
3+
description: Upgrade Git for Windows to the latest stable release
4+
5+
inputs:
6+
arch:
7+
description: >
8+
Target architecture fragment of Git for Windows installer filename
9+
(should be `32-bit`, `64-bit`, or `arm64`)
10+
required: true
11+
12+
runs:
13+
using: composite
14+
15+
steps:
16+
- name: Report version/build of Git in this runner image
17+
run: git version --build-options
18+
shell: pwsh
19+
- name: Download and install latest stable Git for Windows release
20+
env:
21+
ARCH: ${{ inputs.arch }}
22+
GH_TOKEN: ${{ github.token }}
23+
run: |
24+
$workingDir = '~/git-dl'
25+
$repo = 'git-for-windows/git'
26+
$pattern = "Git-*-${Env:ARCH}.exe"
27+
$log = 'setup-log.txt'
28+
# Inno Setup args reference: https://jrsoftware.org/ishelp/index.php?topic=setupcmdline
29+
$arguments = @(
30+
'/VERYSILENT',
31+
'/SUPPRESSMSGBOXES',
32+
'/ALLUSERS',
33+
"/LOG=$log",
34+
'/NORESTART',
35+
'/CLOSEAPPLICATIONS',
36+
'/FORCECLOSEAPPLICATIONS'
37+
)
38+
39+
mkdir $workingDir | Out-Null
40+
cd $workingDir
41+
gh release download --repo $repo --pattern $pattern
42+
$installer = Get-Item $pattern
43+
Start-Process -FilePath $installer -ArgumentList $arguments -NoNewWindow -Wait
44+
45+
Get-Content -Path $log -Tail 50
46+
shell: pwsh
47+
- name: Report version/build of Git after upgrade
48+
run: git version --build-options
49+
shell: pwsh

.github/workflows/ci.yml

Lines changed: 5 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -255,40 +255,13 @@ jobs:
255255
runs-on: ${{ matrix.os }}
256256

257257
steps:
258-
- name: Report version/build of Git in this runner image
259-
run: git version --build-options
260-
- name: Upgrade Git for Windows to latest stable release
261-
# TODO(ci): Remove this and related steps once `windows-11-arm` ships a new enough Git.
258+
- name: Upgrade Git for Windows
259+
# TODO(ci): Don't run this step once `windows-11-arm` ships a new enough Git.
262260
# The Windows 11 ARM runner still ships Git 2.48.*, so it remains affected by #1849.
263261
if: matrix.os == 'windows-11-arm'
264-
env:
265-
GH_TOKEN: ${{ github.token }}
266-
run: |
267-
$workingDir = '~/git-dl'
268-
$repo = 'git-for-windows/git'
269-
$pattern = 'Git-*-arm64.exe'
270-
$log = 'setup-log.txt'
271-
# Inno Setup args reference: https://jrsoftware.org/ishelp/index.php?topic=setupcmdline
272-
$arguments = @(
273-
'/VERYSILENT',
274-
'/SUPPRESSMSGBOXES',
275-
'/ALLUSERS',
276-
"/LOG=$log",
277-
'/NORESTART',
278-
'/CLOSEAPPLICATIONS',
279-
'/FORCECLOSEAPPLICATIONS'
280-
)
281-
282-
mkdir $workingDir | Out-Null
283-
cd $workingDir
284-
gh release download --repo $repo --pattern $pattern
285-
$installer = Get-Item $pattern
286-
Start-Process -FilePath $installer -ArgumentList $arguments -NoNewWindow -Wait
287-
288-
Get-Content -Path $log -Tail 50
289-
- name: Report version/build of Git after upgrade
290-
if: matrix.os == 'windows-11-arm'
291-
run: git version --build-options
262+
uses: ./.github/actions/upgrade-git-for-windows
263+
with:
264+
arch: arm64
292265
- uses: actions/checkout@v4
293266
- name: Install rustup
294267
if: matrix.os == 'windows-11-arm'

0 commit comments

Comments
 (0)