Skip to content

Commit

Permalink
ci: use semantic-release
Browse files Browse the repository at this point in the history
  • Loading branch information
cwillisf committed Dec 21, 2023
1 parent bbafc30 commit dca7446
Show file tree
Hide file tree
Showing 4 changed files with 23,295 additions and 13,124 deletions.
42 changes: 6 additions & 36 deletions .github/workflows/ci-cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@ name: CI/CD

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

concurrency:
group: "${{ github.workflow }} @ ${{ github.event.pull_request.head.label || github.head_ref || github.ref }}"
Expand Down Expand Up @@ -40,42 +38,14 @@ jobs:
GitHub head ref: ${{ github.head_ref }}
EOF
- name: Setup & Test
run: |
npm ci
npm run test
- run: npm ci

- name: Generate release version
run: |
export NODE_ENV=production
export RELEASE_TIMESTAMP=$(date +'%Y%m%d%H%M%S')
export VPKG=$($(npm bin)/json -f package.json version)
export VERSION=${VPKG}-prerelease.${RELEASE_TIMESTAMP}
echo "RELEASE_VERSION=${VERSION}" >> $GITHUB_ENV
if [[ "${GITHUB_REF##*/}" == hotfix/* ]]; then
echo "NPM_TAG=hotfix" >> $GITHUB_ENV
else
echo "NPM_TAG=latest" >> $GITHUB_ENV
fi
- run: npm test

- name: Build
run: |
npm run build
npm --no-git-tag-version version $RELEASE_VERSION
- run: npm run build

- name: Deploy to NPM (do a dry-run if not on master, develop, or hotfix/*)
- name: Run semantic-release
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
NPM_TAG: ${{ env.NPM_TAG }}
run: |
message=$([[ "$TRIGGER_DEPLOY" == "false" ]] && echo "DRY RUN of" || echo "Deploying")
echo "$message version $RELEASE_VERSION to $NPM_TAG"
npm set //registry.npmjs.org/:_authToken=$NPM_TOKEN
npm publish --tag $NPM_TAG $([[ "$TRIGGER_DEPLOY" == "false" ]] && echo "--dry-run")
- name: Check Release Version and Create Tag
run: |
if npm info | grep -q $RELEASE_VERSION; then
git tag $RELEASE_VERSION
git push origin $RELEASE_VERSION
fi
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: npx --no -- semantic-release
Loading

0 comments on commit dca7446

Please sign in to comment.