forked from git-for-windows/git-sdk-64
-
Notifications
You must be signed in to change notification settings - Fork 9
187 lines (175 loc) · 7.71 KB
/
ci-artifacts.yml
File metadata and controls
187 lines (175 loc) · 7.71 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
name: ci-artifacts
on:
push:
branches:
- main
pull_request:
# For the continuous `ci-artifacts` release
permissions:
contents: write
env:
LC_CTYPE: C.UTF-8
jobs:
minimal-sdk-artifact:
if: github.repository_owner == 'git-for-windows'
runs-on: windows-11-arm
outputs:
git-artifacts-extract-location: ${{ steps.git-artifacts-extract-location.outputs.result }}
steps:
- name: clone git-sdk-arm64
run: |
git init --bare git-sdk-arm64.git &&
git --git-dir=git-sdk-arm64.git remote add origin https://github.com/${{github.repository}} &&
git --git-dir=git-sdk-arm64.git config remote.origin.promisor true &&
git --git-dir=git-sdk-arm64.git config remote.origin.partialCloneFilter blob:none &&
git --git-dir=git-sdk-arm64.git fetch --depth=1 origin ${{github.sha}} &&
git --git-dir=git-sdk-arm64.git update-ref --no-deref HEAD ${{github.sha}}
- name: clone build-extra
run: git clone --depth=1 --single-branch -b main https://github.com/git-for-windows/build-extra
- name: build git-sdk-arm64-minimal-sdk
shell: bash
run: |
sh -x ./build-extra/please.sh create-sdk-artifact --sdk=git-sdk-arm64.git minimal-sdk &&
cygpath -aw minimal-sdk/usr/bin >>$GITHUB_PATH
- name: compress artifact
shell: bash
run: mkdir artifacts && (cd minimal-sdk && tar cvf - * .[0-9A-Za-z]*) | gzip -1 >artifacts/git-sdk-aarch64-minimal.tar.gz
- name: upload minimal-sdk artifact
uses: actions/upload-artifact@v6
with:
name: minimal-sdk
path: artifacts/git-sdk-aarch64-minimal.tar.gz
- name: clone git-for-windows/git's `main`
run: git clone --depth=1 --branch main https://github.com/git-for-windows/git ..\git
- name: build current `main` of git-for-windows/git
shell: bash
run: |
set -x
. /etc/profile
test "$(cygpath -aw /)" = "${{github.workspace}}\minimal-sdk" || exit 1
test "$(type -p gcc)" = "/clangarm64/bin/gcc" || exit 1
make -C ../git DEVELOPER=1 NO_PERL=1 SKIP_DASHED_BUILT_INS=YesPlease -j8 all strip
- name: show build-options
shell: bash
run: . /etc/profile && ../git/git version --build-options
- name: compress git artifacts
shell: bash
run: tar -C .. -czf git-artifacts.tar.gz --exclude '*.a' --exclude '*.o' --exclude .git --exclude .depend git
- name: upload git artifacts for testing
uses: actions/upload-artifact@v6
with:
name: git-artifacts
path: git-artifacts.tar.gz
- name: determine where `git-artifacts` want to be extracted
id: git-artifacts-extract-location
shell: bash
run: |
cd .. &&
echo "result=$(pwd)" >>$GITHUB_OUTPUT
- name: create zip and 7z SFX variants of the minimal SDK
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
shell: bash
run: |
for path in clangarm64/bin/7z.exe clangarm64/bin/7z.dll clangarm64/lib/7zip/7zCon.sfx clangarm64/bin/libc++.dll
do
git --git-dir=git-sdk-arm64.git show HEAD:$path >${path##*/}
done &&
mkdir minimal-sdk-extra &&
(cd minimal-sdk && ../7z.exe a -mmt=on -mx9 ../minimal-sdk-extra/git-sdk-aarch64-minimal.zip * .?*) &&
(cd minimal-sdk && ../7z.exe a -t7z -mmt=on -m0=lzma -mqs -mlc=8 -mx=9 -md=256M -mfb=273 -ms=256M -sfx../7zCon.sfx \
../minimal-sdk-extra/git-sdk-aarch64-minimal.7z.exe * .?*)
- name: upload minimal-sdk-extra artifacts
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
uses: actions/upload-artifact@v6
with:
name: minimal-sdk-extra
path: minimal-sdk-extra
test-minimal-sdk:
needs: minimal-sdk-artifact
uses: ./.github/workflows/test-ci-artifacts.yml
with:
git-artifacts-extract-location: ${{ needs.minimal-sdk-artifact.outputs.git-artifacts-extract-location }}
permissions:
contents: read
publish-release-assets:
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
needs: test-minimal-sdk
steps:
- name: download minimal-sdk artifact
uses: actions/download-artifact@v8
with:
name: minimal-sdk
path: ${{github.workspace}}
- name: download minimal-sdk artifact
uses: actions/download-artifact@v8
with:
name: minimal-sdk-extra
path: ${{github.workspace}}
- name: publish release assets
uses: actions/github-script@v8
with:
script: |
const req = { owner: context.repo.owner, repo: context.repo.repo }
// find or create the GitHub release named `ci-artifacts`
const release = await (async () => {
try {
return await github.rest.repos.getReleaseByTag({ ...req, tag: 'ci-artifacts' });
} catch (e) {
if (e.status === 404) {
// create the `ci-artifacts` GitHub release based on the current revision
const workflowRunsURL = `${context.serverUrl}/${
process.env.GITHUB_WORKFLOW_REF.replace(/\/\.github\/workflows\/([^@]+).*/, '/actions/workflows/$1')
}`
return await github.rest.repos.createRelease({
... req,
tag_name: 'ci-artifacts',
body: `Continuous release of \`ci-artifacts\`
This release is automatically updated by the [ci-artifacts](${workflowRunsURL}) workflow.
For technical reasons, allow up to a minute for release assets to be missing while they are updated.`,
});
}
throw e;
}
})()
const fs = require('fs')
for (const fileName of [
'git-sdk-aarch64-minimal.tar.gz',
'git-sdk-aarch64-minimal.zip',
'git-sdk-aarch64-minimal.7z.exe',
]) {
console.log(`Uploading ${fileName}`)
const uploadReq = {
...req,
release_id: release.data.id,
name: fileName,
headers: {
'content-length': (await fs.promises.stat(fileName)).size,
},
data: fs.createReadStream(fileName),
}
// if the asset does not yet exist, simply upload it
const originalAsset = release.data.assets.filter(asset => asset.name === fileName).pop()
if (!originalAsset) {
const asset = await github.rest.repos.uploadReleaseAsset(uploadReq)
console.log(`Uploaded to ${asset.data.browser_download_url}`)
continue
}
// otherwise upload it using a temporary file name,
// then delete the old asset
// and then rename the new asset;
// this way, the asset is not missing for a long time
const asset = await github.rest.repos.uploadReleaseAsset({ ...uploadReq, name: `tmp.${fileName}` })
await github.rest.repos.deleteReleaseAsset({ ...req, asset_id: originalAsset.id })
const updatedAsset = await github.rest.repos.updateReleaseAsset({...req,
asset_id: asset.data.id,
name: fileName,
label: fileName,
})
console.log(`Updated ${updatedAsset.data.browser_download_url}`)
}
await github.rest.git.updateRef({
...req,
ref: 'tags/ci-artifacts',
sha: process.env.GITHUB_SHA,
})