forked from git-for-windows/git-sdk-64
-
Notifications
You must be signed in to change notification settings - Fork 5
ci: add ci-artifacts pipeline #22
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
dennisameling
merged 1 commit into
git-for-windows:main
from
dennisameling-org:add-ci-artifacts
Sep 15, 2024
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,160 @@ | ||
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.event.repository.fork == false | ||
runs-on: [Windows, ARM64] | ||
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: 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 && | ||
(cd minimal-sdk && ../7z.exe a -mmt=on -mx9 ../artifacts/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 \ | ||
../artifacts/git-sdk-aarch64-minimal.7z.exe * .?*) | ||
- name: run some tests | ||
shell: bash | ||
run: | | ||
set -x | ||
. /etc/profile | ||
|
||
# cygpath works | ||
test "$(cygpath -aw /)" = "${{github.workspace}}\minimal-sdk" || exit 1 | ||
|
||
# comes with Clang and can compile a DLL | ||
test "$(type -p clang)" = "/clangarm64/bin/clang" || exit 1 | ||
cat >dll.c <<-\EOF && | ||
__attribute__((dllexport)) int increment(int i) | ||
{ | ||
return i + 1; | ||
} | ||
EOF | ||
|
||
clang -Wall -g -O2 -shared -o sample.dll dll.c || exit 1 | ||
ls -la | ||
dennisameling marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
# stat works | ||
test "stat is /usr/bin/stat" = "$(type stat)" || exit 1 | ||
stat /usr/bin/stat.exe || exit 1 | ||
|
||
# unzip works | ||
test "unzip is /usr/bin/unzip" = "$(type unzip)" || exit 1 | ||
git init unzip-test && | ||
echo TEST >unzip-test/README && | ||
git -C unzip-test add -A && | ||
git -C unzip-test -c user.name=A -c [email protected] commit -m 'Testing, testing...' && | ||
git --git-dir=unzip-test/.git archive -o test.zip HEAD && | ||
unzip -v test.zip >unzip-test.out && | ||
cat unzip-test.out && | ||
test "grep is /usr/bin/grep" = "$(type grep)" || exit 1 | ||
grep README unzip-test.out | ||
- name: publish release assets | ||
if: github.event_name == 'push' && github.ref == 'refs/heads/main' | ||
uses: actions/github-script@v7 | ||
with: | ||
script: | | ||
process.chdir('artifacts') | ||
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, | ||
}) |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.