This repository has been archived by the owner on Jun 24, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
132 lines (108 loc) · 4.09 KB
/
snapshot-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
# Based on https://github.com/Shopify/polaris
name: Snapshot Release
on:
issue_comment:
types:
- created
concurrency: ${{ github.workflow }}-${{ github.ref }}
jobs:
snapshot:
name: Snapshot Release
runs-on: ubuntu-latest
if: |
github.event.issue.pull_request &&
github.event.comment.body == '/snapshot' &&
github.repository == 'pedakihq/pedaki'
steps:
- name: Add initial reaction
uses: peter-evans/create-or-update-comment@v3
with:
comment-id: ${{ github.event.comment.id }}
reactions: eyes
edit-mode: replace
body: |
@${{ github.actor }} your snapshot release is being processed.
:hourglass_flowing_sand: This may take a few minutes...
- name: Enforce permission requirement
id: check-permissions
continue-on-error: true
uses: prince-chrismc/check-actor-permissions-action@v2
with:
permission: write
- name: Add reaction if permission requirement not met
if: steps.check-permissions.outcome == 'failure'
uses: peter-evans/create-or-update-comment@v3
with:
comment-id: ${{ github.event.comment.id }}
reactions: confused
edit-mode: replace
body: |
@${{ github.actor }} you do not have permission to run this command.
Please ask a maintainer to run this command for you.
- name: Exit if permission requirement not met
if: steps.check-permissions.outcome == 'failure'
run: exit 1
- name: Checkout Repo
uses: actions/checkout@v3
with:
fetch-depth: 0
# Because changeset entries are consumed and removed on the
# 'changeset-release/main' branch, we need to reset the files
# so the following 'changeset version --snapshot' command will
# regenerate the package version bumps with the snapshot releases
- name: Reset changeset entries on changeset-release/main branch
run: |
if [[ $(git branch --show-current) == 'changeset-release/main' ]]; then
git checkout origin/main -- .changeset
fi
- uses: pnpm/action-setup@v2
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version-file: .nvmrc
cache: pnpm
cache-dependency-path: pnpm-lock.yaml
- name: Install deps
run: pnpm install --child-concurrency 3 --frozen-lockfile --prefer-offline
- name: Create an .npmrc
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
run: |
cat << EOF > "$HOME/.npmrc"
//registry.npmjs.org/:_authToken=$NPM_TOKEN
EOF
- name: Run Changeset
id: changeset
run: |
pnpm exec changeset version --snapshot
pnpm run publish:prepare
output=$(pnpm exec changeset publish --tag next)
echo $output
changesetComment=$(echo "$output" | grep -zoE 'New tag: ([^ ]+)' | sed -E 's/New tag: //g')
echo "changesetComment=$changesetComment" >> $GITHUB_OUTPUT
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Send success comment
uses: peter-evans/create-or-update-comment@v3
if: success()
with:
comment-id: ${{ github.event.comment.id }}
reactions: rocket
reactions-edit-mode: replace
edit-mode: replace
body: |
@${{ github.actor }} your snapshot release has been published!
```
${{ steps.changeset.outputs.changesetComment }}
```
- name: Send failure comment
uses: peter-evans/create-or-update-comment@v3
if: failure()
with:
comment-id: ${{ github.event.comment.id }}
reactions: -1
reactions-edit-mode: replace
edit-mode: replace
body: |
@${{ github.actor }} your snapshot release failed to publish.
Please check the logs for more information.