-
Notifications
You must be signed in to change notification settings - Fork 22
135 lines (114 loc) · 3.96 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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
name: Release
on:
schedule:
- cron: "0 5 * * 1,4" # at 05:00 on monday,thursday
workflow_dispatch:
jobs:
tests:
name: Tests
uses: ./.github/workflows/tests.yml
secrets: inherit
visual-tests:
name: Visual Tests
uses: ./.github/workflows/tests-visual.yml
secrets: inherit
publish:
name: Publish Packages
needs: [tests, visual-tests]
runs-on: ubuntu-latest
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
CHECKOUT_REF: ${{ github.event.client_payload.ref }}
RELEASE_TYPE: ${{ github.event.client_payload.type }}
NPM_CONFIG_PROVENANCE: true
outputs:
SLACK_MESSAGE: ${{ steps.slackMessage.outputs.SLACK_MESSAGE }}
permissions:
contents: write
id-token: write
steps:
- name: Checkout
uses: actions/checkout@v4
with:
# Pulls all commits (needed for semantic release to correctly version)
# See https://github.com/semantic-release/semantic-release/issues/1526
fetch-depth: "0"
fetch-tags: true
- name: Publish Setup
run: |
git config --global user.name 'github-actions[bot]'
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
- name: Install Dependencies
uses: ./.github/actions/install-dependencies
- name: Publish to NPM
id: publish-npm
env:
NODE_AUTH_TOKEN: ${{secrets.HV_NPM_AUTOMATION_TOKEN}}
run: |
VERSION=v$(npm pkg get version -ws | sed -n 's/.*uikit-react-core": "\(.*\)".*/\1/p')
echo "CURRENT_VERSION=$VERSION" >> "$GITHUB_ENV"
npm config set //registry.npmjs.org/:_authToken=$NODE_AUTH_TOKEN
npm run publish 2>&1 | tee publish_logs.txt
- name: Check if packages were updated
run: |
if grep -q "lerna success published" publish_logs.txt; then
echo "New packages were published successfully"
elif grep -q "lerna Command failed" publish_logs.txt; then
echo "lerna Command failed"
exit 1
else
echo "No packages were updated - skipping release"
exit 1
fi
- name: Set NEW_VERSION
id: version
# Outputs the NEW_VERSION if there is one, or exits otherwise
# We only tag+publish+notify if there a new core package version
run: |
VERSION=v$(npm pkg get version -ws | sed -n 's/.*uikit-react-core": "\(.*\)".*/\1/p')
if [ "$CURRENT_VERSION" = "$VERSION" ]; then
echo "No new uikit-react-core version to release. Exiting"
exit 1
fi
echo "NEW_VERSION=$VERSION" >> "$GITHUB_ENV"
- name: Tag Release
run: |
git tag -a $NEW_VERSION -m "Version $NEW_VERSION"
git push origin $NEW_VERSION
- name: Create GitHub Release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
npm i --no-save [email protected]
npx changelogithub --from $CURRENT_VERSION --to $NEW_VERSION
- name: Set SLACK_MESSAGE
id: slackMessage
run: |
echo "SLACK_MESSAGE=$(.github/scripts/changelog.js $CURRENT_VERSION $NEW_VERSION)" >> $GITHUB_OUTPUT
publish-documentation:
name: Publish Documentation
needs: [publish]
uses: ./.github/workflows/documentation.yml
secrets: inherit
with:
publish-folder: ${{ github.ref_name }}
security-scans:
name: Security Scans
needs: [publish]
uses: ./.github/workflows/security.yml
secrets: inherit
notify-release:
name: Notify release
runs-on: ubuntu-latest
needs: [publish]
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Send Slack message
uses: slackapi/[email protected]
env:
SLACK_BOT_TOKEN: ${{ secrets.SLACK_TOKEN }}
with:
channel-id: "ui-kit"
payload: |
{ "blocks": ${{ needs.publish.outputs.SLACK_MESSAGE }} }