Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 19 additions & 1 deletion .github/actions/cs-release/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -118,12 +118,30 @@ runs:
NUGET_API_KEY: ${{ steps.nuget-login.outputs.NUGET_API_KEY }}
run: dotnet nuget push "./nupkg/*.nupkg" --source https://api.nuget.org/v3/index.json --skip-duplicate --api-key "$NUGET_API_KEY"

- name: "Release notes"
# GitHub's generated notes, since the previous release of this repository's versions: the newest release whose tag starts
# with `v`. Left to GitHub, the notes start from the newest release of any tag, such as one that only stores CI's builds
if: ${{ inputs.push == 'true' }}
id: release-notes
shell: bash
env:
GH_TOKEN: ${{ inputs.github-token }}
TAG: "v${{ steps.set-version.outputs.VERSION }}"
COMMIT: ${{ github.sha }}
run: |
PREVIOUS_TAG="$(gh api "repos/$GITHUB_REPOSITORY/releases?per_page=100" --jq '[.[] | select(.draft | not) | select(.tag_name | startswith("v"))] | sort_by(.created_at) | last | .tag_name // empty')"
echo "Previous release: ${PREVIOUS_TAG:-(none)}"
arguments=(-f "tag_name=$TAG" -f "target_commitish=$COMMIT")
[[ -n "$PREVIOUS_TAG" ]] && arguments+=(-f "previous_tag_name=$PREVIOUS_TAG")
gh api "repos/$GITHUB_REPOSITORY/releases/generate-notes" "${arguments[@]}" --jq .body > "$RUNNER_TEMP/release-notes.md"
echo "NOTES_PATH=$RUNNER_TEMP/release-notes.md" >> "$GITHUB_OUTPUT"

- name: "Create tag and GitHub release"
if: ${{ inputs.push == 'true' }}
uses: softprops/action-gh-release@efb35369e0ad2afab669f228072c1b0d510eae64 # v3.0.3
with:
token: ${{ inputs.github-token }}
generate_release_notes: true
body_path: ${{ steps.release-notes.outputs.NOTES_PATH }}
prerelease: ${{ inputs.pre-release == 'true' }}
tag_name: "v${{ steps.set-version.outputs.VERSION }}"
target_commitish: ${{ github.sha }}
Expand Down
2 changes: 1 addition & 1 deletion docs/workflows.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ On a private repository, macOS minutes count ten times against your GitHub Actio

## cs-release action

Packs NuGet packages, pushes them to NuGet.org, and creates a tagged GitHub release with the packages attached. It only releases from the default branch, because packages on NuGet.org can't be deleted.
Packs NuGet packages, pushes them to NuGet.org, and creates a tagged GitHub release with the packages attached. It only releases from the default branch, because packages on NuGet.org can't be deleted. The release notes are GitHub's generated list of pull requests since the previous release whose tag starts with `v`, so releases with other tags in the same repository don't count.

This is an action, not a reusable workflow, because of how NuGet.org checks trusted publishing: it matches the policy against the workflow file that contains the job doing the login. An action runs inside your own job, so the policy names your own workflow file. A reusable workflow from this repository would never match ([NuGet/NuGetGallery#11000](https://github.com/NuGet/NuGetGallery/issues/11000)).

Expand Down