Skip to content
README.md 2.82 KiB
Newer Older
# @semantic-release/config-release-channels
Matthew Clarkson's avatar
Matthew Clarkson committed

> [**semantic-release**](https://github.com/semantic-release/semantic-release)
> config to setup `alpha`, `beta` and `stable` release channels.
Matthew Clarkson's avatar
Matthew Clarkson committed

## Getting Started
Matthew Clarkson's avatar
Matthew Clarkson committed

Add the following to `.releaserc.yaml`:
Matthew Clarkson's avatar
Matthew Clarkson committed

```yaml
extends:
  - "@semantic-release/config-release-channels"
Matthew Clarkson's avatar
Matthew Clarkson committed
```

Combine that with one of the @semantic-release / `config-gitlab-*` projects:
Matthew Clarkson's avatar
Matthew Clarkson committed

```yaml
extends:
  - "@semantic-release/config-release-channels"
  - "@semantic-release/config-gitlab-poetry"
Matthew Clarkson's avatar
Matthew Clarkson committed

Add the following to `.gitlab-ci.yml`:

```yaml
include:
  - project: "ci/templates"
    ref: v1.6.1
    file:
      - "/.templates.yml"

semantic-release:
  extends: .semantic-release
```

## Configuration

### Branches

Create the `alpha`, `beta` and `stable` branches to the root commit:

```sh
for BRANCH in alpha beta stable; do
  git checkout -b $BRANCH $(git rev-list --max-parents=0 HEAD)
  git push -u origin $BRANCH
done
```

### Protect

#### Branches

Protecting the release branches enables protected CI variables to be allowed in the `semantic-release` jobs.

For each release branch [protect][protect-branch] the branch.

Recommended protections are for _no-one_ to be able to merge and for only maintainers to _merge_.

#### Tags

`semantic-release` will create version tags.

It is sensible to protect the version tags against accidental deletion.

Create the `v*` wildcard [protection][protect-tag].

## Usage
Matthew Clarkson's avatar
Matthew Clarkson committed

All work happens on `main`. When a release needs to be made, a merge can be made
to `alpha`:
Matthew Clarkson's avatar
Matthew Clarkson committed

    # We will do an 'alpha' release first
    git checkout alpha
Matthew Clarkson's avatar
Matthew Clarkson committed

    # Pull in all the changes for the release
    git merge --no-ff main
Matthew Clarkson's avatar
Matthew Clarkson committed

    # Push up the 'alpha' branch for release on the CI
    git push
Matthew Clarkson's avatar
Matthew Clarkson committed

`semantic-release` will automatically pick up the changes on the `alpha` branch
and create a new `N.N.N-alpha.X` release.
Matthew Clarkson's avatar
Matthew Clarkson committed

We can make multiple `alpha` releases, until we are comfortable we want to
promote the changes to `beta`. The same process is followed:
Matthew Clarkson's avatar
Matthew Clarkson committed

    # Move 'alpha' changes to 'beta'
    git checkout beta
    git merge --no-ff main
    git push
Matthew Clarkson's avatar
Matthew Clarkson committed

This will result in a `N.N.N-beta.N` release.
Matthew Clarkson's avatar
Matthew Clarkson committed

Finally, when we are happy with the stability of the `beta` channel we can
promote to `stable`:
Matthew Clarkson's avatar
Matthew Clarkson committed

    # Move 'beta' changes to 'stable'
    git checkout stable
    git merge --no-ff main
    git push
Matthew Clarkson's avatar
Matthew Clarkson committed

This will create the final `N.N.N` release for the changes. The final release
can be merged back to the prerelease branches so that subsequent prereleases are
for the _next_ major version:
Matthew Clarkson's avatar
Matthew Clarkson committed

    # Apply stable release back to the prerelease channels
    git checkout alpha
    git merge --no-ff vN.N.N
    git push
    git checkout beta
    git merge --no-ff vN.N.N
    git push

[protect-branch]: https://docs.gitlab.com/ee/user/project/protected_branches.html
[protect-tag]: https://docs.gitlab.com/ee/user/project/protected_tags.html