-
Notifications
You must be signed in to change notification settings - Fork 0
111 lines (94 loc) · 2.94 KB
/
ci.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
name: Continuous Integration
on:
push:
branches:
- '*'
tags:
- "v*.*.*"
pull_request:
branches:
- develop
concurrency:
group: ${{format('{0}:{1}', github.repository, github.ref)}}
cancel-in-progress: true
jobs:
build:
name: Build
runs-on: ubuntu-latest
steps:
- name: Clone repository
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 20
- name: Install dependencies
run: npm ci
- name: Tests
run: npm test
- name: Example
run: npm run example
publish-npm:
name: Publish NPM package
needs: [ build ]
runs-on: ubuntu-latest
if: ${{ github.event_name == 'push' && startsWith(github.ref, 'refs/tags/') }}
steps:
- name: Clone repository
uses: actions/checkout@v4
- name: Check version tags
run: |
GITHUB_TAGNAME=${{ github.ref_name }}
if [[ ! $GITHUB_TAGNAME =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "Tag name is not valid. It should match the pattern v*.*.*"
exit 1
fi
PACKAGE_JSON_VERSION=$(node -p "require('./package.json').version")
if [[ $GITHUB_TAGNAME != "v$PACKAGE_JSON_VERSION" ]]; then
echo "Tag name does not match package.json version"
exit 1
fi
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 20
registry-url: https://registry.npmjs.org/
- name: Install dependencies
run: npm ci
- name: Generate README.md
run: |
sudo apt install -y pandoc asciidoc-base
asciidoc -b docbook README.adoc
pandoc -f docbook -t markdown README.xml -o README.md --shift-heading-level-by=1 --standalone
rm README.xml
# Include the title as h1
title=$(sed -n 's/^title: \(.*\)/\1/p' README.md)
sed -i '/^---/,/^---/d' README.md
if [ -n "$title" ]; then
sed -i "1s/^/# $title\n\n/" README.md
fi
# Remove attributes from section names
# https://github.com/jgm/pandoc/issues/5965
sed -i -E 's/^(#+ .*?) \{#_[^}]+\}$/\1/' README.md
- name: Publish NPM package
run: npm publish --access public
env:
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
publish-github:
name: Publish Github Release
needs: [ build, publish-npm ]
runs-on: ubuntu-latest
if: ${{ github.event_name == 'push' && startsWith(github.ref, 'refs/tags/') }}
permissions:
contents: write
steps:
- name: Clone repository
uses: actions/checkout@v4
- name: Changelog
uses: alandefreitas/cpp-actions/create-changelog@v1.8.3
with:
thank-non-regular: true
- name: Release
uses: softprops/action-gh-release@v2
with:
body_path: CHANGELOG.md