-
Notifications
You must be signed in to change notification settings - Fork 7
159 lines (131 loc) · 4.58 KB
/
release-management.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
name: Release Management
on:
push:
branches: [ master ]
jobs:
test_and_build:
name: Test and build
runs-on: ubuntu-20.04
outputs:
version: ${{ steps.check_package_version.outputs.version }}
version_changed: ${{ steps.check_package_version.outputs.changed }}
steps:
- name: Clone repository
uses: actions/checkout@v4
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: 22
cache: npm
- name: Install
run: npm ci
- name: Lint
run: npm run lint
- name: Test
run: npm test
- name: Build
run: npm run build
- name: Check package.json for version change
id: check_package_version
uses: EndBug/version-check@v2
- name: Log when version changed
if: steps.check_package_version.outputs.changed == 'true'
run: 'echo "Version change found in commit ${{ steps.check_package_version.outputs.commit }}! New version: ${{ steps.check_package_version.outputs.version }} (${{ steps.check_package_version.outputs.type }})"'
- name: Log when version unchanged
if: steps.check_package_version.outputs.changed == 'false'
run: 'echo "No version change"'
update_release_draft:
name: Update release draft
permissions:
contents: write
needs: [test_and_build]
if: needs.test_and_build.outputs.version_changed == 'false'
runs-on: ubuntu-20.04
steps:
- name: Draft release on GitHub
uses: release-drafter/release-drafter@v6
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
publish_release_draft_on_version_bump:
name: Publish release draft
needs: [test_and_build]
if: needs.test_and_build.outputs.version_changed == 'true'
runs-on: ubuntu-20.04
steps:
- name: Clone repository
uses: actions/checkout@v4
# An existing release draft is published only if there is a version bump in `package.json`.
# Throws an error and breaks the job if called regardless. We check for version changes in the
# `test_and_build` job first so this job is skipped rather than exited with an error.
- name: Publish matching GitHub release draft
id: github_release
env:
GH_TOKEN: ${{ github.token }}
GH_REPO: ${{ github.repository }}
run: gh release edit "v${{ needs.test_and_build.outputs.version }}" --draft=false
- name: Write out the release URL
run: echo "Released at $RELEASE_URL"
env:
RELEASE_URL: ${{ steps.github_release.outputs.release_url }}
publish_package_to_npm:
name: Publish to npm
needs: [test_and_build, publish_release_draft_on_version_bump]
if: needs.test_and_build.outputs.version_changed == 'true'
runs-on: ubuntu-20.04
steps:
- name: Clone repository
uses: actions/checkout@v4
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: 22
cache: npm
registry-url: https://registry.npmjs.org
- name: Install
run: npm ci
- name: Publish to npm
run: npm publish
env:
NODE_AUTH_TOKEN: ${{secrets.NPM_PUBLISH_TOKEN}}
deploy_docs:
name: Deploy docs
permissions:
contents: write
needs: [test_and_build, publish_release_draft_on_version_bump]
if: needs.test_and_build.outputs.version_changed == 'true'
runs-on: ubuntu-20.04
steps:
- name: Clone repository
uses: actions/checkout@v4
# Hard-coded username and email for the GitHub bot user
# https://api.github.com/users/github-actions%5Bbot%5D
- name: Configure Git credentials
run: |
git config user.name github-actions[bot]
git config user.email 41898282+github-actions[bot]@users.noreply.github.com
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: 22
cache: npm
- name: Install
run: npm ci
- name: Build
run: npm run build
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: 3.x
- name: Get cache ID
run: echo "cache_id=$(date --utc '+%V')" >> $GITHUB_ENV
- name: Restore cache
uses: actions/cache@v4
with:
key: mkdocs-material-${{ env.cache_id }}
path: .cache
restore-keys: |
mkdocs-material-
- name: Install MkDocs
run: pip install 'mkdocs-material>=9.0.0,<10.0.0'
- name: Build and deploy MkDocs
run: mkdocs gh-deploy --force