-
Notifications
You must be signed in to change notification settings - Fork 18
99 lines (95 loc) · 3.25 KB
/
main.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
name: QA
on: [pull_request]
jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: pnpm/[email protected]
with:
version: 8.2.0
- uses: actions/setup-node@v3
with:
node-version: 18
cache: pnpm
- name: Install dependencies
run: pnpm install
- name: Check linters
run: pnpm lint
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: pnpm/[email protected]
with:
version: 8.2.0
- uses: actions/setup-node@v3
with:
node-version: 18
cache: "pnpm"
- name: Install dependencies
run: pnpm install
- name: Test
run: pnpm test:ci
- name: Generate coverage report
uses: irongut/[email protected]
if: ${{ github.actor != 'dependabot[bot]' }}
with:
filename: coverage/cobertura-coverage.xml
format: markdown
output: file
- name: Add Coverage PR Comment
uses: marocchino/sticky-pull-request-comment@v2
if: github.event_name == 'pull_request' && ${{ github.actor != 'dependabot[bot]' }}
with:
recreate: true
path: code-coverage-results.md
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: pnpm/[email protected]
- uses: actions/setup-node@v3
with:
node-version: 18
cache: pnpm
- uses: actions/cache@v3
with:
path: |
${{ github.workspace }}/.next/cache
key: ${{ runner.os }}-nextjs-${{ hashFiles('**/pnpm-lock.json') }}-${{ hashFiles('**.[jt]s', '**.[jt]sx') }}
# If source files changed but packages didn't, rebuild from a prior cache.
restore-keys: |
${{ runner.os }}-nextjs-${{ hashFiles('**/pnpm-lock.json') }}-
- name: Install dependencies
run: pnpm install
- name: Build project
run: pnpm build
- name: Creating .npmrc
if: ${{ github.actor != 'dependabot[bot]' }}
run: |
cat << EOF > "$HOME/.npmrc"
//registry.npmjs.org/:_authToken=$NPM_TOKEN
EOF
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Release on @dev tag in npm
if: ${{ github.actor != 'dependabot[bot]' }}
run: npx changeset version --snapshot pr && pnpm publish --tag dev --no-git-checks
# Store package.json version in env
- run: echo "PACKAGE_JSON=$(jq -c . < package.json)" >> $GITHUB_ENV
if: ${{ github.actor != 'dependabot[bot]' }}
- run: echo '${{ fromJson(env.PACKAGE_JSON).version }}'
if: ${{ github.actor != 'dependabot[bot]' }}
# Post a comment with released snapshot
- name: Create with released tag
if: ${{ github.actor != 'dependabot[bot]' }}
uses: peter-evans/create-or-update-comment@v2
with:
issue-number: ${{ github.event.pull_request.number }}
body: |
Released snapshot build with `@dev` tag in npm with version: `${{ fromJson(env.PACKAGE_JSON).version }}`
Install it with
```bash
pnpm add @saleor/app-sdk@${{ fromJson(env.PACKAGE_JSON).version }}
```