Skip to content

Commit 4934aca

Browse files
committed
git-artifacts: optionally use release branches
For embargoed Git for Windows versions, we already have a well-established paradigm where the `git-sdk-32`, `git-sdk-64`, `build-extra` and `MINGW-packages` worktrees are not initialized with the current state of the `main` branch, but with the current state of the `git-<version>` branches, the "release branches". Let's teach the `git-artifacts` workflow to optionally use the same paradigm. This supersedes the strategy we established earlier when building from a tag, where the `build-extra` revision to use could be specified; This strategy was incomplete, as it left out e.g. `MINGW-packages` which most likely _also_ wanted to be at a specific revision rather than blindly using the tip commit of the `main` branch. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
1 parent 3388926 commit 4934aca

File tree

3 files changed

+88
-34
lines changed

3 files changed

+88
-34
lines changed

.github/workflows/git-artifacts.yml

Lines changed: 69 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,10 @@ on:
2121
existing_git_tag:
2222
description: 'Existing tag to build from. Requires tag_git_workflow_run_id to be empty'
2323
required: false
24-
build_extra_rev_for_existing_git_tag:
25-
description: 'build-extra revision to use if building from an existing Git tag. Required if existing_git_tag is non-empty'
24+
release_branch:
25+
description: 'The branch name to use for this release (e.g. `git-2.44.x-releases`)'
2626
required: false
27+
type: string
2728

2829
env:
2930
GPG_OPTIONS: "--batch --yes --no-tty --list-options no-show-photos --verify-options no-show-photos --pinentry-mode loopback"
@@ -35,7 +36,7 @@ env:
3536
REPO: git
3637
TAG_GIT_WORKFLOW_RUN_ID: "${{github.event.inputs.tag_git_workflow_run_id}}"
3738
EXISTING_GIT_TAG: "${{github.event.inputs.existing_git_tag}}"
38-
BUILD_EXTRA_REV_FOR_EXISTING_GIT_TAG: "${{github.event.inputs.build_extra_rev_for_existing_git_tag}}"
39+
RELEASE_BRANCH: "${{github.event.inputs.release_branch}}"
3940

