Skip to content

Commit cb7098c

Browse files
committed
ci: use semantic-release
1 parent def2c92 commit cb7098c

File tree

4 files changed

+28091
-18238
lines changed

4 files changed

+28091
-18238
lines changed

.github/workflows/ci-cd.yml

+6-32
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,7 @@ name: CI/CD
22

33
on:
44
workflow_dispatch: # Allows you to run this workflow manually from the Actions tab
5-
pull_request: # Runs whenever a pull request is created or updated
65
push: # Runs whenever a commit is pushed to the repository
7-
branches: [master, develop, hotfix/*]
86

97
concurrency:
108
group: "${{ github.workflow }} @ ${{ github.event.pull_request.head.label || github.head_ref || github.ref }}"
@@ -50,38 +48,14 @@ jobs:
5048
mkdir -p ./test/results
5149
npm test
5250
53-
- name: Generate release version
54-
run: |
55-
export RELEASE_TIMESTAMP=$(date +'%Y%m%d%H%M%S')
56-
export VPKG=$($(npm bin)/json -f package.json version)
57-
export VERSION=${VPKG}-prerelease.${RELEASE_TIMESTAMP}
58-
59-
echo "RELEASE_VERSION=${VERSION}" >> $GITHUB_ENV
60-
61-
if [[ "${GITHUB_REF##*/}" == hotfix/* ]]; then
62-
echo "NPM_TAG=hotfix" >> $GITHUB_ENV
63-
else
64-
echo "NPM_TAG=latest" >> $GITHUB_ENV
65-
fi
51+
- run: npm run build
6652

67-
- name: Build
68-
run: |
69-
npm run build
70-
npm --no-git-tag-version version $RELEASE_VERSION
71-
72-
- name: Deploy to NPM (do a dry-run if not on master, develop, or hotfix/*)
53+
- name: Run semantic-release
7354
env:
7455
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
75-
NPM_TAG: ${{ env.NPM_TAG }}
76-
run: |
77-
message=$([[ "$TRIGGER_DEPLOY" == "false" ]] && echo "DRY RUN of" || echo "Deploying")
78-
echo "$message version $RELEASE_VERSION to $NPM_TAG"
79-
npm set //registry.npmjs.org/:_authToken=$NPM_TOKEN
80-
npm publish --tag $NPM_TAG $([[ "$TRIGGER_DEPLOY" == "false" ]] && echo "--dry-run")
81-
82-
- name: Check Release Version and Create Tag
56+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
8357
run: |
84-
if npm info | grep -q $RELEASE_VERSION; then
85-
git tag $RELEASE_VERSION
86-
git push origin $RELEASE_VERSION
58+
if [[ ${{contains(github.ref, 'hotfix/')}} ]]; then
59+
sed -e "s|hotfix/REPLACE|${{ github.ref_name }}|" --in-place release.config.js
8760
fi
61+
npx --no -- semantic-release

0 commit comments

Comments
 (0)