Skip to content

Web Release

Web Release #55

Workflow file for this run

name: Web Release
on:
push:
branches:
- main
workflow_dispatch: # Allow manual triggering of this job in case of failures
inputs:
version:
default: 'patch'
description:
'The version override: patch, minor or major'
required: false
jobs:
release:
# Only run if:
# - The commit message does not contain `[skip release]`
# - OR the workflow was manually triggered and has a `version` string
if: "(!contains(github.event.head_commit.message, '[skip release]') && (contains(github.event.head_commit.message, '(web)') || contains(github.event.head_commit.message, '(all)'))) || inputs.version"
runs-on: ubuntu-latest
steps:
## First, we'll checkout the repository. We don't persist credentials because we need a
## Personal Access Token to push on a branch that is protected. See
## https://github.com/cycjimmy/semantic-release-action#basic-usage
- uses: actions/checkout@v4
with:
persist-credentials: false
fetch-depth: 0 # Used for conventional commit ranges
- uses: Workday/canvas-kit-actions/install@v1
with:
node_version: 18.x
- name: Config git user
shell: bash
run: |
git config --global user.name "${{ github.actor }}"
git config --global user.email "${{ github.actor }}@users.noreply.github.com"
- name: Get previous tag
id: previous-tag
run:
echo "tag=$(node -p 'require("./packages/canvas-tokens-web/package.json").version')" >> $GITHUB_OUTPUT
- name: Generate Changeset
uses: Workday/canvas-kit-actions/generate-changeset@v1
id: changeset
with:
token: ${{ secrets.GITHUB_TOKEN }}
fromRef: '@workday/canvas-tokens-web@${{steps.previous-tag.outputs.tag}}'
toRef: 'main'
tagName: 'new-release'
- name: Filter changes
id: filter-changes
run: echo "changelog=$(node scripts/utils/filter-changes.js)" >> $GITHUB_OUTPUT
env:
PACKAGE: web
CHANGESET_BODY: ${{steps.changeset.outputs.body}}
- name: Create pre-changelog for versioning
run: npx ts-node scripts/utils/create-prechangelog.ts
env:
PACKAGE: web
VERSION: ${{inputs.version}}
CHANGESET_BODY: ${{steps.filter-changes.outputs.changelog}}
- name: Bump package
run: npx changeset version
- name: Get release tag
id: new-tag
run:
echo "tag=$(node -p 'require("./packages/canvas-tokens-web/package.json").version')" >> $GITHUB_OUTPUT
## So far, the changes to to the workspace have not been committed. We'll commit them now and
## create a tag
- name: Commit and add Tag
shell: bash
run: |
git add . && git commit -m "chore: Release @workday/canvas-tokens-web v${{steps.new-tag.outputs.tag}} [skip release]" && git tag -a @workday/canvas-tokens-web@${{steps.new-tag.outputs.tag}} -m "@workday/canvas-tokens-web@${{steps.new-tag.outputs.tag}}"
- name: See git log
run: |
git log --no-walk --tags --oneline -n 1
# Push both the commit and tag created by changeset version command using a PAT
- name: Push changes
uses: ad-m/github-push-action@master
with:
github_token: ${{ secrets.GH_RW_TOKEN }}
branch: "main"
# Don't push tags here because Changeset pushes them in the Build & Publish step
tags: false
# Create a release on Github.
- name: Create GH Release
uses: softprops/action-gh-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: "@workday/canvas-tokens-web@${{steps.new-tag.outputs.tag}}"
name: "@workday/canvas-tokens-web@${{steps.new-tag.outputs.tag}}"
body: ${{steps.filter-changes.outputs.changelog}}
draft: false
prerelease: false
# publish:
- name: Build & Publish
id: changesets
uses: changesets/action@v1
with:
# This expects you to have a script called release which does a build for your packages and calls changeset publish
publish: yarn release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_CI_PUBLISH_TOKEN }}
NODE_AUTH_TOKEN: ${{ secrets.NPM_CI_PUBLISH_TOKEN }}