-
Notifications
You must be signed in to change notification settings - Fork 0
85 lines (78 loc) · 2.66 KB
/
bump_version_and_publish.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
name: Bump version & publish
on:
workflow_dispatch:
inputs:
package:
description: 'Select package'
required: true
type: choice
options:
- 'channels'
- 'use-channels'
version:
description: 'Semver type of new version'
required: true
type: choice
options:
- major
- minor
- patch
dryrun:
description: 'Dry run (will not publish and tag)'
required: false
type: boolean
jobs:
bump-version:
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write
steps:
- name: Check out source
uses: actions/checkout@v3
with:
ssh-key: ${{secrets.DEPLOY_KEY}}
- name: Setup node
uses: actions/setup-node@v3
with:
node-version-file: '.nvmrc'
- name: Install npm packages
run: npm ci
- name: build (for testing)
if: ${{ github.event.inputs.package == 'use-channels' }}
run: npm run build -w packages/channels
- name: Run tests
run: |
cd packages/${{ github.event.inputs.package }}
npm run test
- name: Build
run: |
cd packages/${{ github.event.inputs.package }}
npm run build
- name: Setup Git
run: |
git config user.name github-actions
git config user.email github-actions@github.com
- name: bump version
run: |
echo "1. cd packages/${{ github.event.inputs.package }}"
cd packages/${{ github.event.inputs.package }}
echo "2. npm version ${{ github.event.inputs.version }}"
npm version ${{ github.event.inputs.version }} --no-git-tag-version
version=$(npm pkg get version | tr -d '{}' | tr -d '"' | awk -F ': ' '{ print $2 }' | tr -d '\n')
echo "3. git add"
git add .
echo "4. git commit -m ${{ github.event.inputs.package }} v$version"
git commit -m "${{ github.event.inputs.package }} v$version"
echo "5. git tag ${{ github.event.inputs.package }}@$version"
git tag ${{ github.event.inputs.package }}@$version
- name: Push latest version
if: ${{ github.event.inputs.dryrun == 'false' }}
run: git push origin main --tags
- name: publish
if: ${{ github.event.inputs.dryrun == 'false' }}
run: |
npm config set //registry.npmjs.org/:_authToken ${NPM_TOKEN}
npm publish --workspace=packages/${{ github.event.inputs.package }} --provenance
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}