mirror of
https://github.com/stoatchat/javascript-client-api.git
synced 2026-07-17 23:54:25 -04:00
87 lines
2.7 KiB
YAML
87 lines
2.7 KiB
YAML
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 }}"
|