Repository navigation
86 lines (74 loc) · 2.72 KB
/
Copy pathbuild_and_publish.yml
File metadata and controls
86 lines (74 loc) · 2.72 KB
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
name: Build and Publish API
on:
push:
branches:
- main
jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: write
id-token: write
packages: write
steps:
- name: Checkout repository
uses: actions/checkout@v5
- uses: pnpm/action-setup@v4
- name: Use Node.js LTS
uses: actions/setup-node@v5
with:
node-version: 22.x
registry-url: "https://registry.npmjs.org"
cache: "pnpm"
- name: Install packages
run: pnpm install
- name: Build package
run: pnpm build
- name: Commit changes
uses: EndBug/add-and-commit@v9
with:
author_name: Stoat CI
author_email: stoat-ci@users.noreply.github.com
message: "chore: build library from latest spec [skip ci]"
- name: Find current API version
id: check-api
run: echo "api-version=$(jq -r .info.version OpenAPI.json)" >> $GITHUB_OUTPUT
- name: Check if tag exists for current version
uses: mukunku/tag-exists-action@v1.6.0
id: check-tag
with:
tag: ${{ steps.check-api.outputs.api-version }}
- name: Update version in package.json
if: steps.check-tag.outputs.exists == 'false'
run: |
jq '.version="${{ steps.check-api.outputs.api-version }}"' package.json > temp.json
mv temp.json package.json
- name: Commit changes
if: steps.check-tag.outputs.exists == 'false'
uses: EndBug/add-and-commit@v9
with:
author_name: Stoat CI
author_email: stoat-ci@users.noreply.github.com
tag: "${{ steps.check-api.outputs.api-version }} --force"
message: "chore: bump version to ${{ steps.check-api.outputs.api-version }} [skip ci]"
- name: Publish to npm
run: pnpm publish --access public --provenance --no-git-checks
if: steps.check-tag.outputs.exists == 'false'
- name: Checkout stoat.js repository
if: steps.check-tag.outputs.exists == 'false'
uses: actions/checkout@v3
with:
repository: stoatchat/javascript-client-sdk
path: stoat.js
token: ${{ secrets.GITHUB_TOKEN }}
- name: Update stoat-api dependency
if: steps.check-tag.outputs.exists == 'false'
run: cd stoat.js && pnpm add stoat-api@${{ steps.check-api.outputs.api-version }}
- name: Commit changes
if: steps.check-tag.outputs.exists == 'false'
uses: EndBug/add-and-commit@v4
with:
cwd: "stoat.js"
author_name: Stoat CI
author_email: stoat-ci@users.noreply.github.com
message: "chore: update stoat-api to ${{ steps.check-api.outputs.api-version }}"