-
Notifications
You must be signed in to change notification settings - Fork 7
62 lines (60 loc) · 2.23 KB
/
publish-npm.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
name: Publish (npm)
on:
workflow_call:
secrets:
NPM_TOKEN:
required: true
jobs:
publish:
name: ${{ matrix.target }}
runs-on: ubuntu-24.04
permissions:
contents: read
id-token: write
pull-requests: write
strategy:
matrix:
target: [ ui, icons, helper, tsconfig, publish-package, eslint-config, eslint-plugin-nextjs ]
steps:
- uses: actions/checkout@v4
- name: Setup Node.js env
uses: ./.github/actions/setup-node-env
with:
# we have to skip the cache here, because publish-package#build needs to run,
# or else the bin is not correctly linked
cache-key: false
- name: Run Publish
run: pnpm run publish-package --filter=@gw2treasures/${{ matrix.target }} --env-mode=loose
id: publish
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
NPM_CONFIG_PROVENANCE: true
GITHUB_EVENT_NAME: ${{ github.event_name }}
- name: Find Comment
if: github.event_name == 'pull_request'
uses: peter-evans/find-comment@v3
id: fc
with:
issue-number: ${{ github.event.pull_request.number }}
comment-author: 'github-actions[bot]'
body-includes: Publish / npm / ${{ matrix.target }}
- name: Delete comment if found but nothing will be published
if: github.event_name == 'pull_request' && steps.fc.outputs.comment-id && !steps.publish.outputs.publish
uses: actions/github-script@v7
with:
script: |
github.rest.issues.deleteComment({
owner: context.repo.owner,
repo: context.repo.repo,
comment_id: ${{ steps.fc.outputs.comment-id }}
})
- name: Add comment with packages to be published
if: github.event_name == 'pull_request' && steps.publish.outputs.publish
uses: peter-evans/create-or-update-comment@v4
with:
comment-id: ${{ steps.fc.outputs.comment-id }}
issue-number: ${{ github.event.pull_request.number }}
edit-mode: replace
body: |
**Publish / npm / ${{ matrix.target }}**
Merging this PR will publish the npm package `${{ steps.publish.outputs.package }}@${{ steps.publish.outputs.version }}` as `${{ steps.publish.outputs.tag }}`.