-
Notifications
You must be signed in to change notification settings - Fork 14
144 lines (143 loc) · 5.7 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
136
137
138
139
140
141
142
143
144
name: Publish Package to npmjs
on:
release:
types: [published]
jobs:
validate-tag:
runs-on: ubuntu-latest
steps:
- uses: actions-ecosystem/action-regex-match@v2
id: tag-match
with:
text: ${{ github.event.release.tag_name }}
regex: '^\d+\.\d+\.\d+$'
- run: echo "Please create tag for release with format like 4.0.1" && exit 1
if: ${{ steps.tag-match.outputs.match == '' }}
# Old create-checkly versions still look for the tag with a `v` prefix.
# We can automatically push the necessary tag to keep those working.
- name: Create tag for old create-checkly versions
uses: actions/github-script@v6
with:
script: |
github.rest.git.createRef({
owner: context.repo.owner,
repo: context.repo.repo,
ref: 'refs/tags/v${{ github.event.release.tag_name }}',
sha: context.sha
})
# Build package and publish a prerelease
prerelease:
needs: validate-tag
permissions:
id-token: write
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
# Setup .npmrc file to publish to npm
- uses: actions/setup-node@v4
with:
node-version: '18.x'
registry-url: 'https://registry.npmjs.org'
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
# Ensure that the README is published with the package
- run: rm -f packages/cli/README.md && cp README.md packages/cli
- run: npm ci
- name: Add SHORT_SHA env property with commit short sha
run: echo "SHORT_SHA=$(git rev-parse --short HEAD)" >> $GITHUB_ENV
- name: Set version and publish prerelease for 'cli' package
run: |
npm --no-git-tag-version version ${{ github.event.release.tag_name }}-prerelease-${{ env.SHORT_SHA }} --workspace packages/cli
npm publish --provenance --workspace packages/cli --tag prerelease
- name: Set version and publish prerelease for 'create-cli' package
run: |
npm --no-git-tag-version version ${{ github.event.release.tag_name }}-prerelease-${{ env.SHORT_SHA }} --workspace packages/create-cli
npm publish --provenance --workspace packages/create-cli --tag prerelease
- name: Output prerelease packages versions
run: |
npm pkg get version --workspace packages/cli
npm pkg get version --workspace packages/create-cli
# Slack failure alert
- name: Slack Failure Notification
if: ${{ failure() }}
uses: rtCamp/action-slack-notify@v2
env:
SLACK_USERNAME: Checkly Github Bot
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
SLACK_CHANNEL: cli
SLACK_ICON: https://github.com/checkly.png?size=48
SLACK_COLOR: ${{ job.status }}
SLACK_TITLE: ':red_circle: NPM prerelease failed'
SLACK_MESSAGE: by ${{ github.actor }}
SLACK_FOOTER: ''
# Slack success alert
- name: Slack Success Notification
if: ${{ success() }}
uses: rtCamp/action-slack-notify@v2
env:
SLACK_USERNAME: Checkly Github Bot
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
SLACK_CHANNEL: cli
SLACK_ICON: https://github.com/checkly.png?size=48
SLACK_COLOR: ${{ job.status }}
SLACK_TITLE: ':white_check_mark: NPM prerelease succeeded'
SLACK_MESSAGE: by ${{ github.actor }}
SLACK_FOOTER: ''
# Publish package to NPM
release:
runs-on: ubuntu-latest
environment: production
needs: prerelease
permissions:
id-token: write
steps:
- uses: actions/checkout@v3
with:
ref: main
- uses: actions/setup-node@v4
with:
node-version: '18.x'
registry-url: 'https://registry.npmjs.org'
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
# Ensure that the README is published with the package
- run: rm -f packages/cli/README.md && cp README.md packages/cli
- run: npm ci
- name: Set version and publish 'cli' package
run: |
npm --no-git-tag-version version ${{ github.event.release.tag_name }} --workspace packages/cli
npm publish --provenance --workspace packages/cli
- name: Set version and publish 'create-cli' package
run: |
npm --no-git-tag-version version ${{ github.event.release.tag_name }} --workspace packages/create-cli
npm publish --provenance --workspace packages/create-cli
- name: Output final packages versions
run: |
npm pkg get version --workspace packages/cli
npm pkg get version --workspace packages/create-cli
# Slack failure alert
- name: Slack Failure Notification
if: ${{ failure() }}
uses: rtCamp/action-slack-notify@v2
env:
SLACK_USERNAME: Checkly Github Bot
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
SLACK_CHANNEL: cli
SLACK_ICON: https://github.com/checkly.png?size=48
SLACK_COLOR: ${{ job.status }}
SLACK_TITLE: ':red_circle: NPM publish failed'
SLACK_MESSAGE: by ${{ github.actor }}
SLACK_FOOTER: ''
# Slack success alert
- name: Slack Success Notification
if: ${{ success() }}
uses: rtCamp/action-slack-notify@v2
env:
SLACK_USERNAME: Checkly Github Bot
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
SLACK_CHANNEL: cli
SLACK_ICON: https://github.com/checkly.png?size=48
SLACK_COLOR: ${{ job.status }}
SLACK_TITLE: ':white_check_mark: NPM publish succeeded'
SLACK_MESSAGE: by ${{ github.actor }}
SLACK_FOOTER: ''