-
Notifications
You must be signed in to change notification settings - Fork 10
181 lines (175 loc) · 7.09 KB
/
Copy pathpublish-npm.yaml
File metadata and controls
181 lines (175 loc) · 7.09 KB
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
name: Publish NPM Package
on:
release:
types: [published]
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
publish-harper-npm-package:
runs-on: ubuntu-latest
outputs:
harper-version: ${{ steps.version-components.outputs.version }}
steps:
- uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
with:
node-version: latest
registry-url: 'https://registry.npmjs.org'
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Get release build
env:
GH_TOKEN: ${{ github.token }}
run: gh release download ${{ github.event.release.tag_name }} --pattern "harper-*.tgz"
- name: Get version components
id: version-components
uses: matt-usurp/validate-semver@7bbc9584679de1aeef57aa531504ab00438481ab # v2.1.0
with:
version: ${{ github.event.release.tag_name }}
- name: Set package tag
id: package-tag
# Once we have our first full, non-beta release, turn this back on:
# run: |
# if [[ "${{ steps.version-components.outputs.prerelease }}" == '' ]]; then
# echo "packageTag=latest" >> "$GITHUB_OUTPUT"
# else
# echo "packageTag=next" >> "$GITHUB_OUTPUT"
# fi
# and get rid of this hard coded latest tagging:
run: |
echo "packageTag=latest" >> "$GITHUB_OUTPUT"
- name: Publish package to NPM registry
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
run: npm publish --access=public --tag=${{ steps.package-tag.outputs.packageTag }} harper-*.tgz
publish-harperfast-npm-package:
runs-on: ubuntu-latest
outputs:
harper-version: ${{ steps.version-components.outputs.version }}
steps:
- uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
with:
node-version: latest
registry-url: 'https://registry.npmjs.org'
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Get release build
env:
GH_TOKEN: ${{ github.token }}
run: gh release download ${{ github.event.release.tag_name }} --pattern "harper-*.tgz"
- name: Get version components
id: version-components
uses: matt-usurp/validate-semver@7bbc9584679de1aeef57aa531504ab00438481ab # v2.1.0
with:
version: ${{ github.event.release.tag_name }}
- name: Rename package to '@harperfast/harper'
run: |
mkdir package
tar -xvf harper-${{ steps.version-components.outputs.version }}.tgz -C package --strip-components=1
pushd package
npm pkg set name=@harperfast/harper
popd
tar -czvf harperfast-harper-${{ steps.version-components.outputs.version }}.tgz package
- name: Set package tag
id: package-tag
# Once we have our first full, non-beta release, turn this back on:
# run: |
# if [[ "${{ steps.version-components.outputs.prerelease }}" == '' ]]; then
# echo "packageTag=latest" >> "$GITHUB_OUTPUT"
# else
# echo "packageTag=next" >> "$GITHUB_OUTPUT"
# fi
# and get rid of this hard coded latest tagging:
run: |
echo "packageTag=latest" >> "$GITHUB_OUTPUT"
- name: Publish package to NPM registry
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
run: npm publish --access=public --tag=${{ steps.package-tag.outputs.packageTag }} harperfast-harper-*.tgz
send-slack-message-on-success:
if: success() && !cancelled()
needs:
- publish-harperfast-npm-package
- publish-harper-npm-package
runs-on: ubuntu-latest
steps:
- name: Send Slack published notification
uses: slackapi/slack-github-action@45a88b9581bfab2566dc881e2cd66d334e621e2c # v3.0.3
with:
method: chat.postMessage
token: ${{ secrets.SLACK_BOT_TOKEN }}
payload: |
{
"channel": "#development-ci",
"text": "Harper v${{ needs.publish-harper-npm-package.outputs.harper-version }} has been published to NPM",
"blocks": [
{
"type": "header",
"text": {
"type": "plain_text",
"text": "Harper v${{ needs.publish-harper-npm-package.outputs.harper-version }} release"
}
},
{
"type": "context",
"elements": [
{
"type": "mrkdwn",
"text": "*Status*"
},
{
"type": "mrkdwn",
"text": ":white_check_mark: Published to :npm:"
},
{
"type": "mrkdwn",
"text": "<https://www.npmjs.com/package/harper/v/${{ needs.publish-harper-npm-package.outputs.harper-version }}|harper@${{ needs.publish-harper-npm-package.outputs.harper-version }}>"
},
{
"type": "mrkdwn",
"text": "<https://www.npmjs.com/package/@harperfast/harperfast/v/${{ needs.publish-harperfast-npm-package.outputs.harper-version }}|@harperfast/harper@${{ needs.publish-harperfast-npm-package.outputs.harper-version }}>"
}
]
}
]
}
send-slack-message-on-failure:
if: failure() && !cancelled()
needs:
- publish-harperfast-npm-package
- publish-harper-npm-package
runs-on: ubuntu-latest
steps:
- uses: slackapi/slack-github-action@45a88b9581bfab2566dc881e2cd66d334e621e2c # v3.0.3
with:
method: chat.postMessage
token: ${{ secrets.SLACK_BOT_TOKEN }}
payload: |
{
"channel": "#development-ci",
"text": "Harper v${{ needs.publish-harper-npm-package.outputs.harper-version }} NPM publish failed",
"blocks": [
{
"type": "header",
"text": {
"type": "plain_text",
"text": "Harper v${{ needs.publish-harper-npm-package.outputs.harper-version }} release"
}
},
{
"type": "context",
"elements": [
{
"type": "mrkdwn",
"text": "*Status*"
},
{
"type": "mrkdwn",
"text": ":x: Failed to publish to :npm:"
},
{
"type": "mrkdwn",
"text": "<${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}|Workflow run ${{ github.run_id }}>"
}
]
}
]
}