forked from microsoft/Oryx
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding automatic release notes from changelog file. (microsoft#16)
* Adding automatic release notes from changelog file. * PR fixes
- Loading branch information
Showing
4 changed files
with
65 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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,9 @@ | ||
|
||
[//]: # (This file contains all the changes that should be displayed in our releases.) | ||
[//]: # (In order to use it, add new lines below this comment session, above existing ones.) | ||
[//]: # (The build and release systems will only add the new lines to the release, so NEVER edit an existing line,) | ||
[//]: # (since it would make it appear again in the release.) | ||
[//]: # (Add meaningful description of your changes, and if relevant how to make use of a new feature you're adding,) | ||
[//]: # (as well as pointers to relevant documentation in our docs folder.) | ||
|
||
- Officially releasing on GitHub. |
This file contains 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,8 @@ | ||
|
||
[//]: # (This file contains all the changes that should be displayed in our releases.) | ||
[//]: # (In order to use it, add new lines below this comment session, leaving the remaining lines in the file.) | ||
[//]: # (The build and release systems will only add the new lines to the release, so NEVER edit an existing line,) | ||
[//]: # (since it would make it appear again in the release.) | ||
[//]: # (Add meaningful description of your changes, and if relevant how to make use of a new feature you're adding,) | ||
[//]: # (as well as pointers to relevant documentation in our docs folder.) | ||
|
This file contains 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 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,42 @@ | ||
#!/bin/bash | ||
# -------------------------------------------------------------------------------------------- | ||
# Copyright (c) Microsoft Corporation. All rights reserved. | ||
# Licensed under the MIT license. | ||
# -------------------------------------------------------------------------------------------- | ||
|
||
# This script reads `./CHANGELOG.md` file and produces a file that is added as a build artifact which | ||
# contains the changes only to a partcular build. | ||
# To achieve this, we use the tags that the release adds to the git repo, and do a `git diff` between the | ||
# changelog file in that tag and HEAD. The output of this diff is later parsed to only output the new lines. | ||
# In order for this script to work, the agent running it should have the full git repo available. | ||
|
||
set -e | ||
|
||
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" | ||
CHANGELOG_FILE="$DIR/../CHANGELOG.md" | ||
|
||
OUTPUT_FILE=$1 | ||
if [ -z "$OUTPUT_FILE" ]; then | ||
# Create a default file using DevOps' pipeline artifacts directory | ||
OUTPUT_FILE=$BUILD_ARTIFACTSTAGINGDIRECTORY/Release-notes.md | ||
fi | ||
|
||
echo "Release notes will be placed in $OUTPUT_FILE" | ||
|
||
# First, we look for the latest tag that was pushed. Since our builds numbers are lexicographically ordered, | ||
# YYYYMMDD.P, we just take the latest value that starts with a `2` to avoid other tags that might be in the repo. | ||
# Optimistic note: yes, this script will break in year 3000, but we can fix it then. | ||
LAST_TAG=$(git tag --sort=committerdate | tail -n 1) | ||
|
||
if [ -z "$LAST_TAG" ]; then | ||
echo "Couldn't find a base tag, will output the entire file" | ||
# Ignore the lines starting with [//] which we're using as comments. | ||
cat $CHANGELOG_FILE | grep -v -e '^\[//\]' > $OUTPUT_FILE | ||
else | ||
echo "Getting the diff from latest tag, $LAST_TAG" | ||
# Get the diff for the changelog file | ||
# The regex ^+[^+] is used to capture only the added lines, and the [^+], which means "exclude '+', removes the | ||
# lines that git adds to the diff output containing the file name. Finally, we remove the '+' from the beginning | ||
# of the selected lines. | ||
git diff $LAST_TAG HEAD | grep -e ^+[^+] | sed 's/^+//' > $OUTPUT_FILE | ||
fi |