generated from jsynowiec/node-typescript-boilerplate
-
Notifications
You must be signed in to change notification settings - Fork 1
159 lines (132 loc) · 4.64 KB
/
build.yml
File metadata and controls
159 lines (132 loc) · 4.64 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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
on:
push:
branches:
- master
- staging
- develop
name: Continuous integration
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- run: git fetch --all --tags
- name: Setup nodejs
uses: actions/setup-node@v1
with:
node-version: '12.x'
- name: Check Release Version
uses: thebongy/version-check@v1
with:
file: package.json
failBuild: false
id: version_check
- name: Bump package.json version (staging)
if: github.ref == 'refs/heads/staging'
run: npm -no-git-tag-version version v${{ steps.version_check.outputs.rawVersion }}-beta
- name: Install dependencies
run: npm ci
- name: Linting and Test
run: npm run test:prod
- name: Run Build
run: npm run build
- name: Create tarball
run: |
npm pack
- name: Rename tar (staging)
if: github.ref == 'refs/heads/staging'
run: mv *.tgz juno-node-${{ steps.version_check.outputs.rawVersion }}.tgz
- name: Upload Artifact
uses: actions/upload-artifact@v2
with:
name: juno-node-${{ steps.version_check.outputs.rawVersion }}
path: ./juno-node-${{ steps.version_check.outputs.rawVersion }}.tgz
# Publish release on push to master
release-master:
if: github.ref == 'refs/heads/master'
runs-on: ubuntu-latest
needs: build
steps:
- uses: actions/checkout@v2
- run: git fetch --all --tags
- name: Check Release Version
id: version_check
uses: thebongy/version-check@v1
with:
file: package.json
tagFormat: v${version}
- name: Setup nodejs
uses: actions/setup-node@v1
with:
node-version: '12.x'
registry-url: 'https://registry.npmjs.org'
- name: Publish Release
id: create_release
uses: actions/create-release@latest
with:
tag_name: ${{ steps.version_check.outputs.releaseVersion }}
release_name: ${{ steps.version_check.outputs.releaseVersion }}
prerelease: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Download Artifact
uses: actions/download-artifact@v2
with:
name: juno-node-${{ steps.version_check.outputs.rawVersion }}
- name: Upload Release Asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: juno-node-${{ steps.version_check.outputs.rawVersion }}.tgz
asset_name: juno-node-${{ steps.version_check.outputs.releaseVersion }}.tgz
asset_content_type: application/tgz
- name: Publish to npm
run: npm publish juno-node-${{ steps.version_check.outputs.rawVersion }}.tgz
env:
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
release-staging:
if: github.ref == 'refs/heads/staging'
runs-on: ubuntu-latest
needs: build
steps:
- uses: actions/checkout@v2
- run: git fetch --all --tags
- name: Check Release Version
id: version_check
uses: thebongy/version-check@v1
with:
file: package.json
tagFormat: v${version}-beta
- name: Setup nodejs
uses: actions/setup-node@v1
with:
node-version: '12.x'
registry-url: 'https://registry.npmjs.org'
- name: Download Artifact
uses: actions/download-artifact@v2
with:
name: juno-node-${{ steps.version_check.outputs.rawVersion }}
- name: Publish Release
id: create_release
uses: actions/create-release@latest
with:
tag_name: ${{ steps.version_check.outputs.releaseVersion }}
release_name: ${{ steps.version_check.outputs.releaseVersion }}
prerelease: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Upload Release Asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: juno-node-${{ steps.version_check.outputs.rawVersion }}.tgz
asset_name: juno-node-${{ steps.version_check.outputs.releaseVersion }}.tgz
asset_content_type: application/gzip
- name: Publish to npm
run: npm publish juno-node-${{ steps.version_check.outputs.rawVersion }}.tgz --tag beta
env:
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}