-
Notifications
You must be signed in to change notification settings - Fork 85
139 lines (115 loc) · 4.16 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
#
# Copyright 2022 The Dapr Authors
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# http://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
name: Build
on:
push:
branches:
- main
- release-*
tags:
- v*
pull_request:
branches:
- main
- release-*
# Manual trigger
workflow_dispatch: {}
env:
NODE_VER: 16.14.0
jobs:
build:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
node_version: [16.14.0]
steps:
- uses: actions/checkout@v3
- name: Setup Node ${{ matrix.node_version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node_version }}
- name: Build package (install dependencies, lint, prettier, build)
run: npm run build
# @TODO: add a depend on the test-e2e pipeline?
- name: Run unit tests
id: tests
run: npm run test:unit:all
- name: Upload test coverage
uses: codecov/codecov-action@v1
publish:
needs: build
if: startswith(github.ref, 'refs/tags/v')
runs-on: ubuntu-latest
environment: production
steps:
- uses: actions/checkout@v3
- name: Setup Node ${{ env.NODE_VER }}
uses: actions/setup-node@v3
with:
node-version: ${{ env.NODE_VER }}
registry-url: "https://registry.npmjs.org"
- name: Install dependencies
run: npm install
- name: Build package
run: npm run build-ci
- name: Publish to npm (@dapr/dapr)
run: npm publish build/ --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
# dapr-client is deprecated, but we still want to publish it for a while.
- name: "[dapr-client] Configure to publish to dapr-client for deprecation notice reasons"
run: |
sed -i s#"@dapr/dapr"#"dapr-client"# package.json
echo "This has been deprecated and will not be updated anymore, please use https://www.npmjs.com/package/@dapr/dapr" > README.md
- name: "[dapr-client] Install dependencies"
run: npm install
- name: "[dapr-client] Build Package"
run: npm run build-ci
- name: "[dapr-client] Publish to npm (dapr-client)"
run: npm publish build/ --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
publish-dev:
needs: build
if: startsWith(github.ref, 'refs/heads/main')
runs-on: ubuntu-latest
environment: development
steps:
- uses: actions/checkout@v3
- name: Setup Node ${{ env.NODE_VER }}
uses: actions/setup-node@v3
with:
node-version: ${{ env.NODE_VER }}
registry-url: "https://registry.npmjs.org"
- name: Configure package name
run: |
sed -i s#"@dapr/dapr"#"@dapr/dapr-dev"# package.json
cat <(echo "WARNING: This is a development version of the SDK. It is not recommended to use this version in production.\n") README.md > README.md.tmp
mv README.md.tmp README.md
- name: Configure version
run: |
# Version should be in the format of <version>-<timestamp>-<commit-hash>
# e.g. 1.0.0-20220101000000-abcdef
VERSION=$(npm version | grep '@dapr/dapr' | awk -F':' '{print $2}' | tr -d "[:space:],'")
TIMESTAMP=$(date -u +"%Y%m%d%H%M%S")
COMMIT_HASH=$(git rev-parse --short HEAD)
sed -i s#"\"version\": \"$VERSION\""#"\"version\": \"$VERSION-$TIMESTAMP-$COMMIT_HASH\""# package.json
- name: Install dependencies
run: npm install
- name: Build package
run: npm run build-ci
- name: Publish to npm (@dapr/dapr-dev)
run: npm publish build/ --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}