-
Notifications
You must be signed in to change notification settings - Fork 0
100 lines (80 loc) · 2.53 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
name: Build
on: [ push, pull_request, release, workflow_dispatch ]
env:
YARN_NPM_AUTH_TOKEN: ${{ secrets.NPM_GALC_UI_PUBLISH_TOKEN }}
jobs:
debug:
runs-on: ubuntu-latest
steps:
- name: Dump GitHub context
env:
GITHUB_CONTEXT: ${{ toJson(github) }}
run: echo "${GITHUB_CONTEXT}"
build:
runs-on: ubuntu-latest
# We need to build in order to publish, but we don't want to build on other release events
if: github.event_name != 'release' || github.event.action == 'created'
steps:
- name: Check out repository
uses: actions/checkout@v3
- name: Cache node modules
uses: actions/cache@v3
with:
path: ~/node_modules
key: cache-${{ hashFiles('**/yarn.lock') }}
- name: Install dependencies
run: yarn install
- name: Check style
run: yarn lint
- name: Run tests w/coverage
run: yarn coverage
- name: Build
run: yarn build
- name: Upload distribution
if: ${{ always() }}
uses: actions/upload-artifact@v3
with:
name: dist
path: dist/**
- name: Upload artifacts
if: ${{ always() }}
uses: actions/upload-artifact@v3
with:
name: artifacts
path: artifacts/**
# TODO: stop hard-coding ref_name and package-name
publish-snapshot:
needs: build
runs-on: ubuntu-latest
if: github.ref_name == 'main' && github.event_name == 'push'
steps:
- name: Check out repository
uses: actions/checkout@v3
- name: Download distribution
uses: actions/download-artifact@v3
with:
name: dist
path: dist
- name: Publish latest snapshot
if: github.event_name == 'push'
run: |
yarn version 0.0.0-"${GITHUB_SHA:0:7}" --immediate
yarn npm publish --access public --tag snapshot
publish-release:
needs: build
runs-on: ubuntu-latest
if: github.event_name == 'release' && github.event.action == 'created'
steps:
- name: Check out repository
uses: actions/checkout@v3
- name: Download distribution
uses: actions/download-artifact@v3
with:
name: dist
path: dist
- name: Publish release package
# NOTE: Assumes tag in form x.y.z
# TODO: figure out why ${{github.event.release.tag_name}} doesn't work
run: |
yarn version "${github.ref_name}" --immediate
yarn npm publish --access public --tag latest