-
Notifications
You must be signed in to change notification settings - Fork 2
58 lines (52 loc) · 1.63 KB
/
publish.yaml
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
name: Publish
on:
push:
tags:
- "v*"
jobs:
build:
strategy:
matrix:
os: [ubuntu-latest]
node-version: [20.x, 22.x]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- name: install pnpm
run: npm install -g pnpm
- run: pnpm install --frozen-lockfile
- run: pnpm build
if: matrix.os == 'ubuntu-latest'
- run: pnpm test
if: matrix.os == 'ubuntu-latest'
- run: npm test
publish-npm:
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
with:
node-version: 20
registry-url: https://registry.npmjs.org/
- name: install pnpm
run: npm install -g pnpm
- name: Set VERSION variable from tag
run: echo "VERSION=${GITHUB_REF/refs\/tags\/v/}" >> $GITHUB_ENV
- name: Print version
run: echo $VERSION
- name: Verify commit exists in origin/main
run: |
git fetch --no-tags --prune --depth=1 origin +refs/heads/*:refs/remotes/origin/*
git branch --remote --contains | grep origin/main
- name: Verify that the version exists in package.json
run: 'sudo apt-get install -y jq && [[ "$(jq -r ".version" package.json)" == "$VERSION" ]]'
- run: pnpm install --frozen-lockfile
- run: pnpm build
- run: npm publish --access=public
env:
NODE_AUTH_TOKEN: "${{secrets.NPM_AUTH_TOKEN}}"