diff --git a/.github/workflows/releases.yml b/.github/workflows/releases.yml index 6f9f6547a..f44689804 100644 --- a/.github/workflows/releases.yml +++ b/.github/workflows/releases.yml @@ -16,10 +16,15 @@ jobs: with: go-version: 1.16 - name: Generate changelog + id: changelog run: | - echo "GORELEASER_CURRENT_TAG=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV - git fetch --unshallow - script/changelog | tee CHANGELOG.md + echo "::set-output name=tag-name::${GITHUB_REF#refs/tags/}" + gh api repos/$GITHUB_REPOSITORY/releases/generate-notes \ + -f tag_name="${GITHUB_REF#refs/tags/}" \ + -f target_commitish=trunk \ + -q .body > CHANGELOG.md + env: + GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} - name: Run GoReleaser uses: goreleaser/goreleaser-action@v2 with: @@ -27,6 +32,7 @@ jobs: args: release --release-notes=CHANGELOG.md env: GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} + GORELEASER_CURRENT_TAG: ${{steps.changelog.outputs.tag-name}} - name: Checkout documentation site uses: actions/checkout@v2 with: diff --git a/docs/releasing.md b/docs/releasing.md index 3c583a80b..f17902c7b 100644 --- a/docs/releasing.md +++ b/docs/releasing.md @@ -1,6 +1,6 @@ # Releasing -Our build system automatically compiles and attaches cross-platform binaries to any git tag named `vX.Y.Z`. The automated changelog is generated from commit messages starting with “Merge pull request …” that landed between this tag and the previous one (as determined topologically by git). +Our build system automatically compiles and attaches cross-platform binaries to any git tag named `vX.Y.Z`. The changelog is [generated from git commit log](https://docs.github.com/en/repositories/releasing-projects-on-github/automatically-generated-release-notes). Users who run official builds of `gh` on their machines will get notified about the new version within a 24 hour period. diff --git a/script/changelog b/script/changelog deleted file mode 100755 index 056f7ce54..000000000 --- a/script/changelog +++ /dev/null @@ -1,24 +0,0 @@ -#!/bin/bash -set -e - -current_tag="${GITHUB_REF#refs/tags/}" -start_ref="HEAD" - -# Find the previous release on the same branch, skipping prereleases if the -# current tag is a full release -previous_tag="" -while [[ -z $previous_tag || ( $previous_tag == *-* && $current_tag != *-* ) ]]; do - previous_tag="$(git describe --tags "$start_ref"^ --abbrev=0)" - start_ref="$previous_tag" -done - -git log "$previous_tag".. --reverse --first-parent --oneline | \ - while read -r sha title; do - if [[ $title == "Merge pull request #"* ]]; then - pr_num="$(grep -o '#[[:digit:]]\+' <<<"$title")" - pr_desc="$(git show -s --format=%b "$sha" | sed -n '1,/^$/p' | tr $'\n' ' ')" - printf "* %s %s\n\n" "$pr_desc" "$pr_num" - else - printf "* %s\n\n" "$title" - fi - done \ No newline at end of file