-
Notifications
You must be signed in to change notification settings - Fork 6
60 lines (51 loc) · 2.07 KB
/
publish.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# Name of the visible action in the workflow overview
name: Publish
on:
# Pushes to canary or next branches
push:
branches: [221-targeted-response]
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
pull_request:
types: [closed]
branches:
- main
- development
jobs:
publish:
runs-on: ubuntu-latest
# run the job if the PR was merged or the branch is 221-targeted-response
if: github.event.pull_request.merged == true || github.ref == 'refs/heads/221-targeted-response'
steps:
- name: Checkout
uses: actions/checkout@v3
with:
# We need to fetch all commits so Lerna is able to properly determine the changed packages
fetch-depth: 0
- name: Use Node and set it up for publishing
uses: actions/setup-node@v3
with:
node-version: '16.20.1'
cache: 'npm'
# Setup .npmrc file to publish to GitHub Packages
registry-url: 'https://npm.pkg.github.com'
scope: '@compassion-design-system'
- name: Install and link dependencies
run: npm ci
- name: 'Version & Publish'
env:
# Reassign the variable from the workflow runner to the one used by Lerna
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# Set commit author to the GitHub Actions bot
# Trigger a canary release if the branch is 221-targeted-response or development (released on a separate dist channel)
# Otherwise (main branch) trigger a normal release (promoting any pre-releases to regular versions)
run: |
git config user.name "${{ github.actor }}"
git config user.email "${{ github.actor}}@users.noreply.github.com"
DIST_TAG=${{ github.base_ref }}
CREATE_RELEASE=""
if [ ${{ github.base_ref }} == main ]; then
npx lerna publish from-package --conventional-commits --create-release github --yes
else
npx lerna publish from-package --conventional-commits --dist-tag=${{ github.base_ref }} --yes
fi