-
Notifications
You must be signed in to change notification settings - Fork 777
Tool for generating image release changes #868
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
5 commits
Select commit
Hold shift + click to select a range
99baea1
Tool for generating image release changes
eljog 6b1d82a
commit hash not needed for monthly
eljog 27c416d
Merge branch 'main' into eljog/tool-for-generating-image-release-changes
eljog 1200d60
Merge branch 'main' into eljog/tool-for-generating-image-release-changes
eljog 39eb179
Merge branch 'main' into eljog/tool-for-generating-image-release-changes
eljog 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
Next
Next commit
Tool for generating image release changes
- Loading branch information
commit 99baea12eae074c4757fdeed573b45923b8d16df
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,79 @@ | ||
| #!/bin/bash | ||
|
|
||
| # This script is used to prepare a release of the dev containers. | ||
| # It will bump the version of the manifest.json file and run the devcontainer upgrade command. | ||
| # It will only run on the images that have been modified since the last release commit that is passed in as the first argument. | ||
| # If the second argument is "monthly", it will run on all images. | ||
| # Example adhoc release: ./build/prepare-release.sh 1c6f558dc86aafd7749074ec44e238f331303517 | ||
| # Example monthly release: ./build/prepare-release.sh 1c6f558dc86aafd7749074ec44e238f331303517 monthly | ||
|
|
||
|
|
||
| SCRIPT_SOURCE_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" | ||
| SRC_DIR=$(readlink -m $SCRIPT_SOURCE_DIR/../src) | ||
| MANIFEST_FILE="manifest.json" | ||
| COMMIT_HASH=$1 | ||
| RELEASE_TYPE=$2 | ||
|
|
||
| get_modified_images() { | ||
| git diff --name-only --diff-filter=ACMRTUB ${COMMIT_HASH} HEAD ${SRC_DIR} | while read file; do | ||
| if [ ! -z $file ]; then | ||
| commitMessage=$(git log -1 $file) | ||
| # omit auto commits from bot | ||
| if [[ $commitMessage != *"Dev containers Bot"* ]]; then | ||
| # only get the top level directory for the image | ||
| if [ $(echo $file | tr "/" "\n" | wc -l) -eq 3 ]; then | ||
| readlink -m $(dirname $file) | ||
| fi | ||
| fi | ||
| fi | ||
| done | sort | uniq | ||
| } | ||
|
|
||
| get_all_images() { | ||
| find $SRC_DIR -maxdepth 1 -type d | tail -n +2 | sort | uniq | ||
| } | ||
|
|
||
| bump_version() { | ||
samruddhikhandale marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| directory=$1 | ||
| manifestPath="$directory/$MANIFEST_FILE" | ||
| version=$(grep -oP '(?<="version": ")[^"]*' $manifestPath) | ||
| newVersion=$(echo $version | awk -F. -v OFS=. '{$NF += 1 ; print}') | ||
| sed -i "s/\"version\": \"$version\"/\"version\": \"$newVersion\"/g" $manifestPath | ||
| } | ||
|
|
||
| release_image() { | ||
| image=$1 | ||
| echo "-----------------------------------------------" | ||
| echo "Releasing image $image" | ||
| echo "-----------------------------------------------" | ||
|
|
||
| bump_version $image | ||
| devcontainer upgrade --workspace-folder $image | ||
| } | ||
|
|
||
| adhoc_release() { | ||
| for image in $(get_modified_images); do | ||
| release_image $image | ||
| done | ||
| } | ||
|
|
||
| monthly_release() { | ||
| for image in $(get_all_images); do | ||
| release_image $image | ||
| done | ||
| } | ||
|
|
||
| main() { | ||
| if [ "$COMMIT_HASH" == "" ]; then | ||
| echo "Commit hash is required" | ||
| exit 1 | ||
| fi | ||
|
|
||
| if [ "$RELEASE_TYPE" == "monthly" ]; then | ||
| monthly_release | ||
| else | ||
| adhoc_release | ||
| fi | ||
| } | ||
|
|
||
| main | ||
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.