Skip to content

Commit 525ff5a

Browse files
authored
[Test PR] Extract "Upgrade Git for Windows" to a composite action (#68)
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.
1 parent 19c8a7b commit 525ff5a

File tree

2 files changed

+63
-33
lines changed

2 files changed

+63
-33
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: 14 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -255,40 +255,21 @@ 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.
262-
# The Windows 11 ARM runner still ships Git 2.48.*, so it remains affected by #1849.
258+
- name: Upgrade Git for Windows
259+
# TODO(ci): Don't run this step once `windows-11-arm` ships a new enough Git.
260+
# The Windows 11 ARM runner still ships Git 2.48.*, so it remains affected by #1849. So we
261+
# upgrade to the latest stable Git for Windows. We do this before `actions/checkout` for
262+
# two reasons: so `actions/checkout` will itself use the new Git, verifying that it works,
263+
# and so no dangling subprocess from the old Git will prevent the Inno Setup installer from
264+
# replacing its files. We can't run our `upgrade-git-for-windows` composite action with a
265+
# `./` path, because it has not been checked out. But we also want to use any changes that
266+
# have just been made to it, so we specify the current repo and commit. But the `github`
267+
# context is unavailable in `uses`, so we do this indirectly via the `dynamic-uses` action.
263268
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
269+
uses: jenseng/dynamic-uses@v1
270+
with:
271+
uses: ${{ github.repository }}/.github/actions/upgrade-git-for-windows@${{ github.sha }}
272+
with: '{ "arch": "arm64" }'
292273
- uses: actions/checkout@v4
293274
- name: Install rustup # FIXME: Remove this comment, it is just for testing a non-ff merge.
294275
if: matrix.os == 'windows-11-arm'

0 commit comments

Comments
 (0)