4041
defaults:
4142
run:
@@ -51,10 +52,12 @@ jobs:
5152
mingw_package_prefix: ${{steps.configure-environment.outputs.MINGW_PACKAGE_PREFIX}}
5253
sdk_repo_arch: ${{steps.configure-environment.outputs.SDK_REPO_ARCH}}
5354
check-run-state: ${{steps.check-run-state.outputs.check-run-state}}
55+
release-branch: ${{steps.configure-environment.outputs.release-branch}}
5456
steps:
5557
- name: clone git-for-windows-automation
5658
uses: actions/checkout@v5
5759
- name: Construct bundle-artifacts from existing tag
60+
id: handle-existing-git-tag
5861
if: env.EXISTING_GIT_TAG != ''
5962
run: |
6063
die () {
@@ -65,8 +68,14 @@ jobs:
6568
test -z "$TAG_GIT_WORKFLOW_RUN_ID" ||
6669
die 'existing_git_tag cannot be used with tag_git_workflow_run_id!'
6770
68-
test -n "$BUILD_EXTRA_REV_FOR_EXISTING_GIT_TAG" ||
69-
die 'existing_git_tag needs build_extra_rev_for_existing_git_tag!'
71+
if test -n "$RELEASE_BRANCH"
72+
then
73+
RELEASE_BRANCH="${EXISTING_GIT_TAG%%.windows.*}" &&
74+
RELEASE_BRANCH=git-"${RELEASE_BRANCH#v}" &&
75+
test git- != "$RELEASE_BRANCH" ||
76+
die "Could not determine release branch from '$EXISTING_GIT_TAG'"
77+
echo "RELEASE_BRANCH=$RELEASE_BRANCH" >>$GITHUB_ENV
78+
fi
7079
7180
set -o pipefail &&
7281
@@ -98,8 +107,8 @@ jobs:
98107
id: get-bundle-artifacts-url
99108
with:
100109
script: |
101-
if (process.env.EXISTING_GIT_TAG || process.env.BUILD_EXTRA_REV_FOR_EXISTING_GIT_TAG) {
102-
throw new Error('tag_git_workflow_run_id cannot be used with existing_git_tag or build_extra_rev_for_existing_git_tag!')
110+
if (process.env.EXISTING_GIT_TAG) {
111+
throw new Error('tag_git_workflow_run_id cannot be used with existing_git_tag!')
103112
}
104113
const getDownloadURL = require('./get-workflow-run-artifact')
105114
const workflowRunId = process.env.TAG_GIT_WORKFLOW_RUN_ID
@@ -167,6 +176,7 @@ jobs:
167176
echo "MINGW_PREFIX=$MINGW_PREFIX" >> $GITHUB_OUTPUT
168177
echo "MINGW_PACKAGE_PREFIX=$MINGW_PACKAGE_PREFIX" >> $GITHUB_ENV
169178
echo "MINGW_PACKAGE_PREFIX=$MINGW_PACKAGE_PREFIX" >> $GITHUB_OUTPUT
179+
echo "SDK_REPO_ARCH=$SDK_REPO_ARCH" >> $GITHUB_ENV
170180
echo "SDK_REPO_ARCH=$SDK_REPO_ARCH" >> $GITHUB_OUTPUT
171181
test -n "$ARTIFACTS_TO_BUILD" || {
172182
ARTIFACTS_TO_BUILD="mingit"
@@ -176,6 +186,18 @@ jobs:
176186
}
177187
echo "ARTIFACTS_TO_BUILD=$ARTIFACTS_TO_BUILD" >> $GITHUB_ENV
178188
echo "PKG_CACHE_KEY=pkg-$GIT_VERSION-$ARCHITECTURE-$TAG_GIT_WORKFLOW_RUN_ID" >> $GITHUB_ENV
189+
190+
if test -z "$RELEASE_BRANCH"
191+
then
192+
RELEASE_BRANCH="$(cat bundle-artifacts/release-branch)"
193+
if test -z "$RELEASE_BRANCH"
194+
then
195+
echo "No release branch found in bundle-artifacts/release-branch"
196+
exit 1
197+
fi
198+
echo "RELEASE_BRANCH=$RELEASE_BRANCH" >> $GITHUB_ENV
199+
fi
200+
echo "release-branch=$RELEASE_BRANCH" >> $GITHUB_OUTPUT
179201
- name: Configure user
180202
run:
181203
USER_NAME="${{github.actor}}" &&
@@ -185,9 +207,21 @@ jobs:
185207
git config --global user.email "$USER_EMAIL" &&
186208
echo "PACKAGER=$USER_NAME <$USER_EMAIL>" >> $GITHUB_ENV
187209
- uses: git-for-windows/setup-git-for-windows-sdk@v1
210+
if: env.OWNER == 'git-for-windows' && env.RELEASE_BRANCH == 'main'
188211
with:
189212
flavor: build-installers
190213
architecture: ${{env.architecture}}
214+
- name: Set up Git for Windows SDK ${{ env.architecture }} (${{ env.RELEASE_BRANCH }})
215+
if: env.OWNER != 'git-for-windows' || env.RELEASE_BRANCH != 'main'
216+
shell: bash
217+
run: |
218+
git -c checkout.workers=56 \
219+
clone --single-branch -b "$RELEASE_BRANCH" --depth 1 \
220+
https://github.com/git-for-windows/git-sdk-$SDK_REPO_ARCH D:/git-sdk-$SDK_REPO_ARCH &&
221+
222+
cygpath -aw D:/git-sdk-$SDK_REPO_ARCH/usr/bin/core_perl >>$GITHUB_PATH &&
223+
cygpath -aw D:/git-sdk-$SDK_REPO_ARCH/usr/bin >>$GITHUB_PATH &&
224+
cygpath -aw D:/git-sdk-$SDK_REPO_ARCH/${MSYSTEM,,?}/bin >>$GITHUB_PATH
191225
- name: Create artifact build matrix
192226
uses: actions/github-script@v8
193227
id: artifact-build-matrix
@@ -214,25 +248,22 @@ jobs:
214248
d=/usr/src/build-extra &&
215249
if test ! -d $d/.git
216250
then
217-
git clone --single-branch -b main https://github.com/git-for-windows/build-extra $d
251+
git clone --single-branch -b "$RELEASE_BRANCH" https://github.com/git-for-windows/build-extra $d
218252
else
219-
git -C $d fetch https://github.com/git-for-windows/build-extra main &&
220-
git -C $d switch -C main FETCH_HEAD
253+
git -C $d fetch https://github.com/git-for-windows/build-extra "$RELEASE_BRANCH" &&
254+
git -C $d switch -C "$RELEASE_BRANCH" FETCH_HEAD
221255
fi &&
222-
if test -z "$BUILD_EXTRA_REV_FOR_EXISTING_GIT_TAG"
256+
if test -z "$EXISTING_GIT_TAG"
223257
then
224-
git -C $d -c pull.rebase=false pull "$PWD"/bundle-artifacts/build-extra.bundle main
225-
else
226-
git -C $d fetch origin "$BUILD_EXTRA_REV_FOR_EXISTING_GIT_TAG" &&
227-
git -C $d reset --hard "$BUILD_EXTRA_REV_FOR_EXISTING_GIT_TAG"
258+
git -C $d -c pull.rebase=false pull "$PWD"/bundle-artifacts/build-extra.bundle "$RELEASE_BRANCH"
228259
fi
229260
- name: Prepare git-for-windows/git clone with the tag
230261
if: steps.restore-cached-git-pkg.outputs.cache-hit != 'true'
231262
run: |
232263
set -x
233264
if test ! -d /usr/src/MINGW-packages
234265
then
235-
git clone --depth 1 --single-branch -b main \
266+
git clone --depth 1 --single-branch -b "$RELEASE_BRANCH" \
236267
https://github.com/git-for-windows/MINGW-packages /usr/src/MINGW-packages
237268
fi &&
238269
cd /usr/src/MINGW-packages/mingw-w64-git &&
@@ -317,15 +348,17 @@ jobs:
317348
if test -z "$EXISTING_GIT_TAG"
318349
then
319350
git commit -s -m "mingw-w64-git: new version ($version)" PKGBUILD &&
320-
git bundle create "$b"/MINGW-packages.bundle origin/main..main
351+
git bundle create "$b"/MINGW-packages.bundle \
352+
"origin/$RELEASE_BRANCH..$RELEASE_BRANCH"
321353
elif ! git update-index --ignore-submodules --refresh ||
322354
! git diff-files --ignore-submodules ||
323355
! git diff-index --cached --ignore-submodules HEAD
324356
then
325357
echo "::warning::Uncommitted changes after build!" >&2 &&
326358
git diff >&2 &&
327359
git commit -s -m "mingw-w64-git: new version ($version)" PKGBUILD &&
328-
git bundle create "$b"/MINGW-packages.bundle main^..main
360+
git bundle create "$b"/MINGW-packages.bundle \
361+
"$RELEASE_BRANCH^..$RELEASE_BRANCH"
329362
fi)
330363
- name: Cache ${{env.MINGW_PACKAGE_PREFIX}}-git
331364
if: steps.restore-cached-git-pkg.outputs.cache-hit != 'true'
@@ -364,6 +397,7 @@ jobs:
364397
MINGW_PREFIX: ${{ needs.pkg.outputs.mingw-prefix }}
365398
MINGW_PACKAGE_PREFIX: ${{ needs.pkg.outputs.mingw_package_prefix }}
366399
SDK_REPO_ARCH: ${{ needs.pkg.outputs.sdk_repo_arch }}
400+
RELEASE_BRANCH: ${{ needs.pkg.outputs.release-branch }}
367401
strategy:
368402
fail-fast: false
369403
matrix: ${{ fromJSON(needs.pkg.outputs.artifact_matrix) }}
@@ -389,9 +423,21 @@ jobs:
389423
name: bundle-artifacts
390424
path: bundle-artifacts
391425
- uses: git-for-windows/setup-git-for-windows-sdk@v1
426+
if: env.OWNER == 'git-for-windows' && env.RELEASE_BRANCH == 'main'
392427
with:
393428
flavor: build-installers
394429
architecture: ${{env.ARCHITECTURE}}
430+
- name: Set up Git for Windows SDK ${{ env.architecture }} (${{ env.RELEASE_BRANCH }})
431+
if: env.OWNER != 'git-for-windows' || env.RELEASE_BRANCH != 'main'
432+
shell: bash
433+
run: |
434+
git -c checkout.workers=56 \
435+
clone --single-branch -b "$RELEASE_BRANCH" --depth 1 \
436+
https://github.com/git-for-windows/git-sdk-$SDK_REPO_ARCH D:/git-sdk-$SDK_REPO_ARCH &&
437+
438+
cygpath -aw D:/git-sdk-$SDK_REPO_ARCH/usr/bin/core_perl >>$GITHUB_PATH &&
439+
cygpath -aw D:/git-sdk-$SDK_REPO_ARCH/usr/bin >>$GITHUB_PATH &&
440+
cygpath -aw D:/git-sdk-$SDK_REPO_ARCH/${MSYSTEM,,?}/bin >>$GITHUB_PATH
395441
- name: Configure user
396442
run:
397443
USER_NAME="${{github.actor}}" &&
@@ -405,18 +451,15 @@ jobs:
405451
d=/usr/src/build-extra &&
406452
if test ! -d $d/.git
407453
then
408-
git clone --single-branch -b main https://github.com/git-for-windows/build-extra $d
454+
git clone --single-branch -b "$RELEASE_BRANCH" https://github.com/git-for-windows/build-extra $d
409455
else
410-
git -C $d fetch https://github.com/git-for-windows/build-extra main &&
411-
git -C $d switch -C main FETCH_HEAD
456+
git -C $d fetch https://github.com/git-for-windows/build-extra "$RELEASE_BRANCH" &&
457+
git -C $d switch -C "$RELEASE_BRANCH" FETCH_HEAD
412458
fi &&
413459
echo "result=$(cygpath -am "$d")" >> $GITHUB_OUTPUT &&
414-
if test -z "$BUILD_EXTRA_REV_FOR_EXISTING_GIT_TAG"
460+
if test -z "$EXISTING_GIT_TAG"
415461
then
416-
git -C $d -c pull.rebase=false pull "$PWD"/bundle-artifacts/build-extra.bundle main
417-
else
418-
git -C $d fetch origin "$BUILD_EXTRA_REV_FOR_EXISTING_GIT_TAG" &&
419-
git -C $d reset --hard "$BUILD_EXTRA_REV_FOR_EXISTING_GIT_TAG"
462+
git -C $d -c pull.rebase=false pull "$PWD"/bundle-artifacts/build-extra.bundle "$RELEASE_BRANCH"
420463
fi
421464
- name: Prepare home directory for code-signing
422465
env:

.github/workflows/tag-git.yml

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@ on:
1616
description: 'Optionally override from where to fetch the specified rev'
1717
required: true
1818
default: git
19+
release-branch:
20+
description: 'The branch name to use for this release'
21+
required: false
22+
default: main
1923
snapshot:
2024
description: 'A flag indicating whether this is a snapshot or a full Git for Windows release'
2125
required: true
@@ -26,6 +30,7 @@ env:
2630
OWNER: "${{github.event.inputs.owner}}"
2731
REPO: "${{github.event.inputs.repo}}"
2832
REV: "${{github.event.inputs.rev}}"
33+
RELEASE_BRANCH: "${{github.event.inputs.release-branch}}"
2934
SNAPSHOT: "${{github.event.inputs.snapshot}}"
3035
CREATE_CHECK_RUN: "true"
3136
NODEJS_VERSION: 16
@@ -64,14 +69,14 @@ jobs:
6469
text: "For details, see [this run](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id}})."
6570
details-url: "https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id}}"
6671
- name: Configure user
67-
run:
72+
run: |
6873
USER_NAME="${{github.actor}}" &&
6974
USER_EMAIL="${{github.actor}}@users.noreply.github.com" &&
7075
git config --global user.name "$USER_NAME" &&
7176
git config --global user.email "$USER_EMAIL" &&
7277
echo "PACKAGER=$USER_NAME <$USER_EMAIL>" >> $GITHUB_ENV
7378
- name: Clone build-extra
74-
run: git clone --single-branch -b main https://github.com/git-for-windows/build-extra $RUNNER_TEMP/build-extra
79+
run: git clone --single-branch -b "$RELEASE_BRANCH" https://github.com/git-for-windows/build-extra $RUNNER_TEMP/build-extra
7580
- name: Prepare home directory for GPG signing
7681
if: env.GPGKEY != ''
7782
run: |
@@ -93,15 +98,18 @@ jobs:
9398
GPGKEY: ${{secrets.GPGKEY}}
9499
run: |
95100
git clone --bare --filter=blob:none https://github.com/git/git &&
96-
git -C git.git fetch --tags --filter=blob:none "https://github.com/$OWNER/$REPO" main:refs/remotes/origin/main "$REV" &&
101+
git -C git.git fetch --tags --filter=blob:none "https://github.com/$OWNER/$REPO" "$RELEASE_BRANCH:refs/remotes/origin/$RELEASE_BRANCH" "$REV" &&
97102
98103
sh -x "$GITHUB_WORKSPACE/update-scripts/tag-git.sh" \
99104
${{ env.SNAPSHOT != 'true' && '--no-snapshot-version' || ''}} \
100105
--git-dir="git.git" \
101106
--build-extra-dir="$RUNNER_TEMP/build-extra" \
102107
--artifacts-dir="$GITHUB_WORKSPACE/bundle-artifacts" \
108+
--release-branch="$RELEASE_BRANCH" \
103109
"$REV" &&
104110
111+
echo "$RELEASE_BRANCH" >bundle-artifacts/release-branch &&
112+
105113
echo "tag-name=$(cat bundle-artifacts/next_version)" >>$GITHUB_OUTPUT &&
106114
echo "Tag name: \`$(cat bundle-artifacts/next_version)\`" >>$GITHUB_STEP_SUMMARY
107115
- name: update check-run

update-scripts/tag-git.sh

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,22 +8,25 @@ die () {
88
git_git_dir=/usr/src/git/.git &&
99
build_extra_dir=/usr/src/build-extra &&
1010
artifacts_dir= &&
11+
release_branch=main &&
1112
snapshot_version=t &&
1213
while case "$1" in
1314
--git-dir=*) git_git_dir="${1#*=}";;
1415
--build-extra-dir=*) build_extra_dir="${1#*=}";;
1516
--artifacts-dir=*) artifacts_dir="${1#*=}";;
17+
--release-branch=*) release_branch="${1#*=}";;
1618
--full|--full-version|--no-snapshot|--no-snapshot-version) snapshot_version=;;
1719
*) break;;
18-
esac; do shift; done
20+
esac; do shift; done ||
21+
die "Could not parse command-line options: $*"
1922

