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
13 changes: 10 additions & 3 deletions .github/actions/release/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,12 @@ and the notes are its description.
## Usage

```yaml
name: Release

on:
pull_request:
types: [closed]
# NOTE: some repos still use `master`.
branches: [main]

permissions: {}
Expand All @@ -23,17 +26,19 @@ jobs:
permissions:
# Required to create the draft release.
contents: write
# Required to comment the draft release on the pull request.
pull-requests: write

steps:
# Pin to a commit of `mozilla/addons`.
- uses: mozilla/addons/.github/actions/release@43401a931ebc09f2e511deed766171b0105414bc
with:
repo: ${{ github.repository }}
sha: ${{ github.event.pull_request.merge_commit_sha }}
pr: ${{ github.event.pull_request.number }}
github_token: ${{ secrets.GITHUB_TOKEN }}
```

All three inputs are required. Outputs: `version` and `url`.
All four inputs are required. Outputs: `version` and `url`.

## Release process

Expand All @@ -53,7 +58,9 @@ Here is an example for an `npm` package:
# Write the release notes in the description of this commit, also the commit
# title might just be "$version" or something more fancy, but it must have
# the version number in it.
git commit --edit --message ":arrow_up: release $version"
#
# `--cleanup=scissors` is used to allow markdown headers in the commit body.
git commit --edit --message ":arrow_up: release $version" --cleanup=scissors
git push -u origin "releases/$version"
```

Expand Down
24 changes: 17 additions & 7 deletions .github/actions/release/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ inputs:
description: >
The merge commit to release: it is the target of the release, its title
has the version and its description has the release notes.
pr:
required: true
description: The number of the release pull request, to comment the draft on
github_token:
required: true
description: The GitHub token
Expand All @@ -36,6 +39,7 @@ runs:
GH_TOKEN: ${{ inputs.github_token }}
GH_REPO: ${{ inputs.repo }}
sha: ${{ inputs.sha }}
pr: ${{ inputs.pr }}
run: |
set -o pipefail

Expand Down Expand Up @@ -81,10 +85,16 @@ runs:
echo "url=$url" >> "$GITHUB_OUTPUT"
cat "$GITHUB_OUTPUT"

{
echo "### The draft release for \`$version\` is ready"
echo ""
echo "Nothing has been released yet. Publishing this draft creates the \`$version\` tag, which publishes the package:"
echo ""
echo "$url"
} >> "$GITHUB_STEP_SUMMARY"
body=$(printf '%s\n' \
"### The draft release for \`$version\` is ready" \
"" \
"Nothing has been released yet. Publishing this draft creates the \`$version\` tag, which publishes the package:" \
"" \
"$url")

printf '%s\n' "$body" >> "$GITHUB_STEP_SUMMARY"

# Commenting is a convenience, so a missing `pull-requests: write`
# permission should not fail a release that has been drafted already.
printf '%s\n' "$body" | gh pr comment "$pr" --body-file - ||
echo "::warning::could not comment on the release pull request."
Loading