-
Notifications
You must be signed in to change notification settings - Fork 37
211 lines (196 loc) · 7.52 KB
/
release.yaml
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
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
# This github action publishes a release on-demand. It can be triggered manually. Before actually publishing a release,
# it will check whether there are successful CircleCI builds for the commit that is to be released.
name: release-on-demand
on:
workflow_dispatch:
inputs:
fromPackage:
description: "Use \"lerna publish from-package\""
required: false
default: false
type: choice
options:
- false
- true
dryRun:
description: "Dry Run"
required: false
default: false
type: choice
options:
- false
- true
skipCiStatusCheck:
description: "Skip CI status check"
required: false
default: false
type: choice
options:
- false
- true
jobs:
publish-release:
name: Release the main branch as a new version to the npm registry.
runs-on: ubuntu-latest
env:
CIRCLE_TOKEN: ${{ secrets.CIRCLE_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
FROM_PACKAGE: ${{ inputs.fromPackage }}
DRY_RUN: ${{ inputs.dryRun }}
SKIP_CI_STATUS_CHECK: ${{ inputs.skipCiStatusCheck }}
steps:
- uses: actions/checkout@v3
with:
# With fetch-depth 0 the checkout action will also fetch all tags and branches. We need the tags for
# ./disallow-major-release.sh to work.
fetch-depth: 0
token: ${{ secrets.GH_PAT }}
- uses: actions/setup-node@v3
with:
node-version: "18"
cache: 'npm'
cache-dependency-path: '**/package-lock.json'
- name: echo versions
run: |
node --version
npm --version
- name: Check CircleCI status
run: |
if [[ $SKIP_CI_STATUS_CHECK != true ]]; then
bin/check-circle-ci-status.js
fi
- run: npm ci
- name: Disallow major releases
run: .github/workflows/disallow-major-release.sh
- name: Add token to .npmrc
run: echo '//registry.npmjs.org/:_authToken=${NPM_TOKEN}' >> .npmrc
# This is required to make sure that new packages (@instana packages that we publish for the first time) can be
# published to the npm registry. The default visibility for scoped packages is private, but our npm account
# (free plan) does not allow private packages (and we actually want those packages to be public).
- run: npm config set access public
- name: Configure git name/email
run: |
git config user.name "IBM/Instana/Team Node.js"
git config user.email [email protected]
- name: Execute lerna
run: |
set -x
if [[ $DRY_RUN = true ]]; then
npx lerna version --no-git-tag-version --no-push --yes
git status
git --no-pager diff --cached
git --no-pager diff
elif [[ $FROM_PACKAGE = true ]]; then
npx lerna publish --yes --no-verify-access from-package
git log -p -n1
else
npx lerna publish --yes --no-verify-access
git log -p -n1
fi
- id: read_version_number
name: Read the new version number from package.json
# --raw-output removes the quotes around the version number from the jq output.
# The quotes would break the JSON payload for the Slack success message.
run: echo "version=$(jq --raw-output .version packages/core/package.json)" >> $GITHUB_OUTPUT
- name: Send success message to team channel
if: "${{ success() && env.DRY_RUN != 'true' }}"
uses: slackapi/[email protected]
with:
channel-id: ${{ secrets.SLACK_CHANNEL_ID_TEAM }}
payload: |
{
"text": ":mega: :package: Version ${{ steps.read_version_number.outputs.version }} has been released successfully! :star-struck: :tada:",
"attachments": [{
"color": "good",
"fields": [
{
"title": "Changelog",
"value": "<${{ github.server_url }}/${{ github.repository }}/blob/main/CHANGELOG.md>"
},
{
"title": "Commit URL",
"value": "<${{ github.server_url }}/${{ github.repository }}/commit/${{ github.sha }}>"
},
{
"title": "Action URL",
"value": "<${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}>"
},
{
"title": "Dry Run?",
"value": "${{ env.DRY_RUN }}",
"short": true
},
{
"title": "Skip CircleCI check?",
"value": "${{ env.SKIP_CI_STATUS_CHECK }}",
"short": true
},
{
"title": "Publish with from-package?",
"value": "${{ env.FROM_PACKAGE }}",
"short": true
}
]
}]
}
env:
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }}
- name: Send success message to release channel
if: "${{ success() && env.DRY_RUN != 'true' }}"
uses: slackapi/[email protected]
with:
channel-id: ${{ secrets.SLACK_CHANNEL_ID_RELEASES }}
payload: |
{
"text": ":mega: :package: Version ${{ steps.read_version_number.outputs.version }} of the Node.js tracer (npm package @instana/collector and friends) has been released! :star-struck: :tada:",
"attachments": [{
"color": "good",
"fields": [
{
"title": "Changelog",
"value": "<${{ github.server_url }}/${{ github.repository }}/blob/main/CHANGELOG.md>"
}
]
}]
}
env:
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }}
- name: Send failure message
if: "${{ failure() && env.DRY_RUN != 'true' }}"
uses: slackapi/[email protected]
with:
channel-id: ${{ secrets.SLACK_CHANNEL_ID_TEAM }}
payload: |
{
"text": ":boom: :scream: Releasing new package versions has failed! :scream_cat: :sob:",
"attachments": [{
"color": "danger",
"fields": [
{
"title": "Commit URL",
"value": "<${{ github.server_url }}/${{ github.repository }}/commit/${{ github.sha }}>"
},
{
"title": "Action URL",
"value": "<${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}>"
},
{
"title": "Dry Run?",
"value": "${{ env.DRY_RUN }}",
"short": true
},
{
"title": "Skip CircleCI check?",
"value": "${{ env.SKIP_CI_STATUS_CHECK }}",
"short": true
},
{
"title": "Publish with from-package?",
"value": "${{ env.FROM_PACKAGE }}",
"short": true
}
]
}]
}
env:
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }}