-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(lerna): aggressive patch bump (#1163)
* fix(lerna): aggressive patch bump * fix(lerna): aggressive patch bump keeping constant version * fix(lerna): aggressive patch bump keeping constant version * fix(lerna): unpredictable master branch versioning * chore(fix): switch to patch from conventional commit * chore(doc): update the docs * chore(contribution.md): fix documentation * fix(release): add custom script to remove rc tag * fix(scripts): lint errors * fix(scripts): lint errors * fix(scripts): lint errors * fix(scripts): lint errors * fix(scripts): lint errors * feat(release): add rc tag removal script run * fix(versioning): modify rc tag removing script and release.yaml * fix(linting): modify rc tag removing script * fix(contributing): add the mistakenly removed doc * fix(contributing): add the mistakenly removed doc
- Loading branch information
1 parent
e18a440
commit df9fa83
Showing
4 changed files
with
87 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,16 +31,18 @@ jobs: | |
run: yarn build | ||
|
||
publish: | ||
if: |- | ||
${{ | ||
!contains(github.event.commits[0].message, '[skip-ci]') && | ||
( | ||
startsWith(github.event.commits[0].message, 'fix:') || | ||
startsWith(github.event.commits[0].message, 'fix(') || | ||
startsWith(github.event.commits[0].message, 'feat:') || | ||
startsWith(github.event.commits[0].message, 'feat(') || | ||
contains(github.event.commits[0].message, '[release]') | ||
if: ${{ !contains(github.event.head_commit.message, '[skip-ci]') && | ||
( | ||
(github.ref == 'refs/heads/master' && contains(github.event.head_commit.message, '[release]')) || | ||
(startsWith(github.ref, 'refs/heads/release-') && | ||
(startsWith(github.event.head_commit.message, 'fix:') || | ||
startsWith(github.event.head_commit.message, 'fix(') || | ||
startsWith(github.event.head_commit.message, 'feat:') || | ||
startsWith(github.event.head_commit.message, 'feat(') || | ||
contains(github.event.head_commit.message, '[release]') | ||
) | ||
) | ||
) | ||
}} | ||
runs-on: ubuntu-latest | ||
environment: CD | ||
|
@@ -81,17 +83,51 @@ jobs: | |
- name: Build doc | ||
run: yarn docs:bundle | ||
|
||
# Remove rc tag in master branch when it is a [release] commit | ||
- name: Remove RC tags | ||
if: ${{ github.ref == 'refs/heads/master' && contains(github.event.head_commit.message, 'Merge pull request') && contains(github.event.head_commit.message, 'release-') && contains(github.event.head_commit.message, '[release]') }} | ||
run: | | ||
node scripts/remove-rc-tags.js | ||
git config --global user.email "[email protected]" | ||
git config --global user.name "Cognite CICD" | ||
git add packages/*/package.json | ||
git commit -m "chore: remove rc tags [skip-ci]" | ||
git push origin master | ||
- name: Lerna version | ||
env: | ||
GH_TOKEN: ${{ secrets.GH_LERNA_TOKEN }} # Temporary fix to make lerna able to push the new versions commit to master | ||
GITHUB_TOKEN: ${{ secrets.GH_LERNA_TOKEN }} # Temporary fix to make lerna able to push the new versions commit to master | ||
run: yarn lerna version --conventional-commits --conventional-prerelease --preid rc --create-release github --no-private --yes | ||
run: | | ||
if [[ "${GITHUB_REF}" == "refs/heads/master" ]]; then | ||
EVENT_PATH_CONTENT=$(cat ${GITHUB_EVENT_PATH} | jq -r '.') | ||
HEAD_COMMIT_MSG=$(echo $EVENT_PATH_CONTENT | jq -r '.head_commit.message') | ||
MERGE_COMMIT_MSG=$(echo $EVENT_PATH_CONTENT | jq -r '.commits[-1].message') | ||
if [[ "$HEAD_COMMIT_MSG" == *"Merge"* && "$HEAD_COMMIT_MSG" == *"release-"* && "$HEAD_COMMIT_MSG" == *"[release]"* ]] || | ||
[[ "$MERGE_COMMIT_MSG" == *"Merge"* && "$MERGE_COMMIT_MSG" == *"release-"* && "$MERGE_COMMIT_MSG" == *"[release]"* ]]; then | ||
echo "Running major version bump for release merge" | ||
yarn lerna version major --conventional-commits --create-release github --no-private --yes --force-publish | ||
else | ||
echo "Running conventional commit versioning on master" | ||
yarn lerna version --conventional-commits --create-release github --no-private --yes | ||
fi | ||
elif [[ "${GITHUB_REF}" == refs/heads/release-* ]]; then | ||
echo "Running pre-release versioning on release branch" | ||
yarn lerna version --conventional-commits --conventional-prerelease --preid rc --create-release github --no-private --yes | ||
fi | ||
- name: Lerna Publish | ||
if: contains(github.event.head_commit.message, '[release]') | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
NPM_TOKEN: ${{ secrets.NPM_PUBLISH_TOKEN }} | ||
run: yarn lerna publish from-package --pre-dist-tag rc --yes --no-git-reset --no-verify-access | ||
run: | | ||
if [[ "${GITHUB_REF}" == "refs/heads/master" ]]; then | ||
yarn lerna publish from-package --yes --no-git-reset --no-verify-access | ||
elif [[ "${GITHUB_REF}" == refs/heads/release-* ]]; then | ||
yarn lerna publish from-package --pre-dist-tag rc --yes --no-git-reset --no-verify-access | ||
fi | ||
# - name: Publish documentation | ||
# uses: JamesIves/github-pages-deploy-action@releases/v3 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
// Remove -rc tag from release branch when it merge to master | ||
const fs = require('node:fs'); | ||
const glob = require('glob'); | ||
|
||
// Retrive all pacakage.json file paths | ||
const packageFilesPaths = glob.sync('packages/*/package.json'); | ||
|
||
// loop through each and remove rc tag | ||
for (const packageFilePath of packageFilesPaths) { | ||
//get the package content to json file | ||
const packageJson = JSON.parse(fs.readFileSync(packageFilePath, 'utf-8')); | ||
|
||
// check for rc, remove it, reassign the version and rewrite | ||
if (packageJson.version?.includes('-rc')) { | ||
// 6.0.0-rc.1 --> [6.0.0, -rc.1] | ||
// 5.0.0 which then convert to 6.0.0 by release.yaml | ||
majorVersion = Number.parseInt(packageJson.version.split('-rc')[0]) - 1; | ||
packageJson.version = `${majorVersion}.0.0`; | ||
fs.writeFileSync( | ||
packageFilePath, | ||
`${JSON.stringify(packageJson, null, 2)}\n` | ||
); | ||
} | ||
} |