-
Notifications
You must be signed in to change notification settings - Fork 2
78 lines (67 loc) · 2.25 KB
/
pkg-npm-publish.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
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
name: 'pkg: Publish to npm'
run-name: 'Publish to npm Registry (${{ inputs.version }})'
on:
workflow_dispatch:
inputs:
version:
description: 'Semantic Version'
required: true
type: choice
options:
- patch
- minor
- major
jobs:
publish:
name: Publish to npm
runs-on: ubuntu-latest
steps:
- name: '🛒 Checkout Code'
uses: actions/checkout@v4
with:
token: ${{ secrets.GH_BOT_TOKEN }}
- name: '🟢 Use Node.js'
uses: actions/setup-node@v4
with:
node-version: 20
registry-url: 'https://registry.npmjs.org'
cache: 'yarn'
- name: '📦 Install packages'
run: yarn install
- name: '🏗️ Build'
run: yarn build
- name: '🔼 Increment Version'
run: yarn version ${{ inputs.version }}
- name: '#️⃣ Get Version'
uses: actions/github-script@v7
id: version
with:
result-encoding: string
retries: 3
script: |
const fs = require('fs');
const pj = JSON.parse(fs.readFileSync('${{ github.workspace }}/package.json'));
return pj.version;
- name: '💾 Commit Incremented Version'
run: |
git config --local user.email "${{ secrets.GH_BOT_EMAIL }}"
git config --local user.name "${{ secrets.GH_BOT_NAME }}"
git add package.json
git commit -am "[🤖 release]: ${{ steps.version.outputs.result }} (${{ inputs.version }})"
git push origin HEAD --force
- name: '📝 Generate Release Notes (user-input)'
uses: toolmantim/release-drafter@v6
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
version: v${{ steps.version.outputs.result }}
publish: true
- name: Setup .yarnrc.yml
run: |
yarn config set npmScopes.joggr.npmRegistryServer "https://registry.npmjs.org"
yarn config set npmScopes.joggr.npmAlwaysAuth true
yarn config set npmScopes.joggr.npmAuthToken $NPM_AUTH_TOKEN
env:
NPM_AUTH_TOKEN: ${{ secrets.NPM_PUBLISH }}
- name: '🚢 Publish'
run: yarn npm publish --access public