generated from SAP/repository-template
-
Notifications
You must be signed in to change notification settings - Fork 11
140 lines (136 loc) · 5.61 KB
/
pipeline.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
name: CI/CD Pipeline
on:
push:
branches: [main]
pull_request:
branches: [main]
jobs:
build:
strategy:
matrix:
os: [ubuntu-latest, windows-latest]
node-version: [16.x, 18.x]
runs-on: ${{ matrix.os }}
timeout-minutes: 15
steps:
- name: Checkout code repository
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Setup pnpm
uses: pnpm/action-setup@v2.2.4
with:
run_install: true
- name: Cache pnpm modules
uses: actions/cache@v3
env:
cache-name: cache-pnpm-modules
with:
path: ~/.pnpm-store
key: ${{ matrix.os }}-build-${{ env.cache-name }}-${{ matrix.node-version }}-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ matrix.os }}-build-${{ env.cache-name }}-${{ matrix.node-version }}-
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
- name: Install pnpm modules
run: pnpm install
- name: Run build
run: pnpm run build
- name: Run linting
run: pnpm run lint
- name: Run unit tests
run: pnpm run test
- name: Run SonarCloud scan
if: matrix.os == 'ubuntu-latest' && matrix.node-version == '16.x'
uses: sonarsource/sonarcloud-github-action@master
env:
GITHUB_TOKEN: ${{ secrets.ACCESS_PAT }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
version:
# Run version job only on pushes to the main branch. The job depends on completion of the build job.
if: github.repository == 'SAP/open-ux-odata' && github.event_name == 'push' && github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
needs: build
outputs:
changes: ${{ steps.changesetVersion.outputs.changes }} # map step output to job output
steps:
- name: Checkout code repository
uses: actions/checkout@v3
with:
fetch-depth: 0
token: ${{ secrets.ACCESS_PAT }}
- name: Setup pnpm
uses: pnpm/action-setup@v2.2.4
with:
run_install: true
- name: Cache pnpm modules
uses: actions/cache@v3
env:
cache-name: cache-pnpm-modules
with:
path: ~/.pnpm-store
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-
- name: Use Node.js 16.x
uses: actions/setup-node@v3
with:
node-version: 16.x
- name: Install pnpm modules
run: pnpm install
- name: Apply changesets
id: changesetVersion
run: |
echo "changes=$(pnpm ci:version 2>&1 | grep -q 'No unreleased changesets found' && echo 'false' || echo 'true')" >> $GITHUB_OUTPUT
git status
- name: Commit and push changes
if: steps.changesetVersion.outputs.changes == 'true'
run: |
git config user.name github-actions
git config user.email github-actions@github.com
git status
git add -A
git status
git commit -m "chore: apply latest changesets" --no-verify || echo "No changesets found"
git log --pretty=oneline | head -n 10
git push
release:
# Run release job only on pushes to the main branch. The job depends on completion of the build job.
# This job needs to run after the version job commit has been merged - so check if that step returns 'false'
if: github.repository == 'SAP/open-ux-odata' && github.event_name == 'push' && github.ref == 'refs/heads/main' && needs.version.outputs.changes == 'false'
runs-on: ubuntu-latest
needs: version
steps:
- name: Checkout code repository
uses: actions/checkout@v3
- name: Setup pnpm
uses: pnpm/action-setup@v2.2.4
with:
run_install: true
- name: Cache pnpm modules
uses: actions/cache@v3
env:
cache-name: cache-pnpm-modules
with:
path: ~/.pnpm-store
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-
- name: Use Node.js 16.x
uses: actions/setup-node@v3
with:
node-version: 16.x
- name: Install pnpm modules
run: pnpm install
- name: Run build
run: pnpm run build
- name: Setup npmrc with npmjs.com token
run: echo "//registry.npmjs.org/:_authToken=${{ secrets.NPMJS_TOKEN }}" > .npmrc
- name: 'Publish to npmjs'
uses: changesets/action@v1.4.1
with:
publish: pnpm ci:publish
env:
GITHUB_TOKEN: ${{ secrets.ACCESS_PAT }}