From f5bb190762f710e1667bb01d818355df53e486c1 Mon Sep 17 00:00:00 2001 From: Maria Duenas Date: Mon, 12 Jun 2023 13:53:54 +0200 Subject: [PATCH] ci: improve publish to use tags based on branch --- .github/workflows/release.yml | 2 +- ADRs/003_Release_strategy.md | 17 +++++++++++------ package.json | 1 - release.config.js | 2 +- scripts/publish.sh | 12 ++++++++++++ 5 files changed, 25 insertions(+), 9 deletions(-) create mode 100755 scripts/publish.sh diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 53fc4772..0d5764b6 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -19,7 +19,7 @@ jobs: publish_packages: name: Publish Packages needs: [ validations ] - if: github.ref == 'refs/heads/main' || github.ref == 'refs/heads/next' || github.ref == 'refs/heads/beta' + if: github.ref == 'refs/heads/main' || github.ref == 'refs/heads/beta' uses: ./.github/workflows/publish.yml with: node_version: 16 diff --git a/ADRs/003_Release_strategy.md b/ADRs/003_Release_strategy.md index ab4b5a3b..af70b5ad 100644 --- a/ADRs/003_Release_strategy.md +++ b/ADRs/003_Release_strategy.md @@ -4,6 +4,8 @@ Date: 28.03.2022 +Updated: 12.06.2023 + ### Status accepted @@ -39,13 +41,16 @@ In the file release.config.js we can configure semantic-release to do the follow 5. Publish on our GitHub repo the [release notes](https://github.com/otto-ec/b2b-design-system/releases) (@semantic-release/github) -### Development Options +### Release types + +As we have released a stable version of the library, our release strategy works as follows: + +- Any releases run from branch `main` will publish a stable version of the npm package with format `vx.x.x` and tag + `latest`. +- Any releases run from `beta` will publish a pre-release version of the npm package with format `vx.x.x-beta.n` and + tag `beta`. Where `n` will increase for any new beta release on that `x` version. -1. Until we reach base maturity in our product, we will release to branch beta, which will create releases in the - format `x.x.x-beta`. Once we have priority 1 components ready, we can merge beta to main and then just continue - with normal feature branches -2. Not using `beta` branch. We run the risk reaching early big release numbers as we could potentially be - making many breaking changes. +- Beta can be merged into `main` once this pre-release has been tested and approved. Then a new Release should be triggered from `main` to publish a stable release. ## Decision We are using a GitHub workflow `release.yml` that is triggered manually from GH Actions ui, by choosing from diff --git a/package.json b/package.json index 309d5725..86f7bfa9 100644 --- a/package.json +++ b/package.json @@ -14,7 +14,6 @@ "homepage": "https://github.com/otto-de/b2b-design-system#readme", "scripts": { "deploy": "npm run deploy --workspace=@otto-de/b2b-core-components", - "publish": "npm publish --workspace packages/", "release": "semantic-release", "build-tokens": "npm run build --workspace=@otto-de/b2b-tokens", "build-core-components": "npm run build --workspace=@otto-de/b2b-core-components", diff --git a/release.config.js b/release.config.js index 820e495f..9e65d6b2 100644 --- a/release.config.js +++ b/release.config.js @@ -21,7 +21,7 @@ module.exports = { [ '@semantic-release/exec', { - "publishCmd": "npm run publish -- --tag=${branch.name}", + "publishCmd": "node ./scripts/publish.sh ${branch.name}", } ], [ diff --git a/scripts/publish.sh b/scripts/publish.sh new file mode 100755 index 00000000..cebdd98a --- /dev/null +++ b/scripts/publish.sh @@ -0,0 +1,12 @@ +#! /usr/bin/env bash + +branch="${1}" + +tag=$branch +if [[ $branch = 'main' ]] || [[ ! -n $branch ]]; +then + tag="latest" +fi + +echo publishing on tag ${tag} +npm publish --workspace packages/ --tag=$tag