-
Notifications
You must be signed in to change notification settings - Fork 18
88 lines (77 loc) · 2.66 KB
/
deploy-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
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
name: Deploy to NPM
on:
workflow_dispatch:
workflow_run:
workflows: ['Publish new github release']
types:
- completed
jobs:
deploy-npm:
name: Deploy to NPM
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/v') || startsWith(github.ref, 'refs/heads/master') || github.event.workflow_run.conclusion == 'success'
steps:
- name: Checkout source branch
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Checkout to master
if: github.event.workflow_run.conclusion == 'success'
run: git checkout master
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version-file: '.nvmrc'
cache: 'npm'
- name: Setup npm login
run: |
npm set //registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}
- name: Install node_modules
env:
HUSKY: 0
run: |
rm -rf node_modules
npm run setup:ci
- name: Get the two latest versions
run: |
CURRENT_VERSION=$(git tag -l "v*" --sort=-version:refname | head -n 1)
LAST_VERSION=$(git tag -l "v*" --sort=-version:refname | head -n 2 | awk 'NR == 2 { print $1 }')
echo "Current version: $CURRENT_VERSION"
echo "Previous version: $LAST_VERSION"
echo "current_version=$(echo $CURRENT_VERSION)" >> $GITHUB_ENV
echo "last_version=$(echo $LAST_VERSION)" >> $GITHUB_ENV
echo "DATE=$(date)" >> $GITHUB_ENV
- name: Build & Publish affected packages
run: |
npm run deploy:npm -- --base=$last_version --head=$current_version
- name: Send message to Slack channel
id: slack
uses: slackapi/slack-github-action@v1.27.0
env:
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }}
PROJECT_NAME: 'React Native SDK npm packages'
NPM_PACKAGE_URL: 'https://www.npmjs.com/search?q=%40rudderstack'
with:
channel-id: ${{ secrets.SLACK_RELEASE_CHANNEL_ID }}
payload: |
{
"blocks": [
{
"type": "header",
"text": {
"type": "plain_text",
"text": "New release: ${{ env.PROJECT_NAME }}"
}
},
{
"type": "divider"
},
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "*Release: <${{ env.NPM_PACKAGE_URL }}|Latest Packages>*\n${{ env.DATE }}"
}
}
]
}