In this lab you will automate GitHub Releases using the Release Drafter action.
Duration: 15-20 minutes
References:
- About releases
- Automatically generated release notes
- GitHub Action - Release Drafter
- GITHUB_TOKEN - permissions
- Navigate to the action repository release-drafter and read the documentation on how to use the action
- Add a new workflow file
.github/workflows/release-drafter.yml
to your repository - Copy and paste the following content to the newly created file:
name: Release Drafter
on:
push:
branches:
- main
# Comment out the 2 lines if the permissions for the GITHUB_TOKEN is read and write and you get an workflow runtime error
permissions:
contents: write
jobs:
update_release_draft:
runs-on: ubuntu-latest
steps:
- uses: release-drafter/release-drafter@v5
with:
config-name: release-drafter.yml
disable-autolabeler: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- Commit the changes into a new
feature/lab06
branch - Using the same
feature/lab06
branch, add a new configuration file.github/release-drafter.yml
- Copy and paste the following content to the newly created file:
template: |
## What’s Changed
$CHANGES
- Commit the changes into the
feature/lab06
branch - Open a new pull request and merge the
feature/lab06
branch into themain
branch - Go to
Actions
and see the details of yourRelease Drafter
workflow - After the workflow completed, navigate to the
Releases
page to see yourv0.1.0
draft release - Open the configuration file release-drafter.yml
- Copy and paste the more complicate configuration content:
name-template: 'v$RESOLVED_VERSION 🌈'
tag-template: 'v$RESOLVED_VERSION'
categories:
- title: '🚀 Features'
labels:
- 'feature'
- 'enhancement'
- title: '🐛 Bug Fixes'
labels:
- 'fix'
- 'bugfix'
- 'bug'
- title: '🧰 Maintenance'
label: 'chore'
change-template: '- $TITLE @$AUTHOR (#$NUMBER)'
change-title-escapes: '\<*_&' # You can add # and @ to disable mentions, and add ` to disable code blocks.
version-resolver:
major:
labels:
- 'major'
minor:
labels:
- 'minor'
patch:
labels:
- 'patch'
default: patch
template: |
## Changes
$CHANGES
- Commit the changes into a new
feature/lab06
branch - Open a new pull request and add the
enhancement
label - Complete the pull request and merge the
feature/lab06
branch into themain
branch - Go to
Actions
and see the details of yourRelease Drafter
workflow - After the workflow completed, navigate to the
Releases
page to see youv0.1.0
draft release updated - Edit the
v0.1.0
draft release and publish your first release - Open the configuration file release-drafter.yml
- Copy and paste the following content into the
categories
configuration:
- title: '⬆️ Dependencies'
collapse-after: 3
labels:
- 'dependencies'
- Commit the changes into a new
feature/lab06
branch - Open a new pull request and add the
bug
label - Complete the pull request and merge the
feature/lab06
branch into themain
branch - Go to
Actions
and see the details of yourRelease Drafter
workflow - After the workflow completed, navigate to the
Releases
page to see your newv0.1.1
draft release - (Optional) Enable the
autolabeler
option of the Release Drafter and configure it to add automatically a label into a pull request. See details Autolabeler