-
Notifications
You must be signed in to change notification settings - Fork 2
145 lines (135 loc) · 4.64 KB
/
build.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
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
# This workflow will do a clean install of node dependencies, build the source code and run tests across different versions of node
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions
name: Build and Release
on:
push:
branches: [main]
tags:
- v* # Our tags are prefixed with 'v'
pull_request:
branches: [main]
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [19.x]
steps:
- uses: actions/checkout@v3
with:
lfs: true
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
- name: Setup cache for npm
id: npm_cache
uses: actions/cache@v3
with:
path: |
~/.npm
~/cache
!~/cache/exclude
**/node_modules
key: npm-${{ matrix.node-version }}-${{ hashFiles('**/package-lock.json') }}
- name: npm install
if: steps.npm_cache.outputs.cache-hit != 'true'
run: npm install-clean
- run: npm run test
deploy_site:
if: ${{ contains(github.ref, 'refs/tags') }}
needs: build
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [19.x]
steps:
- uses: actions/checkout@v3
with:
lfs: true
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
- name: Setup cache for npm
id: npm_cache
uses: actions/cache@v3
with:
path: |
~/.npm
~/cache
!~/cache/exclude
**/node_modules
key: npm-${{ matrix.node-version }}-${{ hashFiles('**/package-lock.json') }}
- name: npm install
if: steps.npm_cache.outputs.cache-hit != 'true'
run: npm install-clean
- run: ./scripts/dist
env:
SKIP_RELEASE_BUNLDE: true
- name: Deploy
uses: JamesIves/github-pages-deploy-action@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}
branch: gh-pages # The branch the action should deploy to.
folder: dist/site # The folder the action should deploy.
clean: true # Automatically remove deleted files from the deploy branch
publish:
if: ${{ contains(github.ref, 'refs/tags') }}
needs: build
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [19.x]
steps:
- uses: actions/checkout@v3
with:
lfs: true
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
registry-url: 'https://registry.npmjs.org'
- name: Setup cache for npm
id: npm_cache
uses: actions/cache@v3
with:
path: |
~/.npm
~/cache
!~/cache/exclude
**/node_modules
key: npm-${{ matrix.node-version }}-${{ hashFiles('**/package-lock.json') }}
- name: npm install
if: steps.npm_cache.outputs.cache-hit != 'true'
run: npm install --frozen-lockfile
- run: ./scripts/dist
- name: Publish to Node Packages
run: npm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }}
- name: Get current tag name
id: tag_name
uses: dawidd6/action-get-tag@v1
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token
with:
tag_name: ${{ steps.tag_name.outputs.tag }}
release_name: ${{ steps.tag_name.outputs.tag }}
body: |
Release ${{ steps.tag_name.outputs.tag }}
draft: false
prerelease: false
- name: Upload Release Asset
id: upload-release-asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps
asset_path: innoq-styleguide-${{ steps.tag_name.outputs.tag }}.zip
asset_name: innoq-styleguide-${{ steps.tag_name.outputs.tag }}.zip
asset_content_type: application/zip