Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create release with template and release notes #22622

Merged
merged 6 commits into from
Sep 4, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
18 changes: 18 additions & 0 deletions .github/release-template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
This week's push hero is @{{GITHUB_USER}}
KevinMind marked this conversation as resolved.
Show resolved Hide resolved

Latest Release: [{{LATEST_TAG}}]({{LAST_RELEASE_URL}})
KevinMind marked this conversation as resolved.
Show resolved Hide resolved

## 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:
11 changes: 11 additions & 0 deletions .github/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
changelog:
categories:
- title: Notable things shipping
labels:
- '*'
exclude:
labels:
- dependencies
- title: Dependendabots
labels:
- dependencies
72 changes: 72 additions & 0 deletions .github/workflows/draft_release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
name: Draft Release

on:
workflow_dispatch:
inputs:
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: |
# Format current date as YYYY.MM.DD

if [[ "${{ github.event_name}}" == 'workflow_dispatch' ]]; then
tag="${{ github.event.inputs.tag }}"
else
tag=$(date +'%Y.%m.%d')
KevinMind marked this conversation as resolved.
Show resolved Hide resolved
fi

#Validate the tag is formatted correctly YYYY.MM.DD or YYYY.MM.DD-rcX
# where rcX is a whole number greater than zero
KevinMind marked this conversation as resolved.
Show resolved Hide resolved
if [[ ! $tag =~ ^[0-9]{4}\.[0-9]{2}\.[0-9]{2}(-rc[0-9]+)?$ ]]; then
echo "Invalid tag format. Must be YYYY.MM.DD or YYYY.MM.DD-rcX"
exit 1
fi
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the YYYY.MM.DD-rcX for? It's new.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need to support cherry pick releases. 2024.09.05-23 for example. Good catch though, I accidentally included rc in the regex.. will remove.


# 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
latest_release=$(
gh api \
-H "Accept: application/vnd.github+json" \
-H "X-GitHub-Api-Version: 2022-11-28" \
/repos/mozilla/addons-server/releases/latest
)

latest_tag=$(echo $latest_release | jq -r '.tag_name')
latest_release_url=$(echo $latest_release | jq -r '.html_url')

cat <<EOF
$latest_release
EOF

# Cat the file ../release-template.md
template=$(cat .github/release-template.md)

# Replace {{GITHUB_USER}} in template with ${{ github.actor }}
template=${template//\{\{GITHUB_USER\}\}/${{ github.actor }}}

# Replace {{LATEST_TAG}} in template with $latest_tag
template=${template//\{\{LATEST_TAG\}\}/$latest_tag}

# Replace {{LAST_RELEASE_URL}} in template with $latest_release_url
template=${template//\{\{LAST_RELEASE_URL\}\}/$latest_release_url}

gh release create $tag \
--title $tag \
--target master \
--notes "$template" \
--draft
Loading