-
Notifications
You must be signed in to change notification settings - Fork 14
Start migrating Git for Windows' snapshot builds to GitHub Actions #109
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
Merged
Changes from 1 commit
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
513b8bb
git-artifacts: stop special-casing v2.48.0-rc1
dscho 6b2db73
Scope some workflows to the main repository
dscho 60ac230
downloadAndUnZip: refactor out three separate functions
dscho 59cbfd5
github-release(download): ensure to request a binary download
dscho d7c47eb
github-release: add a function to download assets from a GitHub Release
dscho 905a18b
Merge branch 'embargoed-builds-preamble'
dscho f3a2525
Add a GitHub workflow to prepare the branches for embargoed Git for W…
dscho f7f6a0b
prepare-embargoed-branches: add git-sdk-arm64
dscho 24982d9
prepare-embargoed-branches: support A.B.C.D versions
dscho dd1874e
prepare-embargoed-branches: optionally prepare for MinGit backports
dscho 01ac2f7
Merge branch 'embargoed-branches'
dscho fe95907
git-artifacts(snapshots): work around a bug in `git fetch <bundle>`
dscho 600d642
git-artifacts: trace commands that prepare the git clone
dscho 115a75f
Add a workflow definition to upload Git for Windows' snapshots
dscho 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,60 @@ | ||
name: prepare-embargoed-branches | ||
run-name: Prepare branches for embargoed Git ${{ inputs.version }} | ||
|
||
on: | ||
workflow_dispatch: | ||
inputs: | ||
version: | ||
description: 'The Git version for which to prepare the branches' | ||
required: true | ||
|
||
jobs: | ||
prepare-embargoed-branches: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: sanity check | ||
if: ${{ github.repository_owner == 'git-for-windows' }} | ||
run: echo "This action is not meant to be run on the Git for Windows repository" >&2 && exit 1 | ||
- run: actions/checkout@v4 | ||
- name: identify actor | ||
id: actor | ||
uses: actions/github-script@v7 | ||
with: | ||
script: | | ||
const githubApiRequest = require('./github-api-request') | ||
const answer = await githubApiRequest( | ||
console, | ||
'${{ secrets.GITHUB_TOKEN }}', | ||
'GET', | ||
'/users/${{ github.triggering_actor }}' | ||
) | ||
core.setOutput('name', answer.name) | ||
core.setOutput('email', answer.email || '${{ github.triggering_actor }}@users.noreply.github.com') | ||
- name: configure | ||
run: | | ||
USER_NAME="${{ steps.actor.outputs.name }}" && | ||
USER_EMAIL="${{ steps.actor.outputs.email }}" && | ||
git config --global user.name "$USER_NAME" && | ||
git config --global user.email "$USER_EMAIL" && | ||
git config --global url.https://github.com/${{ github.repository_owner }}.insteadOf \ | ||
https://github.com/embargoed-git-for-windows-builds && | ||
git config --global credential.helper '' && | ||
git config --global --add credential.helper cache | ||
- name: configure push token | ||
uses: actions/github-script@v7 | ||
with: | ||
script: | | ||
const { callGit, getPushAuthorizationHeader } = require('./repository-updates.js') | ||
for (const repo of ['build-extra', 'git', 'git-sdk-32', 'git-sdk-64', 'MINGW-packages']) { | ||
const header = await getPushAuthorizationHeader( | ||
console, | ||
core.setSecret, | ||
${{ secrets.GH_APP_ID }}, | ||
${{ toJSON(secrets.GH_APP_PRIVATE_KEY) }}, | ||
context.repo.owner, | ||
repo | ||
) | ||
console.log(callGit(['config', '--global', `http.https://github.com/${context.repo.owner}/${repo}.extraHeader`, header])) | ||
} | ||
- name: Prepare embargoed branches | ||
run: sh -x ./prepare-embargoed-branches.sh "${{ inputs.version }}" |
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,99 @@ | ||
#!/bin/sh | ||
|
||
die () { | ||
echo "$*" >&2 | ||
exit 1 | ||
} | ||
|
||
dry_run= | ||
mingit= | ||
while case "$1" in | ||
--dry-run|-n) dry_run=1;; | ||
--mingit) mingit=1;; | ||
-*) die "Unknown option: $1";; | ||
*) break;; | ||
esac; do shift; done | ||
|
||
test $# = 1 || | ||
die "Usage: $0 [--dry-run] [--mingit] <version> # e.g. 2.39.1" | ||
|
||
version=${1#v} | ||
if test -z "$mingit" | ||
then | ||
case "$version" in | ||
*[^0-9.]*|*..*|.*|*.) die "Invalid version: '$version'";; | ||
*.*.*) ;; # okay | ||
*) die "Invalid version: '$version'";; | ||
esac | ||
previous_version_prefix=${version%.*}.$((${version##*.}-1)) | ||
branch_name=git-$version | ||
else | ||
previous_version_prefix="$(expr "$version" : '\([0-9]\+\.[0-9]\+\)\.\{0,1\}[0-9]*$')" | ||
test -n "$previous_version_prefix" || die "Invalid version: '$version'" | ||
branch_name=mingit-$previous_version_prefix.x-releases | ||
fi | ||
grep_version_regex="$(echo "$previous_version_prefix" | sed 's/\./\\\\&/g')" | ||
|
||
handle_repo () { | ||
name="$1" | ||
path="$2" | ||
args="$3" | ||
|
||
echo "### Handling $name ###" && | ||
|
||
if test -e "$path/.git" | ||
then | ||
git_dir="$path/.git" | ||
main_refspec="refs/remotes/origin/main:refs/heads/main" | ||
else | ||
# To allow for running this script on Linux/macOS, fall back to cloning to pwd | ||
git_dir=${path##*/}.git && | ||
if test ! -d "$git_dir" | ||
then | ||
# We only need a partial clone | ||
git clone --bare --filter=blob:none \ | ||
https://github.com/git-for-windows/$name "$git_dir" | ||
fi | ||
main_refspec="refs/heads/main:refs/heads/main" | ||
fi && | ||
|
||
# ensure that the `embargoed-git-for-windows-builds` remote is set | ||
remote_url=https://github.com/embargoed-git-for-windows-builds/$name && | ||
case "$(git --git-dir "$git_dir" remote show -n embargoed-git-for-windows-builds)" in | ||
*"Fetch URL: $remote_url"*"Push URL: $remote_url"*) ;; # okay | ||
*) git --git-dir "$git_dir" remote add embargoed-git-for-windows-builds $remote_url;; | ||
esac && | ||
|
||
# if `embargoed-git-for-windows-builds` already has the branch, everything's fine already | ||
revision=$(git --git-dir "$git_dir" ls-remote embargoed-git-for-windows-builds refs/heads/$branch_name | cut -f 1) && | ||
if test -n "$revision" | ||
then | ||
echo "$name already has $branch_name @$revision" | ||
else | ||
git --git-dir "$git_dir" fetch origin main && | ||
revision="$(eval git --git-dir "\"$git_dir\"" rev-list -1 FETCH_HEAD $args)" && | ||
if test -z "$revision" | ||
then | ||
die "No matching revision for $args in $name" | ||
fi && | ||
echo "Creating $branch_name in $name @$revision" && | ||
push_ref_spec="$revision:refs/heads/$branch_name $main_refspec" && | ||
if test -n "$dry_run" | ||
then | ||
git --git-dir "$git_dir" show -s "$revision" && | ||
echo "Would call 'git push embargoed-git-for-windows-builds $push_ref_spec'" | ||
else | ||
echo "git push embargoed-git-for-windows-builds $push_ref_spec" && | ||
git --git-dir "$git_dir" push embargoed-git-for-windows-builds $push_ref_spec | ||
fi | ||
fi | ||
} | ||
|
||
handle_repo git-sdk-32 /c/git-sdk-32 \ | ||
"\"--grep=mingw-w64-i686-git \".*\" -> $grep_version_regex\" -- cmd/git.exe" && | ||
handle_repo git-sdk-64 /c/git-sdk-64 \ | ||
"\"--grep=mingw-w64-x86_64-git \".*\" -> $grep_version_regex\" -- cmd/git.exe" && | ||
handle_repo build-extra /usr/src/build-extra \ | ||
"-- versions/package-versions-$previous_version_prefix\\*-MinGit.txt" && | ||
handle_repo MINGW-packages /usr/src/MINGW-packages \ | ||
"\"--grep=mingw-w64-git: new version .v$grep_version_regex\" -- mingw-w64-git/PKGBUILD" |
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
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.