levibostian / action-promote-semantic-release

GitHub Action to promote your code to your next release. Promote develop to alpha, alpha to beta, beta to prod, etc.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

GitHub release (latest SemVer) GitHub release (latest SemVer including pre-releases)

action-promote-semantic-release

GitHub Action to promote your code to your next release. Promote develop to alpha, alpha to beta, beta to prod, etc.

This Action is designed to work well with semantic-release where this Action will manage and push code to branches on your repository. This project does not perform any deployments on it's own. Once this Action pushes code to a branch, semantic-release can then be executed on that branch to then make a deployment.

Getting started

Let's say that your project uses the develop branch as the default branch where code gets merged in. From this branch, you make Alpha, Beta and Production releases of your software.

That means that the sequence of releases that you make it:

develop --> alpha --> beta --> production

Once you know the sequence that your project follows for releases, the rest is easy!

name: Promote releases

on: 
  workflow_dispatch: # manually run this Action so you decide when deployments happen

jobs:
  promote-release:
    name: Promote a branch to the next release 
    runs-on: ubuntu-latest # Action is tested with Linux and it's recommended to use Linux. 
    steps:
      - name: Promote release 
        uses: levibostian/action-promote-semantic-release@v1
        with:
          sequence: "develop,alpha,beta,main"
          githubToken: ${{ secrets.BOT_PUSH_TOKEN }}
          gitName: "Deploy bot"
          gitEmail: "deploy@yourcompany.com"

The action comes with the following inputs:

  • sequence (required) - comma separated string containing the sequence of your releases that you follow for your project. Each item in the sequence is the name of a branch that you use in your project.
  • githubToken (required) - a GitHub personal access token for a GitHub account that has push access to the repository. This Action pushes code to branches of your repository.
  • promoteToBranch (optional) - By default, Action will promote existing branch to next branch in sequence. If you want to instead jump directly to a different branch in the sequence, enter it here.
  • gitName (optional) - In case a merge commit needs to be made, what git name should be used for the merge commit? Note: If this is not provided and a merge commit is attempted to be made, the promote script will fail.
  • gitEmail (optional) - In case a merge commit needs to be made, what git email address should be used for the merge commit? Note: If this is not provided and a merge commit is attempted to be made, the promote script will fail.

How does this Action work?

The tool semantic-release is awesome. Create branches and it will take care of the rest.

This is the flow of how the workflow operates:

Development

This action is a composite GitHub Action mostly relying on bash scripts to run commands. This means there is nothing for you to install to create a development environment on your computer. However, this also means that testing the action is more difficult. To test this action, we rely on running the action on GitHub Actions. See .github/workflows/test-action.yml for an example of how we test this action.

All changes made to the code require making a pull request into develop branch with the title conforming to the conventional commit format.

Before pushing code, it would be nice if you would lint it. npm i -g xo && xo --fix will do the trick.

Deployment

Tags/releases are made automatically using semantic-release as long as our git commit messages are written in the conventional commit format. Just git rebase ... or git merge commits from develop into alpha, beta, or main to make a new deployment of the action.

About

GitHub Action to promote your code to your next release. Promote develop to alpha, alpha to beta, beta to prod, etc.

License:MIT License


Languages

Language:JavaScript 100.0%