2023
test $# = 1 ||
2124
die "Usage: $0 [--no-snapshot-version] [--git-dir=<dir>] [--build-extra-dir=<dir>] [--artifacts-dir=<dir>] <git-rev>"
2225

2326
git_rev="$1"
2427

25-
test "refs/heads/main" = "$(git -C "$build_extra_dir" symbolic-ref HEAD)" ||
26-
die "Need the current branch in '$build_extra_dir' to be 'main'"
28+
test "refs/heads/$release_branch" = "$(git -C "$build_extra_dir" symbolic-ref HEAD)" ||
29+
die "Need the current branch in '$build_extra_dir' to be '$release_branch'"
2730

2831
mkdir -p "$artifacts_dir" &&
2932
if test -n "$snapshot_version"
@@ -136,6 +139,6 @@ echo "$tag_message" >"$artifacts_dir"/tag-message &&
136139
git -C "$git_git_dir" rev-parse --verify "$git_rev"^0 >"$artifacts_dir"/git-commit-oid &&
137140

138141
git -C "$git_git_dir" tag $(test -z "$GPGKEY" || echo " -s") -m "$tag_message" "$tag_name" "$git_rev" &&
139-
git -C "$git_git_dir" bundle create "$artifacts_dir"/git.bundle origin/main.."$tag_name" &&
142+
git -C "$git_git_dir" bundle create "$artifacts_dir"/git.bundle origin/$release_branch.."$tag_name" &&
140143

141-
git -C "$build_extra_dir" bundle create "$artifacts_dir"/build-extra.bundle origin/main..main
144+
git -C "$build_extra_dir" bundle create "$artifacts_dir"/build-extra.bundle origin/$release_branch..$release_branch

0 commit comments

Comments
 (0)