26
26
bundle_artifacts_workflow_run_id :
27
27
description : ' Workflow run ID from bundle-artifacts pipeline'
28
28
required : false
29
+ existing_git_tag :
30
+ description : ' Existing tag to build from. Requires bundle_artifacts_workflow_run_id to be empty'
31
+ required : false
32
+ build_extra_rev_for_existing_git_tag :
33
+ description : ' build-extra revision to use if building from an existing Git tag. Required if existing_git_tag is non-empty'
34
+ required : false
29
35
30
36
env :
31
37
GPG_OPTIONS : " --batch --yes --no-tty --list-options no-show-photos --verify-options no-show-photos --pinentry-mode loopback"
36
42
REF : " ${{github.event.inputs.ref}}"
37
43
ARCHITECTURE : " ${{github.event.inputs.architecture}}"
38
44
BUNDLE_ARTIFACTS_WORKFLOW_RUN_ID : " ${{github.event.inputs.bundle_artifacts_workflow_run_id}}"
45
+ EXISTING_GIT_TAG : " ${{github.event.inputs.existing_git_tag}}"
46
+ BUILD_EXTRA_REV_FOR_EXISTING_GIT_TAG : " ${{github.event.inputs.build_extra_rev_for_existing_git_tag}}"
39
47
40
48
defaults :
41
49
run :
@@ -107,16 +115,43 @@ jobs:
107
115
core.info('Preparing artifact build matrix...')
108
116
const createArtifactsMatrix = require('./git-for-windows-automation/create-artifacts-matrix')
109
117
createArtifactsMatrix(core, process.env.ARTIFACTS_TO_BUILD, process.env.ARCHITECTURE)
118
+ - name : Construct bundle-artifacts from existing tag
119
+ if : env.EXISTING_GIT_TAG != ''
120
+ run : |
121
+ die () {
122
+ echo "$*" >&2
123
+ exit 1
124
+ }
125
+
126
+ test -z "$BUNDLE_ARTIFACTS_WORKFLOW_RUN_ID" ||
127
+ die 'existing_git_tag cannot be used with bundle_artifacts_workflow_run_id!'
128
+
129
+ test -n "$BUILD_EXTRA_REV_FOR_EXISTING_GIT_TAG" ||
130
+ die 'existing_git_tag needs build_extra_rev_for_existing_git_tag!'
131
+
132
+ set -o pipefail &&
133
+
134
+ mkdir -p bundle-artifacts &&
135
+ echo "$EXISTING_GIT_TAG" >bundle-artifacts/next_version &&
136
+ echo "$EXISTING_GIT_TAG" |
137
+ sed -n '/^v[0-9]\+\.[0-9]\+\.[0-9]\+\.windows\.[0-9]\+$/{s/^v//;s/\.windows\.1//;s/\.windows\.\(.*\)/(\1)/;p}' \
138
+ >bundle-artifacts/display_version &&
139
+ sed 's/(\(.*\))$/.\1/' <bundle-artifacts/display_version >bundle-artifacts/ver
110
140
- uses : actions/github-script@v6
141
+ if : env.BUNDLE_ARTIFACTS_WORKFLOW_RUN_ID != ''
111
142
id : get-bundle-artifacts-url
112
143
name : Get bundle-artifacts download URL
113
144
with :
114
145
script : |
146
+ if (process.env.EXISTING_GIT_TAG || process.env.BUILD_EXTRA_REV_FOR_EXISTING_GIT_TAG) {
147
+ throw new Error('bundle_artifacts_workflow_run_id cannot be used with existing_git_tag or build_extra_rev_for_existing_git_tag!')
148
+ }
115
149
const getArtifact = require('./git-for-windows-automation/get-bundle-artifacts-artifact')
116
150
const workflowId = process.env.BUNDLE_ARTIFACTS_WORKFLOW_RUN_ID
117
151
core.info('Getting download URL for bundle-artifacts...')
118
152
await getArtifact(github, context, core, workflowId)
119
153
- name : Download bundle-artifacts zip
154
+ if : env.BUNDLE_ARTIFACTS_WORKFLOW_RUN_ID != ''
120
155
run : |
121
156
mkdir bundle-artifacts
122
157
curl -o bundle-artifacts.zip "${{steps.get-bundle-artifacts-url.outputs.downloadUrl}}"
@@ -137,13 +172,24 @@ jobs:
137
172
git -C $d fetch https://github.com/git-for-windows/build-extra main &&
138
173
git -C $d switch -C main FETCH_HEAD
139
174
fi &&
140
- git -C $d pull "$PWD"/bundle-artifacts/build-extra.bundle main
175
+ if test -z "$BUILD_EXTRA_REV_FOR_EXISTING_GIT_TAG"
176
+ then
177
+ git -C $d pull "$PWD"/bundle-artifacts/build-extra.bundle main
178
+ else
179
+ git -C $d fetch origin "$BUILD_EXTRA_REV_FOR_EXISTING_GIT_TAG" &&
180
+ git reset --hard "$BUILD_EXTRA_REV_FOR_EXISTING_GIT_TAG"
181
+ fi
141
182
- name : Check out git/git
142
183
shell : bash
143
184
run : |
144
185
git -c init.defaultBranch=main init &&
145
186
git remote add -f origin https://github.com/git-for-windows/git &&
146
- git fetch --tags bundle-artifacts/git.bundle $(cat bundle-artifacts/next_version) &&
187
+ if test -n "$EXISTING_GIT_TAG"
188
+ then
189
+ git fetch origin "refs/tags/$EXISTING_GIT_TAG:refs/tags/$EXISTING_GIT_TAG"
190
+ else
191
+ git fetch --tags bundle-artifacts/git.bundle $(cat bundle-artifacts/next_version)
192
+ fi &&
147
193
git reset --hard $(cat bundle-artifacts/next_version)
148
194
- name : Prepare home directory for code-signing
149
195
env :
@@ -193,7 +239,16 @@ jobs:
193
239
version=$(cat bundle-artifacts/next_version) &&
194
240
(cd /usr/src/MINGW-packages/mingw-w64-git &&
195
241
cp PKGBUILD.$version PKGBUILD &&
196
- git commit -s -m "mingw-w64-git: new version ($version)" PKGBUILD &&
242
+ if test -z "$EXISTING_GIT_TAG"
243
+ then
244
+ git commit -s -m "mingw-w64-git: new version ($version)" PKGBUILD
245
+ elif ! git update-index --ignore-submodules --refresh ||
246
+ ! git diff-files --ignore-submodules ||
247
+ ! git diff-index --cached --ignore-submodules HEAD
248
+ then
249
+ echo "::warning::Uncommitted changes after build!" >&2
250
+ git diff >&2
251
+ fi &&
197
252
git bundle create "$b"/MINGW-packages.bundle origin/main..main)
198
253
- name : Publish ${{env.MINGW_PACKAGE_PREFIX}}-git
199
254
uses : actions/upload-artifact@v3
@@ -235,7 +290,13 @@ jobs:
235
290
git -C $d fetch https://github.com/git-for-windows/build-extra main &&
236
291
git -C $d switch -C main FETCH_HEAD
237
292
fi &&
238
- git -C $d pull "$PWD"/bundle-artifacts/build-extra.bundle main
293
+ if test -z "$BUILD_EXTRA_REV_FOR_EXISTING_GIT_TAG"
294
+ then
295
+ git -C $d pull "$PWD"/bundle-artifacts/build-extra.bundle main
296
+ else
297
+ git -C $d fetch origin "$BUILD_EXTRA_REV_FOR_EXISTING_GIT_TAG" &&
298
+ git reset --hard "$BUILD_EXTRA_REV_FOR_EXISTING_GIT_TAG"
299
+ fi
239
300
- name : Prepare home directory for code-signing
240
301
env :
241
302
CODESIGN_P12 : ${{secrets.CODESIGN_P12}}
0 commit comments