-
Notifications
You must be signed in to change notification settings - Fork 17
58 lines (56 loc) · 2.23 KB
/
release-canary.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
name: release-canary
on:
pull_request:
types:
- labeled
jobs:
publish:
if: ${{ github.event.label.name == 'build' }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
ref: ${{ github.event.pull_request.head.sha }}
# Setup .npmrc file to publish to npm
- uses: actions/setup-node@v4
with:
node-version: '18.x'
registry-url: 'https://registry.npmjs.org'
# Extract the dynamic value from the canary label if present
- name: Extract CANARY_TAG
id: extract-canary
run: |
LABELS_JSON='${{ toJson(github.event.pull_request.labels) }}'
CANARY_TAG=$(node -e "
const labels = JSON.parse(process.env.LABELS_JSON || '[]');
const canaryLabel = labels.find(label => label.name.startsWith('canary:'));
if (canaryLabel) console.log(canaryLabel.name.split(':')[1]);
")
echo $CANARY_TAG
echo "CANARY_TAG=$CANARY_TAG" >> $GITHUB_ENV
# Ensure that the README is published with the package
- run: rm -f packages/cli/README.md && cp README.md packages/cli
- run: echo "PR_VERSION=0.0.0-pr.${{github.event.pull_request.number}}.$(git rev-parse --short HEAD)" >> $GITHUB_ENV
- run: npm ci
- run: npm version ${{ env.PR_VERSION }} --workspace packages/cli
# Publish to npm with the additional tag if CANARY_TAG is set
- run: |
npm publish --workspace packages/cli --tag experimental
if [[ -n "$CANARY_TAG" ]]; then
echo "Publishing with additional tag: $CANARY_TAG"
npm dist-tag add checkly@$PR_VERSION $CANARY_TAG
fi
env:
CANARY_TAG: ${{ env.CANARY_TAG }}
PR_VERSION: ${{ env.PR_VERSION }}
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- uses: marocchino/sticky-pull-request-comment@v2
with:
header: PR Preview Release Published
hide_and_recreate: true
hide_classify: "OUTDATED"
message: |
🎉 Experimental release successfully published [on npm](https://npmjs.com/package/checkly/v/${{env.PR_VERSION}})
```
npm install checkly@${{env.PR_VERSION}}
```