Skip to content
Use this GitHub action with your project
Add this Action to an existing workflow or create a new one
View on Marketplace

Repository files navigation

Release GitHub Actions

CI StatuscodecovCodeFactorLicense: MIT

Read this in other languages: English, 日本語.

This is a GitHub Actions that automates the release of GitHub Actions.
Once you create a new tag, this action will automatically

  1. Run build
  2. Create branch for release
  3. Change tags to release branch
  4. If there is release which has same tag name and has been published, re-publish it (Because if the tag is changed, the release will be in a draft state).

Table of Contents

Details

generated with TOC Generator

Usage

e.g. .github/workflows/release.yml

#on:# push:# tags:# - "v*"on: createname: Releasejobs:
release:
name: Release GitHub Actionsruns-on: ubuntu-lateststeps:
- uses: technote-space/release-github-actions@v6

More details of target event

CLI Tool

technote-space/release-github-actions-cli - GitHub

Screenshot

Release

Options

namedescriptiondefaultrequirede.g.
BUILD_COMMANDBuild command
More details of execute command
yarn build:all
CLEAN_TARGETSFiles or directories to clean before release (Comma separated)
Absolute path and .. are not permitted to use.
More details of execute command
.[!.]*,__tests__,docs,src,*.[jt]s,*.[mc][jt]s,*.json,*.lock,*.yml,*.yamltrue.[!.]*,*.txt
PACKAGE_MANAGERPackage manager to use to install dependencies
If there is yarn.lock or package-lock.json, the action automatically determines the package manager to use, but this option can be used to specify it explicitly.
npm or yarn
yarn
COMMIT_MESSAGECommit messagefeat: build for releasetruefeat: release
COMMIT_NAMECommit namegithub-actions[bot]true
COMMIT_EMAILCommit email41898282+github-actions[bot]@users.noreply.github.comtrue
BRANCH_NAMEBranch name for GitHub Actions releasegh-actionstruegh-actions/${MAJOR}/${MINOR}/${PATCH}
BUILD_COMMAND_TARGETCommand for search build commandprepare, build, production, prod, package, packcompile
ALLOW_MULTIPLE_BUILD_COMMANDSWhether to allow run multiple build commands.truefalse
CREATE_MAJOR_VERSION_TAGWhether to create major version tag (e.g. v1)
Detail of tags
truefalse
CREATE_MINOR_VERSION_TAGWhether to create minor version tag (e.g. v1.2)
Detail of tags
truefalse
CREATE_PATCH_VERSION_TAGWhether to create patch version tag (e.g. v1.2.3)
Detail of tags
truefalse
FETCH_DEPTHLimit fetching to the specified number of commits from the tip of each remote branch history35
TEST_TAG_PREFIXPrefix for test tagtest/
CLEAN_TEST_TAGWhether to clean test tagfalsetrue
ORIGINAL_TAG_PREFIXPrefix to add when leaving the original tagoriginal/
DELETE_NODE_MODULESWhether to delete node_modulesfalsetrue
GITHUB_TOKENAccess token${{github.token}}true${{secrets.ACCESS_TOKEN}}

Execute commands

Build

  • If package.json includes prepare, build, production, prod, package or pack in scripts, the commands are used for build. (You can change this with BUILD_COMMAND_TARGET)
  • If command does not have install command like npm run install or yarn install, install commands are added.

so if BUILD_COMMAND is not provided and package.json has build script, the following commands are executed for build.

yarn install
yarn build
yarn install --production

If build and pack are included, the commands are:

yarn install
yarn build
yarn pack
yarn install --production

Delete files

To execute GitHub Actions, src files used for build, test files, test settings, etc. are not required.
And GitHub Actions is downloaded every time when it is used, so fewer files are better.

CLEAN_TARGETS option is used for this purpose.
default: .[!.]*,__tests__,docs,src,*.[jt]s,*.[mc][jt]s,*.json,*.lock,*.yml,*.yaml

rm -rdf .[!.]*
rm -rdf *.js
rm -rdf *.mjs
rm -rdf *.ts
rm -rdf *.cts
rm -rdf *.json
rm -rdf *.lock
rm -rdf *.yml
rm -rdf *.yaml
rm -rdf __tests__ docs src

(action.yml is not subject to deletion.)

Action event details

Target events

eventName: actioncondition
push: *condition
release: publishedcondition
create: *condition

condition

  • tags
    • semantic versioning tag (e.g. v1.2.3)
    • test tag (e.g. test/v1.2.3)

Motivation

Releasing GitHub Actions needs all build files and dependencies like node_modules, but are not usually committed.
So if you want to release GitHub Actions, you have to do following steps.

  1. Develop locally on the branch for develop
  2. Build for release
  3. Commit all source code including dependencies like node_modules to branch for release
  4. Add tags (consider major, minor and patch versions)
  5. Push to GitHub
  6. Publish release

It is very troublesome to do this steps for every release.

If you use this GitHub Actions, the steps to do are simpler.

  1. Develop locally on the branch for develop
  2. Publish release (Create tag)
  3. Wait for the automated steps to finish
    1. Build for release
    2. Commit all source code including dependencies like node_modules to branch for release
    3. Add tags (consider major, minor and patch versions)
    4. Push to GitHub

Addition

Tags

Tag name format must be Semantic Versioning.
The following tags will be created.

  • tag name
  • major tag name (generated by tag name)
    • e.g. v1
  • minor tag name (generated by tag name)
    • e.g. v1.2
  • patch tag name (generated by tag name)
    • e.g. v1.2.3

Author

GitHub (Technote)
Blog

About

GitHub Actions to automate the release of GitHub Actions

Topics

Resources

Code of conduct

Contributing

Stars

82 stars

Watchers

1 watching

Forks

Releases

Sponsor this project

Packages

Used by

Contributors

Languages