Added semantic-release

This commit is contained in:
Erik Tiekstra
2021-05-18 09:43:06 +02:00
parent a0039e7e0e
commit e1634dc221
4 changed files with 9230 additions and 0 deletions

80
.releaserc Normal file
View File

@@ -0,0 +1,80 @@
{
"repositoryUrl": "ssh://git@bitbucket.arbetsformedlingen.se:7999/tea/dafa-web-monorepo.git",
"plugins": [
[
"@semantic-release/commit-analyzer",
{
"preset": "angular",
"releaseRules": [
{
"type": "docs",
"scope": "README",
"release": "patch"
},
{
"type": "refactor",
"release": "patch"
},
{
"type": "style",
"release": "patch"
}
],
"parserOpts": {
"noteKeywords": [
"BREAKING CHANGE",
"BREAKING CHANGES",
"BREAKING",
"BREAK"
]
}
}
],
[
"@semantic-release/release-notes-generator",
{
"preset": "conventionalcommits",
"parserOpts": {
"noteKeywords": [
"BREAKING CHANGE",
"BREAKING CHANGES",
"BREAKING",
"BREAK"
]
},
"writerOpts": {
"commitsSort": [
"subject",
"scope"
]
},
"presetConfig": {
"commitUrlFormat": "{{host}}/projects/{{owner}}/repos/{{repository}}/commits/{{hash}}",
"compareUrlFormat": "{{host}}/projects/{{owner}}/repos/{{repository}}/compare/diff?targetBranch=refs%2Ftags%2F{{previousTag}}&sourceBranch=refs%2Ftags%2F{{currentTag}}",
"issueUrlFormat": "https://jira.arbetsformedlingen.se/browse/TV-{{id}}",
"issuePrefixes": [
"TV-"
]
}
}
],
"@semantic-release/changelog",
"@semantic-release/npm",
[
"@semantic-release/git",
{
"assets": [
"package.json",
"package-lock.json",
"CHANGELOG.md"
],
"message": "chore(release): ${nextRelease.version} [skip ci]\n\n${nextRelease.notes}"
}
]
],
"branches": [
{
"name": "develop"
}
]
}

9068
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -18,6 +18,8 @@
"build:pega": "ng build dafa-web --configuration pega", "build:pega": "ng build dafa-web --configuration pega",
"test": "ng test", "test": "ng test",
"test:dafa": "ng test dafa-web", "test:dafa": "ng test dafa-web",
"release": "bash ./tools/release.sh",
"release:dry": "bash ./tools/release.sh dry",
"lint": "nx workspace-lint && ng lint", "lint": "nx workspace-lint && ng lint",
"e2e": "ng e2e", "e2e": "ng e2e",
"e2e:dafa": "ng e2e dafa-web", "e2e:dafa": "ng e2e dafa-web",
@@ -87,6 +89,7 @@
"jest": "26.2.2", "jest": "26.2.2",
"jest-preset-angular": "8.3.2", "jest-preset-angular": "8.3.2",
"prettier": "2.2.1", "prettier": "2.2.1",
"semantic-release": "^17.4.3",
"ts-jest": "26.4.0", "ts-jest": "26.4.0",
"ts-node": "~9.1.1", "ts-node": "~9.1.1",
"typescript": "~4.0.3" "typescript": "~4.0.3"

79
tools/release.sh Normal file
View File

@@ -0,0 +1,79 @@
#!/bin/bash
#
# Script to create a new release using semantic-release
# ----------------------------------
# COLORS
# ----------------------------------
NOCOLOR='\033[0m'
RED='\033[0;31m'
GREEN='\033[0;32m'
ORANGE='\033[0;33m'
CYAN='\033[0;36m'
YELLOW='\033[1;33m'
# ----------------------------------
# CHECKING IF BRANCH IS UP-TO-DATE
# ----------------------------------
BRANCH=$(git rev-parse --abbrev-ref HEAD)
if [[ $BRANCH != "develop" ]]; then
echo -e "${RED}Aborting script - you need to be in branch develop${NOCOLOR}";
exit 1;
fi
if [[ `git status --porcelain` ]]; then
echo -e "${RED}Aborting script - make sure you have committed and pushed everything to Git${NOCOLOR}";
exit 1;
fi
# ----------------------------------
# EXIT WHEN ANY COMMAND FAILS
# ----------------------------------
set -e
function exitMessage()
{
if [ $? -ne 0 ]; then
echo -e "${RED}\"${last_command}\" command filed with exit code $?.${NOCOLOR}"
fi
}
# keep track of the last executed command
trap 'last_command=$current_command; current_command=$BASH_COMMAND' DEBUG
# echo an error message before exiting
trap exitMessage EXIT
# ----------------------------------
# E2E TESTS
# ----------------------------------
echo -e "${CYAN}Running e2e tests using Cypress${NOCOLOR}"
npm run test
echo -e "${GREEN}Tests finished${NOCOLOR}"
# ----------------------------------
# SEMANTIC RELEASE
# ----------------------------------
if [ $1 == "dry" ]; then
echo -e "${CYAN}Dry running Semantic Release${NOCOLOR}"
npx semantic-release --no-ci --debug --dry-run -b develop
echo -e "${GREEN}Dry run of Semantic Release complete${NOCOLOR}"
exit
else
echo -e "${CYAN}Running Semantic Release${NOCOLOR}"
npx semantic-release --no-ci --debug -b develop
echo -e "${GREEN}Semantic Release complete${NOCOLOR}"
fi
# ----------------------------------
# UPDATING GIT REPOSITORIES
# ----------------------------------
echo -e "${CYAN}Updating git repository${NOCOLOR}"
git push
git checkout next
git pull
git merge develop
git push
git checkout develop
echo -e "${GREEN}Git repository updated!${NOCOLOR}"
echo -e "${GREEN}Release is complete!${NOCOLOR}"