-
Notifications
You must be signed in to change notification settings - Fork 1
163 lines (141 loc) · 6.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
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
# Build and publish the documentation as well as the package to NPM and version bump each time a new release is published on Github, or a push is made to the develop branch.
name: Build
on:
push:
branches: [develop]
paths-ignore:
- '*.md'
- '**/*.md'
- 'package.json'
- 'package-lock.json'
release:
types:
- published
permissions: write-all
env:
DOCS_BASE_PATH: docs/omni-widget
LOCAL_VERSION:
jobs:
build-and-release:
concurrency:
group: ${{ github.ref }}
cancel-in-progress: true
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [16.x]
steps:
- name: Checkout 🛎️
uses: actions/checkout@v3
with:
persist-credentials: true
fetch-depth: 0
token: ${{ secrets.PROTECTED_TOKEN }}
- name: Ensure branch up to date 🌿
# Only on branch pushes, not on tagged releases
if: ${{ startsWith(github.ref, 'refs/heads/') }}
run: |
git pull
- name: Use Node.js 16.x ✔
uses: actions/setup-node@v3
with:
node-version: 16.x
registry-url: 'https://registry.npmjs.org'
always-auth: true
- name: Install Package Dependencies 🔗
run: |
npm ci
- name: Build Project 🔧
run: npm run build
- name: Bump patch version for beta ☝
# Develop branch only
if: github.ref == 'refs/heads/develop'
run: |
node scripts/unique-version.mjs --tag "beta"
- name: Build Docs 📝
run: |
npm run docs
- name: Auto Commit Changes 👩💻
uses: stefanzweifel/git-auto-commit-action@v4
# Only on branch pushes, not on tagged releases
if: ${{ startsWith(github.ref, 'refs/heads/') }}
with:
commit_message: Updated docs
branch: ${{ env.GITHUB_REF_NAME }}
- name: Auto Commit Changes 👩💻
uses: stefanzweifel/git-auto-commit-action@v4
# Tagged release branch only
if: ${{ startsWith(github.ref, 'refs/tags/') }}
with:
commit_message: Updated docs
branch: main
push_options: '--force'
- name: Publish Beta Docs 🚀
uses: JamesIves/github-pages-deploy-action@v4.3.4
# Develop branch only
if: github.ref == 'refs/heads/develop'
with:
token: ${{ secrets.ACCESS_TOKEN }}
repository-name: capitec/open-source
branch: main
folder: docs/api # The folder to grab the built docs files from
target-folder: ${{ env.DOCS_BASE_PATH }}/versions/beta # The folder to commit the build docs files into
clean: true # Clean out any previous files in the target folder
clean-exclude: |
versions
git-config-name: Deploy Bot
git-config-email: opensource@capitecbank.co.za
- name: Publish Version Docs 🚀
uses: JamesIves/github-pages-deploy-action@v4.3.4
# Tagged release branch only
if: ${{ startsWith(github.ref, 'refs/tags/') }}
with:
token: ${{ secrets.ACCESS_TOKEN }}
repository-name: capitec/open-source
branch: main
folder: docs/api # The folder to grab the built docs files from
target-folder: ${{ env.DOCS_BASE_PATH }}/versions/${{ github.event.release.tag_name }} # The folder to commit the build docs files into
clean: true
clean-exclude: |
versions
git-config-name: Deploy Bot
git-config-email: opensource@capitecbank.co.za
- name: Publish Latest Docs 🚀
uses: JamesIves/github-pages-deploy-action@v4.3.4
# Release only
if: ${{ startsWith(github.ref, 'refs/tags/') }}
with:
token: ${{ secrets.ACCESS_TOKEN }}
repository-name: capitec/open-source
branch: main
folder: docs/api # The folder to grab the built docs files from
target-folder: ${{ env.DOCS_BASE_PATH }} # The folder to commit the build docs files into
clean:
true
# Dont clean the versions directory when deploying to latest docs path
clean-exclude: |
versions
git-config-name: Deploy Bot
git-config-email: opensource@capitecbank.co.za
- name: Update LOCAL_VERSION ⬆
# Branches only, not releases
if: ${{ startsWith(github.ref, 'refs/heads/') }}
run: |
LOCAL_VERSION=$(cat package.json | jq -r .version | awk '{ print tolower($1) }')
echo LOCAL_VERSION=${LOCAL_VERSION} >> $GITHUB_ENV
- name: Publish Latest Package 📦
# Release only
if: ${{ startsWith(github.ref, 'refs/tags/') }}
run: |
npm version "${{ github.event.release.tag_name }}" -git-tag-version false -allow-same-version true
npm publish --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Publish Beta Package 📦
# Develop branch only
if: github.ref == 'refs/heads/develop'
run: |
npm version "${{ env.LOCAL_VERSION }}-beta" -git-tag-version false -allow-same-version true
npm publish --tag beta --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}