-
Notifications
You must be signed in to change notification settings - Fork 0
109 lines (83 loc) · 2.42 KB
/
commit-workflow.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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
name: Commit Workflow
on:
push:
branches: ['main']
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [18.x]
outputs:
tag: ${{ steps.get_version.outputs.tag }}
preview: ${{ steps.get_preview.outputs.preview }}
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
- run: npm install
- run: |
npm run lint
npm run format
- name: Build the package
run: npm run build
- name: Archive project folder
uses: actions/upload-artifact@v4
with:
name: dist-folder
path: ./dist
- id: get_version
run: |
version=$(node -p 'require("./package.json").version')
echo "::set-output name=tag::$version"
- id: get_preview
run: |
preview=$(node -p 'require("./package.json").preview ? "true" : "false"')
echo "::set-output name=preview::$preview"
publish-dev:
needs: build
runs-on: ubuntu-latest
if: needs.build.outputs.preview == 'true'
steps:
- uses: actions/checkout@v3
- name: Download artifact
uses: actions/download-artifact@v4
with:
name: dist-folder
path: dist
- run: ls
- name: Publish to NPM (Dev Version)
run: |
echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}" > ~/.npmrc
npm publish --tag=dev
publish-prod:
needs: build
runs-on: ubuntu-latest
if: needs.build.outputs.preview != 'true'
steps:
- uses: actions/checkout@v3
- name: Download artifact
uses: actions/download-artifact@v4
with:
name: dist-folder
path: dist
- run: ls
- name: Publish to NPM (Prod Version)
run: |
echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}" > ~/.npmrc
npm publish
release:
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: v${{ needs.build.outputs.tag }}
release_name: Release v${{ needs.build.outputs.tag }}
body: |
Release v${{ needs.build.outputs.tag }}
draft: false
prerelease: ${{ needs.build.outputs.preview == 'true' }}