on:
workflow_dispatch:
# Inputs the workflow accepts.
inputs:
version:
# Friendly description to be shown in the UI instead of 'name'
description: 'Semver type of new version (major / minor / patch)'
# Input has to be provided for the workflow to run
required: true
type: choice
options:
- patch
- minor
- major
This on
block in the GitHub Actions workflow defines an event trigger for manual execution of the workflow using the workflow_dispatch
event.
permissions:
# For pushing tags and commits purposes
contents: write
# Reading issues (Not yet implemented)
issues: read
# Creating PRs
pull-requests: write
This configuration ensures that the GitHub Actions workflow has the necessary permissions to perform its tasks.
jobs:
create-release:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
# Branch that should be git checkout
ref: main
fetch-depth: 0
persist-credentials: true
- name: Set up Git
Ensures that the Github Action steps have access to your code on a certain branch.
- name: Create tag
id: tag-generation
uses: mathieudutour/[email protected]
with:
# patch: vx.x.x+1
# minor: vx.x+1.x
# major: vx+1.x.x
default_bump: ${{ github.event.inputs.version }}
# Required
github_token: ${{ secrets.GITHUB_TOKEN }}
It will fetch your latest tags and make a version bump based on your workflow_dispatch input (On Step 1). Don't need to worry about the ${{ secrets.GITHUB_TOKEN }}
as it is automatically provided by GitHub based on the permissions (On Step 2).
- name: automatic-release
uses: softprops/[email protected]
with:
# Required
token: ${{ secrets.GITHUB_TOKEN }}
# Release name
# Value from the Create Tag step output
# For more details: <https://github.com/mathieudutour/github-tag-action/blob/master/README.md>
tag_name: ${{ steps.tag-generation.outputs.new_tag }}
# Automatic generate pull request list starts from the latest version
generate_release_notes: true
prerelease: false
# .github/release.yml
changelog:
exclude:
labels:
- ignore-for-release
- github-actions
authors:
- octocat
- renovate[bot]
categories:
- title: Breaking Changes 🛠
labels:
- breaking-change
- title: Exciting New Features 🎉
labels:
- enhancement
- feature
- title: Bug fixes 🐛
labels:
- bug
- title: Other Changes 🔄
labels:
- "*"
A sample configuration to modify the CHANGELOG.md
for your release notes. Locate it in the .github/release.yml
directory. This will categorize your pull requests according to the labels given.
Github Link: https://github.com/softprops/action-gh-release/blob/master/.github/release.yml