Skip to content

Commit ce0bf4d

Browse files
committed
ci: add GitHub Actions workflow for tests and npm publish
- Mirror api-type-document: test on Ubuntu + Windows, release on main/master - Requires NPM_TOKEN repo secret for publish Made-with: Cursor
1 parent 0c8e04e commit ce0bf4d

1 file changed

Lines changed: 89 additions & 0 deletions

File tree

.github/workflows/deployment.yml

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
# Aligned with advanced-rest-client/api-type-document — tests + npm publish + GitHub Release on main/master.
2+
# Repo secret required: NPM_TOKEN (npm granular token with publish for @api-components).
3+
name: Tests and publishing
4+
env:
5+
FORCE_COLOR: 1
6+
on:
7+
push:
8+
branches:
9+
- master
10+
- main
11+
- develop
12+
pull_request:
13+
branches:
14+
- master
15+
- main
16+
jobs:
17+
test_linux:
18+
name: ${{ matrix.os }}
19+
strategy:
20+
fail-fast: false
21+
matrix:
22+
os: [ubuntu-22.04]
23+
runs-on: ${{ matrix.os }}
24+
steps:
25+
- uses: actions/checkout@v4
26+
- uses: actions/setup-node@v4
27+
with:
28+
node-version: 20
29+
cache: npm
30+
- name: Install dependencies
31+
run: npm ci
32+
- name: Run tests
33+
run: npm test
34+
35+
test_win:
36+
name: Windows
37+
runs-on: windows-latest
38+
steps:
39+
- uses: actions/checkout@v4
40+
- uses: actions/setup-node@v4
41+
with:
42+
node-version: 20
43+
cache: npm
44+
- name: Install dependencies
45+
run: npm ci
46+
- name: Run tests
47+
run: npm test
48+
49+
tag:
50+
name: Publishing release
51+
if: github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master'
52+
needs:
53+
- test_linux
54+
- test_win
55+
runs-on: ubuntu-latest
56+
permissions:
57+
contents: write
58+
steps:
59+
- name: Checkout code
60+
uses: actions/checkout@v4
61+
with:
62+
fetch-depth: 0
63+
- uses: actions/setup-node@v4
64+
with:
65+
node-version: 20
66+
registry-url: https://registry.npmjs.org
67+
cache: npm
68+
- run: npm ci
69+
- name: Read version from package.json
70+
uses: culshaw/read-package-node-version-actions@v1
71+
id: package-node-version
72+
- name: Changelog
73+
uses: scottbrenner/generate-changelog-action@master
74+
id: Changelog
75+
- name: GitHub Release
76+
uses: softprops/action-gh-release@v2
77+
with:
78+
tag_name: v${{ steps.package-node-version.outputs.version }}
79+
name: v${{ steps.package-node-version.outputs.version }}
80+
body: |
81+
${{ steps.Changelog.outputs.changelog }}
82+
draft: false
83+
prerelease: false
84+
env:
85+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
86+
- name: Publish to npm
87+
run: npm publish --access public
88+
env:
89+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

0 commit comments

Comments
 (0)