We’ve been using a branching strategy (previously along with release-it) like this:
main
Our production branch, of course.release/DEV-123-branch-name
With our epics in Jira we’ve been creating an associatedrelease/*
branch. Any stories within those epics get afeature/*
branch which, when completed, gets merged to the epic’srelease/*
branch. Every time afeature/*
branch is merged into arelease/*
branch, we manually cut a new prerelease withrelease-it
. The target release version number is predetermined by us for eachrelease/*
branch.feature/DEV-456-branch-name
feature/*
branches is where all of the actual work happens. They are branched fromrelease/*
branches and merged back in via PR.
I’m trying to automate our release process with semantic-release and running into some issues. But I first want to ask, is this scenario even possible using semantic-release:
- Automatically release a prerelease from every branch that matches
release/*
. - If there are multiple
release/*
branches, have each be aware of the prerelease versions in the otherrelease/*
branches and set target release version accordingly.
Can semantic-release pull something like this off? Can it manage multiple pre-releases in multiple matching branches?
This is my release.config.js
file as it stands now:
/* eslint-disable no-template-curly-in-string */
module.exports = {
branches: [
'main',
// version number branches will release that version
'+([0-9])?(.{+([0-9]),x}).x',
{
channel: 'alpha',
name: 'alpha/*',
prerelease: true,
},
],
plugins: [
'@semantic-release/commit-analyzer',
'@semantic-release/release-notes-generator',
'@semantic-release/npm',
'@semantic-release/github',
[
'@semantic-release/git', {
assets: [
'CHANGELOG.md',
'README.md',
'dist',
'package.json',
'yarn.lock',
],
message: 'chore(release): ${lastRelease.version}→${nextRelease.version} [skip ci]\n\n${nextRelease.notes}',
},
],
[
'semantic-release-slack-bot',
{
branchesConfig: [
{
notifyOnFail: true,
notifyOnSuccess: true,
pattern: 'main',
},
{
notifyOnFail: true,
notifyOnSuccess: true,
pattern: 'alpha/*',
},
],
notifyOnFail: false,
notifyOnSuccess: false,
},
],
],
};
… and my GitHub workflow file:
name: Release
on:
push:
branches:
- main
- 'alpha/**'
jobs:
release:
name: Release
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0
persist-credentials: false
- name: Setup Node.js
uses: actions/setup-node@v2
with:
node-version: 14.17.x
- name: Install dependencies
run: yarn install --frozen-lockfile
- name: Release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
run: npx semantic-release
That config is resulting in the following errors when the action runs:
2022-05-26T20:12:24.2348523Z [8:12:24 PM] [semantic-release] › ✖ EPRERELEASEBRANCH A pre-release branch configuration is invalid in the `branches` configuration.
2022-05-26T20:12:24.3094679Z Each pre-release branch in the branches configuration (https://github.com/semantic-release/semantic-release/blob/master/docs/usage/configuration.md#branches) must have a prerelease property valid per the Semantic Versioning Specification (https://semver.org/#spec-item-9). If the prerelease property is set to true, then the name property is used instead.
2022-05-26T20:12:24.3095492Z
2022-05-26T20:12:24.3097305Z Your configuration for the problematic branch is { name: 'alpha/DEV-333-cl-implement-semantic-release-for-automating-releases-and-prereleases', channel: 'alpha', prerelease: true, tags: [ { gitTag: 'v0.1.1', version: '0.1.1', channels: [Array] }, { gitTag: 'v0.2.0', version: '0.2.0', channels: [Array] }, { gitTag: 'v0.3.0', version: '0.3.0', channels: [Array] }, { gitTag: 'v0.3.1', version: '0.3.1', channels: [Array] }, { gitTag: 'v0.4.0', version: '0.4.0', channels: [Array] }, ... 29 more items ] }.
This is for a component-library. Our reasoning for multiple pre-release branches is so that the app that uses this package can point to pre-release versions of our package to start incorporating those changes in the app before an official production release is done in our component-library.