-
Notifications
You must be signed in to change notification settings - Fork 0
135 lines (113 loc) · 3.64 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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
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:
strategy:
matrix:
include:
- { name: Windows, os: windows-latest }
- { name: Ubuntu, os: ubuntu-latest }
- { name: MacOS, os: macos-latest }
name: Build (${{ matrix.name }})
runs-on: ${{ matrix.os }}
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: Setup Ninja
if: runner.os == 'Windows'
uses: seanmiddleditch/gha-setup-ninja@v5
- name: Example
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
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}}
continue-on-error: true
- name: Print npm error log
if: failure()
run: |
# Find the latest npm debug log file and print its contents
LOG_FILE=$(ls -t /home/runner/.npm/_logs/*.log | head -n 1)
echo "Latest npm debug log file: $LOG_FILE"
cat $LOG_FILE
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/[email protected]
with:
thank-non-regular: true
- name: Release
uses: softprops/action-gh-release@v2
with:
body_path: CHANGELOG.md