Create release with template and release notes (#22622)

* Create release with template and release notes

* TMP: update from comments

* TMP: update release template with changelog sections

* TMP: use release hero input for GITHUB_USER template variable

* Rename LATEST -> PREVIOUS

* TMP: apply typo fix
This commit is contained in:
Kevin Meinhardt 2024-09-04 11:29:12 +02:00 коммит произвёл GitHub
Родитель ab3c1c130a
Коммит d63e7e7fb1
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: B5690EEEBB952194
3 изменённых файлов: 127 добавлений и 0 удалений

28
.github/release-template.md поставляемый Normal file
Просмотреть файл

@ -0,0 +1,28 @@
This week's push hero is @{{GITHUB_USER}}
Previous Release: [{{PREVIOUS_TAG}}]({{PREVIOUS_RELEASE_URL}})
## Blockers:
## Cherry-picks:
<!-- Link to the actual commits, NOT merge commits. The commits need to appear
in chronological order so that `git cherry-pick` will apply them correctly. -->
## Before we push:
## Before we start:
## Before we promote:
## After we're done:
## Addons-Frontend Changelog:
<!-- Link to the tag comparison of the target tag and the previous tag for addons-frontend
https://github.com/mozilla/addons-frontend/compare/<PREVIOUS_TAG...<CURRENT_TAG>
-->
## Addons Server Changelog:
<!-- This section will be automatically populated once the release notes are auto generated -->

11
.github/release.yml поставляемый Normal file
Просмотреть файл

@ -0,0 +1,11 @@
changelog:
categories:
- title: Notable things shipping
labels:
- '*'
exclude:
labels:
- dependencies
- title: Dependendabots
labels:
- dependencies

88
.github/workflows/draft_release.yml поставляемый Normal file
Просмотреть файл

@ -0,0 +1,88 @@
name: Draft Release
on:
workflow_dispatch:
inputs:
push_hero:
description: The person responsible for facilitating the release.
required: true
type: choice
options:
- kevinmind
- diox
- eviljeff
tag:
description: 'Release date YYYY.MM.DD Also used to generate the tag name.'
required: true
jobs:
draft_release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Create Release Draft
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
shell: bash
run: |
if [ -z "${{ github.event.inputs.tag }}" ]; then
echo "Tag is required"
exit 1
fi
if [ -z "${{ github.event.inputs.push_hero }}" ]; then
echo "Push hero is required"
exit 1
fi
# Format current date as YYYY.MM.DD
if [[ "${{ github.event_name}}" == 'workflow_dispatch' ]]; then
tag="${{ github.event.inputs.tag }}"
fi
# Validate the tag is formatted correctly YYYY.MM.DD or YYYY.MM.DD-X
# where X is a whole number greater than zero
if [[ ! $tag =~ ^[0-9]{4}\.[0-9]{2}\.[0-9]{2}(-[0-9]+)?$ ]]; then
echo "Invalid tag format. Must be YYYY.MM.DD or YYYY.MM.DD-X"
exit 1
fi
# Verify that a release with this tag does not already exist
if gh release view $tag &> /dev/null; then
echo "Release $tag-next already exists"
exit 1
fi
# Get the latest release tag
previous_release=$(
gh api \
-H "Accept: application/vnd.github+json" \
-H "X-GitHub-Api-Version: 2022-11-28" \
/repos/mozilla/addons-server/releases/latest
)
previous_tag=$(echo $previous_release | jq -r '.tag_name')
previous_release_url=$(echo $previous_release | jq -r '.html_url')
cat <<EOF
$previous_release
EOF
# Cat the file ../release-template.md
template=$(cat .github/release-template.md)
# Replace {{GITHUB_USER}} in template with ${{ github.event.inputs.push_hero }}
template=${template//\{\{GITHUB_USER\}\}/${{ github.event.inputs.push_hero }}}
# Replace {{PREVIOUS_TAG}} in template with $previous_tag
template=${template//\{\{PREVIOUS_TAG\}\}/$previous_tag}
# Replace {{PREVIOUS_RELEASE_URL}} in template with $previous_release_url
template=${template//\{\{PREVIOUS_RELEASE_URL\}\}/$previous_release_url}
gh release create $tag \
--title $tag \
--target master \
--notes "$template" \
--draft