-
-
Notifications
You must be signed in to change notification settings - Fork 141
101 lines (92 loc) · 3.16 KB
/
npm-service.yml
File metadata and controls
101 lines (92 loc) · 3.16 KB
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
---
name: NPM Service
on:
release:
types: [published]
pull_request:
branches: [main]
types: [opened, synchronize, reopened]
paths-ignore:
- "**.md"
permissions:
contents: read
id-token: write
# Manage concurrency to stop running jobs and start new ones in case of new commit pushed
concurrency:
group: ${{ github.ref }}-${{ github.workflow }}
cancel-in-progress: true
jobs:
publish:
if: github.event_name == 'release' || github.actor != 'dependabot[bot]'
runs-on: ubuntu-latest
outputs:
channel: ${{ steps.publish.outputs.channel }}
permissions:
id-token: write
contents: read
pull-requests: write
steps:
- uses: actions/checkout@v6
- uses: actions/setup-node@v6
with:
node-version: 20
registry-url: "https://registry.npmjs.org"
- run: npm install -g npm@latest
- uses: ./.github/actions/install
# Dev version setup (PR only)
- name: Compute dev version
if: github.event_name == 'pull_request'
id: version
run: |
CURRENT_VERSION=$(jq -r '.version' package.json)
DEV_CHANNEL="dev-${{ github.event.pull_request.number }}"
DEV_VERSION="${CURRENT_VERSION}-${DEV_CHANNEL}.${{ github.run_id }}-${{ github.run_attempt }}"
echo "channel=$DEV_CHANNEL" >> "$GITHUB_OUTPUT"
echo "version=$DEV_VERSION" >> "$GITHUB_OUTPUT"
- name: Set dev version
if: github.event_name == 'pull_request'
env:
DEV_CHANNEL: ${{ steps.version.outputs.channel }}
run: |
git config --global user.email "${DEV_CHANNEL}@github.com"
git config --global user.name "$DEV_CHANNEL"
npm version "${{ steps.version.outputs.version }}" --no-git-tag-version
# Publish (unified with conditional channel)
- name: Publish
id: publish
env:
DEV_CHANNEL: ${{ steps.version.outputs.channel }}
RELEASE_TAG: ${{ github.event.release.tag_name }}
EVENT_NAME: ${{ github.event_name }}
run: |
if [ "$EVENT_NAME" = "pull_request" ]; then
CHANNEL="$DEV_CHANNEL"
else
CHANNEL="latest-rc"
fi
npm publish --provenance --access public --tag "$CHANNEL"
# For e2e: PR uses dev channel, release uses tag name (e.g., v1.5.0)
if [ "$EVENT_NAME" = "pull_request" ]; then
echo "channel=$DEV_CHANNEL" >> "$GITHUB_OUTPUT"
else
echo "channel=$RELEASE_TAG" >> "$GITHUB_OUTPUT"
fi
# Comment PR (PR only)
- name: Comment PR
if: github.event_name == 'pull_request'
uses: thollander/actions-comment-pull-request@v3
env:
DEV_CHANNEL: ${{ steps.version.outputs.channel }}
with:
message: |
Published under `${{ env.DEV_CHANNEL }}` npm channel.
```sh
$ sf plugins install sfdx-git-delta@${{ env.DEV_CHANNEL }}
```
comment-tag: dev-publish
mode: recreate
e2e-tests:
needs: [publish]
uses: ./.github/workflows/run-e2e-tests.yml
with:
channel: ${{ needs.publish.outputs.channel }}