-
Notifications
You must be signed in to change notification settings - Fork 1
50 lines (49 loc) · 1.67 KB
/
on-merge-to-main.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
name: "Publish packages on merge to main"
on:
pull_request:
types:
- closed
jobs:
merged:
if: github.event.pull_request.merged == true
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: '18.x'
registry-url: 'https://registry.npmjs.org'
- name: Install jq
uses: dcarbone/[email protected]
- name: Configure git identity
run: |
git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"
git config --global user.name "Userfront Robot"
- run: npm ci
- run: npm run build:package
- name: Get dist-tag name
id: dist-tag
env:
BRANCH: "${{ github.event.pull_request.head.ref }}"
run: |
if [[ $BRANCH == release/* ]]; then
echo "NAME=latest" >> "$GITHUB_OUTPUT"
else
echo "NAME=alpha" >> "$GITHUB_OUTPUT"
fi
- run: npm publish -w package --tag ${{ steps.dist-tag.outputs.NAME }} --access=public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Get package version
id: version
run: |
npm pkg get version -ws | jq -r '."@userfront/toolkit"' | xargs -0 -L1 -I '%' echo "VERSION=%" >> "$GITHUB_OUTPUT"
- uses: actions/github-script@v6
with:
script: |
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: 'Published version ${{ steps.version.outputs.VERSION }} to npm.'
})