diff --git a/.github/scripts/generate-release-contributors.sh b/.github/scripts/generate-release-contributors.sh index 0e3b93f38b..c6526c8f3a 100755 --- a/.github/scripts/generate-release-contributors.sh +++ b/.github/scripts/generate-release-contributors.sh @@ -3,14 +3,15 @@ # shellcheck disable=SC2016 # shellcheck disable=SC2086 -from_version=$1 -to_version=$2 +# this should be run on the release branch -# get the date of the first commit on main that wasn't in the from_version +from_version=$1 + +# get the date of the first commit that was not in the from_version from=$(git log --reverse --pretty=format:"%cI" $from_version..HEAD | head -1) -# get the last commit on main that was in the to_version -to=$(git merge-base HEAD $to_version | xargs git log -1 --pretty=format:"%cI") +# get the last commit on main that was included in the release +to=$(git merge-base origin/main HEAD | xargs git log -1 --pretty=format:"%cI") contributors1=$(gh api graphql --paginate -F q="repo:$GITHUB_REPOSITORY is:pr base:main is:merged merged:$from..$to" -f query=' query($q: String!, $endCursor: String) { @@ -66,7 +67,7 @@ query($q: String!, $endCursor: String) { } } ' --jq '.data.search.edges.[].node.body' \ - | grep -oE "#[0-9]{4,}|issues/[0-9]{4,}" \ + | grep -oE "#[0-9]{4,}|$GITHUB_REPOSITORY/issues/[0-9]{4,}" \ | grep -oE "[0-9]{4,}" \ | xargs -I{} gh issue view {} --json 'author,url' --jq '[.author.login,.url]' \ | grep -v '/pull/' \ diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 3c01b78f63..4a7d119983 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -66,13 +66,15 @@ jobs: EOF fi + # the last complex regex is needed because markdown docs render newlines as soft wraps + # while release notes render them as line breaks sed -n "/^## Version $VERSION/,/^## Version /p" CHANGELOG.md \ | tail -n +2 \ | head -n -1 \ | perl -0pe 's/^\n+//g' \ | perl -0pe 's/\n+$/\n/g' \ | sed -r "s,\[#([0-9]+)]\(https://github.com/$GITHUB_REPOSITORY/(pull|issues)/[0-9]+\),#\1," \ - | perl -0pe 's/\n +/ /g' \ + | perl -0pe 's/(?> release-notes.txt # conditional block not indented because of the heredoc @@ -84,7 +86,7 @@ jobs: EOF - .github/scripts/generate-release-contributors.sh v$PRIOR_VERSION $GITHUB_REF_NAME >> release-notes.txt + .github/scripts/generate-release-contributors.sh v$PRIOR_VERSION >> release-notes.txt fi - name: Create GitHub release diff --git a/RELEASING.md b/RELEASING.md index 855cae95e2..4607515f27 100644 --- a/RELEASING.md +++ b/RELEASING.md @@ -33,7 +33,7 @@ In general, patch releases are only made for regressions, memory leaks and deadl * Review and merge the backport pull request that it generates. * Merge a pull request to the release branch updating the `CHANGELOG.md`. * The heading for the release should include the release version but not the release date, e.g. - `## Version 1.9.0 (unreleased)`. + `## Version 1.9.1 (unreleased)`. * Run the [Prepare patch release workflow](https://github.com/open-telemetry/opentelemetry-java/actions/workflows/prepare-patch-release.yml). * Press the "Run workflow" button, then select the release branch from the dropdown list, e.g. `release/v1.9.x`, and click the "Run workflow" button below that. diff --git a/docs/common-github-actions-practices.md b/docs/common-github-actions-practices.md index be62c605d5..7573ffa839 100644 --- a/docs/common-github-actions-practices.md +++ b/docs/common-github-actions-practices.md @@ -397,7 +397,7 @@ Here's some sample `RELEASING.md` documentation that goes with the automation be * Review and merge the backport pull request that it generates. * Merge a pull request to the release branch updating the `CHANGELOG.md`. * The heading for the release should include the release version but not the release date, e.g. - `## Version 1.9.0 (unreleased)`. + `## Version 1.9.1 (unreleased)`. * Run the [Prepare patch release workflow](https://github.com/open-telemetry/TODO/actions/workflows/prepare-patch-release.yml). * Press the "Run workflow" button, then select the release branch from the dropdown list, e.g. `release/v1.9.x`, and click the "Run workflow" button below that. @@ -682,14 +682,17 @@ jobs: EOF fi - # TODO this is dependent on the conventions you follow in your CHANGELOG.md + # TODO the initial sed range match is dependent on the your CHANGELOG.md format + + # the last complex regex is needed because markdown docs render newlines as soft wraps + # while release notes render them as line breaks sed -n "/^## Version $VERSION/,/^## Version /p" CHANGELOG.md \ | tail -n +2 \ | head -n -1 \ | perl -0pe 's/^\n+//g' \ | perl -0pe 's/\n+$/\n/g' \ | sed -r "s,\[#([0-9]+)]\(https://github.com/$GITHUB_REPOSITORY/(pull|issues)/[0-9]+\),#\1," \ - | perl -0pe 's/\n +/ /g' \ + | perl -0pe 's/(?> release-notes.txt ``` @@ -749,8 +752,8 @@ For example to send a PR to notify/update another repository that a new release as part of the release workflow. Note that the Personal Access Token used will need `workflow` (Update GitHub Action workflows) -permission since it will be updating the workflows of the origin repository when it pushes the -branch and workflows have been updated upstream. +permission since if workflows have been updated upstream it will be updating the workflows of the +origin repository when it pushes the branch. ```yaml - uses: actions/checkout@v3