-
Notifications
You must be signed in to change notification settings - Fork 629
89 lines (81 loc) · 2.72 KB
/
build-test-and-deploy.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
name: facebook/metro/build-test-and-deploy
on:
workflow_call:
pull_request:
types: [opened, synchronize]
push:
tags:
# The job is triggered for any tag push. Tag format validation will be done
# as part of the deploy job for clearer error reporting on tag formatting
- '**'
# head_ref is per PR, so this ensures that updating the latest PR commit
# will cancel the previous run of the workflow and trigger a new one
concurrency:
group: "build-test-and-deploy-${{ github.head_ref }}"
cancel-in-progress: true
defaults:
run:
shell: bash
jobs:
# run-js-checks:
# runs-on: ubuntu-latest
# name: "Typescript, Lint, Smoke Test"
# steps:
# - uses: actions/checkout@v4
# - uses: ./.github/actions/yarn-install
# - run: yarn typecheck
# - run: yarn typecheck-ts
# - run: yarn lint
# - run: yarn test-smoke
# test-with-coverage:
# runs-on: ubuntu-latest
# name: "Test Coverage Calculation"
# steps:
# - uses: actions/checkout@v4
# - uses: ./.github/actions/yarn-install
# - run: yarn test-coverage
# - run: "./.github/scripts/install_codecov.sh"
# - run: "./codecov -t ${{ secrets.CODECOV_TOKEN }} -f ./coverage/coverage-final.json"
# test:
# strategy:
# matrix:
# runs-on: ['ubuntu-latest'] # 'windows-latest'
# node-version-type: ['lts', 'min-supported']
# name: "Tests [${{ matrix.runs-on }} machine, ${{ matrix.node-version-type }} Node.js]"
# runs-on: ${{ matrix.runs-on }}
# steps:
# - uses: actions/checkout@v4
# - uses: ./.github/actions/yarn-install
# with:
# node-version-type: ${{ matrix.node-version-type }}
# - name: Run Jest Tests
# run: yarn jest --ci --maxWorkers 4 --reporters=default --reporters=jest-junit --rootdir='./'
validate-tag:
# runs only on tag pushes
if: ${{ github.ref_type == 'tag' }}
runs-on: ubuntu-latest
name: "Validate Tag For Deployment"
steps:
- uses: actions/github-script@v7
with:
script: |
if (/^v\d+(\.\d+){2}(-.*)?$/.test('${{ github.ref_name }}')) {
return true;
} else {
core.setFailed('ERROR! Wrong tag format failed the package deployment!');
}
deploy:
# runs only on tag pushes
if: ${{ github.ref_type == 'tag' }}
runs-on: ubuntu-latest
name: "Deploy"
# needs: [run-js-checks, test, validate-tag]
needs: [validate-tag]
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/yarn-install
- run: echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}" >> ~/.npmrc
- run: "./.github/scripts/publish.sh"
env:
RAW_TAG_NAME: ${{ github.ref_name }}
- run: rm ~/.npmrc