chore(ENG-884): add semantic release into project (#9) #1
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
# Create a semantic release, including | |
# - a package.json version number | |
# - an updated change log file | |
# - a Github release, which will trigger a deployment | |
name: Create Github Release | |
# All changes to `main` have gone through | |
# automated checks and should have gone | |
# through code review and manual checks | |
# where appropriate. | |
on: | |
push: | |
branches: | |
- main | |
# This stops us getting into an infinite loop when a release commit | |
# is created on `main` containing the changes to CHANGE_LOG.md . | |
# The loop could happen because we use credentials from the machine | |
# user so that a commit to the protected `main` branch is possible | |
# (default workflow credentials can't trigger further workflows via | |
# events, to avoid this exact situation). | |
paths-ignore: | |
- "CHANGE_LOG.md" | |
- "sonar-project.properties" | |
jobs: | |
semantic_release: | |
name: semantic release | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
# Need this to prevent the custom Github credentials on | |
# the semantic release step being overridden with the | |
# default ones. | |
persist-credentials: false | |
- name: Use Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 20.x | |
cache: "npm" | |
# Install. | |
- run: npm ci | |
# Create Github release using semantic-release package. | |
# See config here release.config.js | |
# Note, this runs on `main` and creates the release tag. | |
# and updates the changelog file. | |
- name: do release | |
id: semantic_release | |
run: npx semantic-release | |
env: | |
GH_TOKEN: ${{ secrets.RELEASE_GITHUB_TOKEN }} | |
# Don't run pre-commit or commit message hooks on this commit | |
HUSKY: 0 | |
- name: Report to Slack on failure | |
if: ${{ steps.semantic_release.outcome == 'failure' }} | |
uses: rtCamp/action-slack-notify@v2 | |
env: | |
SLACK_COLOR: ${{ job.status }} # or a specific color like 'green' or '#ff00ff' | |
SLACK_MESSAGE: "Semantic Release status: ${{ job.status }}" | |
SLACK_TITLE: Semantic Release | |
SLACK_USERNAME: SemanticReleaseReporter | |
SLACK_WEBHOOK: ${{ secrets.OAK_GITHUB_NOTIFICATION_WEBHOOK }} |