A GitHub action to create a release from branch when pushing a new tag.
Other notable packages that did not satisfy my use case:
- https://github.com/softprops/action-gh-release (can not release from branch)
- https://github.com/release-it/release-it (npm package rather than an action, but still could not release from branch)
- https://github.com/aaiezza/create-release (too bloated with features/libraries I don't need, and relies on deprecated auth method)
name: Tag it with defaults
on:
push:
tags:
- "*"
jobs:
create-release:
permissions:
contents: write
runs-on: ubuntu-latest
steps:
- name: checkout
uses: actions/checkout@v3
with:
fetch-depth: 0 # need this for all history for all branches and tags
- name: Create Release
id: create_release
uses: nickatnight/releases-action@v5
if: startsWith(github.ref, 'refs/tags/')
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
outputs:
ReleaseTag: ${{ steps.create_release.outputs.release_tag }}
# pass in as env variable
explore-essos:
runs-on: ubuntu-latest
needs: [create-release]
env:
RELEASE_TAG: ${{ needs.create-release.outputs.ReleaseTag }}
steps:
...
name: Tag it with parameters
on:
push:
tags:
- "*"
jobs:
create-release:
permissions:
contents: write
runs-on: ubuntu-latest
steps:
- name: checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Create Release
id: create_release
uses: nickatnight/releases-action@v5
if: startsWith(github.ref, 'refs/tags/')
with:
branch: "main"
name: "Gryffindor Release"
message: "Yer a wizard Harry"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
outputs:
ReleaseTag: ${{ steps.create_release.outputs.release_tag }}
# pass in as env variable
conquer-muggles:
runs-on: ubuntu-latest
needs: [create-release]
env:
RELEASE_TAG: ${{ needs.create-release.outputs.ReleaseTag }}
steps:
...
Parameter | Description | Default |
---|---|---|
branch |
Which branch do we want to release from? | master |
name |
Name of the release | name of tag |
message |
Body of the release | autogenerated |
draft |
Is this a draft? | false |
prerelease |
Is this a prerelease? | false |
tag |
Name of tag | GITHUB_REF |