-
Notifications
You must be signed in to change notification settings - Fork 138
[main] Automatically create new security-partners-dotnet branches with tarball contents in pre-release pipeline #3130
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 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
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,113 @@ | ||
| #!/bin/bash | ||
| set -euo pipefail | ||
|
|
||
| print-help () | ||
| { | ||
| echo "Updates the VMR" | ||
| echo | ||
| echo "Syntax: ./update-vmr.sh --releaseChannel 7.0 --sdkVersion 7.0.100 --upstream <valid git url> --tarball dotnet-sdk-source.tar.gz" | ||
| echo | ||
| echo "options:" | ||
| echo "--releaseChannel, -r The .NET SDK release channel (e.g. 6.0)" | ||
| echo "--sdkVersion, -v The .NET SDK version (e.g. 6.0.110)" | ||
| echo "--upstream, -u A valid git URL to the upstream repo to update from and push to" | ||
| echo "--tarball, -t The tarball to update the VMR with" | ||
| echo "--isDryRun, -d (Optional) If set, then don't push results to upstream" | ||
| echo "--help, -h (Optional) print this help message and exit" | ||
| echo | ||
| } | ||
|
|
||
| SHORT=r:v:u:t:dh | ||
| LONG=releaseChannel:,sdkVersion:,upstream:,tarball:,isDryRun,help | ||
|
|
||
| OPTS=$(getopt --options $SHORT --long $LONG --name "$0" -- "$@") | ||
| if [ $? != 0 ] ; then echo "Failed to parse options." >&2 ; exit 1 ; fi | ||
| eval set -- "$OPTS" | ||
|
|
||
| is_dry_run='false' | ||
|
|
||
| while true ; do | ||
| case "$1" in | ||
| -h | --help ) | ||
| print-help | ||
| exit 0 | ||
| ;; | ||
| -r | --releaseChannel ) | ||
| release_channel="$2" | ||
| shift 2 | ||
| ;; | ||
| -v | --sdkVersion ) | ||
| sdk_version="$2" | ||
| shift 2 | ||
| ;; | ||
| -u | --upstream ) | ||
| upstream_url="$2" | ||
| shift 2 | ||
| ;; | ||
| -t | --tarball ) | ||
| source_tarball="$2" | ||
| shift 2 | ||
| ;; | ||
| -d | --isDryRun ) | ||
| is_dry_run=true | ||
| shift | ||
| ;; | ||
| -- ) | ||
| shift | ||
| break | ||
| ;; | ||
| *) | ||
| echo "Internal error! Are you missing required arguments?" | ||
| exit 1 | ||
| ;; | ||
| esac | ||
| done | ||
|
|
||
| : ${release_channel:?Missing --releaseChannel} | ||
| : ${sdk_version:?Missing --sdkVersion} | ||
| : ${upstream_url:?Missing --upstream} | ||
| : ${source_tarball:?Missing --tarball} | ||
|
|
||
| if [ ! -f "${source_tarball}" ]; then | ||
| echo "##vso[task.logissue type=error]File ${source_tarball} not found on disk. Exiting..." | ||
| fi | ||
|
|
||
| month_year=$(date +"%b%Y" -d "+1 month" | sed 's/.*/\L&/') # e.g. aug2022 | ||
|
|
||
| vmr_path="$(pwd)/dotnet-vmr" | ||
|
|
||
| # replace the last two characters in sdk_version with xx | ||
| branch_version=$(echo ${sdk_version} | sed 's/..$/xx/') | ||
| target_branch="release/${branch_version}" # e.g. release/6.0.1xx | ||
|
|
||
| rm -rf "${vmr_path}" | ||
| git init "${vmr_path}" | ||
|
|
||
| pushd "${vmr_path}" | ||
| git remote add upstream "${upstream_url}" | ||
| git fetch upstream "${target_branch}" --depth=1 | ||
|
|
||
| git checkout "${target_branch}" | ||
|
|
||
| new_branch_name="dev/${sdk_version}-${month_year}" | ||
| git checkout -b "${new_branch_name}" | ||
|
|
||
| # delete all contents except the .git folder | ||
| # otherwise we won't catch deleted files in a commit | ||
| ls | grep -v ".git" | xargs rm -rf | ||
| tar -xzf "${source_tarball}" -C "${vmr_path}" | ||
|
|
||
| git add -f . | ||
|
|
||
| git config user.email "dotnet-maestro[bot]@users.noreply.github.com" | ||
| git config user.name "dotnet-maestro[bot]" | ||
| git commit -m "Update to .NET ${sdk_version}" | ||
|
|
||
| if [ "$is_dry_run" = true ]; then | ||
| echo "Doing a dry run, not pushing to upstream. List of changes:" | ||
| git log --name-status HEAD^..HEAD | ||
| else | ||
| echo "Pushing branch to upstream." | ||
| git push -u upstream "${new_branch_name}" | ||
| fi | ||
| popd | ||
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.