-
Notifications
You must be signed in to change notification settings - Fork 32
90 lines (77 loc) · 3.1 KB
/
release.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
name: Release
on:
schedule:
- cron: '0 4 * * 1-5'
workflow_dispatch:
jobs:
release:
name: 'Release & Publish'
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@v3
with:
# pulls all commits (needed for lerna / semantic release to correctly version)
fetch-depth: 0
token: ${{ secrets.GH_TOKEN }}
- name: Pull all tags
# pulls all tags (needed for lerna / semantic release to correctly version)
run: git fetch --all --tags
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version-file: .nvmrc
registry-url: 'https://registry.npmjs.org'
- name: Install dependencies
run: yarn install
- name: Get version from lerna.json before release step
id: initversion
run: |
echo "::set-output name=version::$(grep '"version":' lerna.json | cut -d\" -f4)"
- name: Check for package changes
id: changes
run: |
npx lerna changed 2>&1 | tail -1 |tee outfile
echo "::set-output name=changed::$(cat outfile)"
- name: GitHub Release
id: release
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GIT_AUTHOR_NAME: ${{ secrets.GH_NAME }}
GIT_AUTHOR_EMAIL: ${{ secrets.GH_EMAIL }}
GIT_COMMITTER_NAME: ${{ secrets.GH_NAME }}
GIT_COMMITTER_EMAIL: ${{ secrets.GH_EMAIL }}
if: contains(steps.changes.outputs.changed, 'ready to publish')
run: 'yarn lerna:run-version --yes --create-release github -m "chore(Release): %v [skip ci]" --conventional-commits'
- name: Get version from package.json after release step
id: extractver
run: |
echo "::set-output name=version::$(grep '"version":' lerna.json | cut -d\" -f4)"
- name: Confirm version changes
run: |
echo "the initial version is ${{steps.initversion.outputs.version}}"
echo "the updated version is ${{steps.extractver.outputs.version}}"
- name: Publish NPM packages
if: steps.initversion.outputs.version != steps.extractver.outputs.version
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }}
run: |
npm publish --tag latest ./packages/design-tokens
npm publish --tag latest ./packages/eslint-config-react
npm publish --tag latest ./packages/fonts
npm publish --tag latest ./packages/icon-library
npm publish --tag latest ./packages/react-component-library
npm publish --tag latest ./packages/cra-template-defencedigital
- name: Publish Storybook
if: steps.initversion.outputs.version != steps.extractver.outputs.version
run: |
curl -X POST -d {} ${{ secrets.STORYBOOK_TOKEN }}
- name: Send notification on failure
if: failure()
env:
SLACK_BOT_TOKEN: ${{ secrets.SLACK_NOTIFICATIONS_BOT_TOKEN }}
uses: defencedigital/design-system-slacknotify-action@master
with:
channel_id: C02H226CT33
status: FAILED
color: danger