-
Notifications
You must be signed in to change notification settings - Fork 4
99 lines (93 loc) · 3.04 KB
/
release-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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
name: publish release
env:
CI: true
PNPM_CACHE_FOLDER: .pnpm-store
# only trigger on pull request closed events
on:
pull_request:
types: [closed]
branches: [master]
jobs:
test:
if: github.event.pull_request.merged == true
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: ./.github/actions/install
- run: pnpm run lint
- run: pnpm run test
env:
NODE_OPTIONS: --max-old-space-size=8192
build:
if: github.event.pull_request.merged == true
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: ./.github/actions/install
- run: pnpm run build-storybook
- name: Archive screenshots
if: ${{ failure() }}
uses: actions/upload-artifact@v1
with:
name: loki-screenshots
path: packages/ui/.loki
chromatic-deployment:
if: github.event.pull_request.merged == true
runs-on: ubuntu-latest
needs: [test, build]
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- uses: ./.github/actions/install
- name: Publish to Chromatic
uses: chromaui/action@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
projectToken: ${{ secrets.CHROMATIC_PROJECT_TOKEN }}
exitZeroOnChanges: true
workingDir: packages/ui
autoAcceptChanges: true
publish_canary:
if: github.event.pull_request.merged == true && !startsWith(github.head_ref, 'release/v')
runs-on: ubuntu-latest
needs: [test, build]
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: ./.github/actions/install
- run: echo //registry.npmjs.org/:_authToken=${NPM_TOKEN} > .npmrc
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Publish to npm
run: pnpm run publish-canary
publish_release:
# this job will only run if the PR has been merged
if: github.event.pull_request.merged == true && startsWith(github.head_ref, 'release/v')
runs-on: ubuntu-latest
steps:
- name: Check Release Format
id: check-release
run: |
if [[ ${{ github.head_ref }} =~ ^release/v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo ::set-output name=match::true
fi
- name: Create tag
if: steps.check-release.outputs.match == 'true'
id: create_tag
run: |
tag=$(echo ${{ github.event.pull_request.head.ref }} | sed 's/release\///')
echo ::set-output name=tag::$tag
- uses: actions/checkout@v2
with:
fetch-depth: 0
- run: echo //registry.npmjs.org/:_authToken=${NPM_TOKEN} > .npmrc
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Set tag
if: steps.check-release.outputs.match == 'true'
run: |
npx lerna publish from-git --no-push --force-publish
git tag --force ${{ steps.create_tag.outputs.tag }} -m "tag release ${{ steps.create_tag.outputs.tag }}"
git push -f origin ${{ steps.create_tag.outputs.tag }}