name: A GitHub Action for creating GitHub Releases
on: push
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Release
uses: softprops/action-gh-release@v2
if: startsWith(github.ref, 'refs/tags/')
action-gh-release
GitHub Action for creating GitHub Releases
How to create GitHub Releases using GitHub Actions?
action-gh-release is a GitHub Action that simplifies the creation of GitHub Releases across multiple OS environments like Linux, Windows, and macOS. It's particularly useful because it triggers only when you push tags, making it highly efficient for managing releases without cluttering the workflow with non-tag pushes.
Here’s a quick guide on how it works:
-
Tag-Based Triggers: The action only runs when you push tags. You can set this up in your workflow file using conditions in the
step.if
field or by specifying tag patterns directly in the push configurations. -
Setting Up the Workflow:
- Main Job: Set to run on the latest Ubuntu environment.
- Steps Include:
- Checkout: Fetch your code.
- Conditional Release: Trigger the release process using
softprops/action-gh-release@v2
if the commit starts with a tag reference.
-
Uploading Assets:
- You can specify which files to upload by listing them or using glob patterns. For instance, to upload
Release.txt
andLICENSE
, you simply specify these in thefiles
field under the release step.
- You can specify which files to upload by listing them or using glob patterns. For instance, to upload
-
Customizing Release Notes:
- The action supports external release notes, allowing you to use any changelog generator or manually create them. Simply point to the file containing the release notes using the
body_path
attribute.
- The action supports external release notes, allowing you to use any changelog generator or manually create them. Simply point to the file containing the release notes using the
-
Handling Paths in Windows:
- Remember to use forward slashes in file paths to avoid issues in pattern matching.
-
Advanced Options:
- You have various optional settings like draft, prerelease status, assets uploads, and more, which you can tailor according to your needs.
This setup not only makes your release process smoother but also ensures that every release is consistent and well-documented.