This is a reusable workflow to tag and release a new version of a GitHub action or workflow.
The workflow takes a semantic version as input.
It validates the version, tags the repository on the main
branch, and creates a GitHub Release.
The input version must be a 3-component semantic version: A.B.C
.
(The version may have a v
prefix; the workflow accounts for that.)
It then creates the tag vA.B.C
.
It also force creates the tags vA.B
and vA
at the same commit.
This lets users of your workflow automatically get updates that they want.
To use this workflow, just set it in the uses
key of a job in your project's workflow file.
Here is an example workflow snippet that calls this workflow with a hard code 1.0.0
version:
jobs:
release:
name: New Release
uses: brobeson/ActionRelease/.github/workflows/release.yaml@v1
with:
version: "1.0.0"
One method to pass a new version to this workflow, is for your calling workflow to use on.workflow_dispatch
and require a version input.
on:
workflow_dispatch:
inputs:
version:
description: The new version.
required: true
type: string
jobs:
release:
name: New Release
uses: brobeson/ActionRelease/.github/workflows/release.yaml@v1
with:
version: ${{inputs.version}}
Warning
The action release workflow will fail if you try to automatically run it when you create a tag in your repository. I'll address this in a future version of the action release workflow.
Key | Required | Type | Description |
---|---|---|---|
version |
yes | string | The semantic version of the new release. |
The workflow runs the following steps.
- Verify the Version
The version must be a 3-component semantic version. This step verifies the input. Av
prefix, such asv1.0.0
, is allowed; the workflow strips it out. - Clone the Repository
This step just clones the repository to the runner. - Tag the Repository
This step creates the local tagsvA.B.C
,vA.B
, andvA
on themain
branch. The tagsvA.B
andvA
are created with--force
; if they already exist, they move to the new commit. - Push the Tags
This step force pushes the new tags to the origin remote. - Create a Release
This step creates a new GitHub Release at the newvA.B.C
tag. The release title isA.B.C
. For now, the release notes are empty.