-
Notifications
You must be signed in to change notification settings - Fork 26
76 lines (71 loc) · 2.5 KB
/
build_and_publish.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
name: Build and Publish API
on:
push:
branches: [main]
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Use Node.js 18
uses: actions/setup-node@v3
with:
node-version: 18.x
cache: "yarn"
- uses: pnpm/[email protected]
with:
version: 7
- name: Install packages
run: yarn install
- name: Build package
run: yarn build
- name: Commit changes
uses: EndBug/add-and-commit@v9
with:
author_name: Revolt CI
author_email: [email protected]
message: "chore: build library from latest spec [skip ci]"
- name: Find current API version
run: echo "api_version=$(jq -r .info.version OpenAPI.json)" >> $GITHUB_ENV
- name: Check if tag exists for current version
uses: mukunku/[email protected]
id: checkTag
with:
tag: ${{ env.api_version }}
- name: Update version in package.json
if: ${{ steps.checkTag.outputs.exists }} != true
run: |
jq '.version="${{ env.api_version }}"' package.json > temp.json
mv temp.json package.json
- name: Commit changes
if: ${{ steps.checkTag.outputs.exists }} != true
uses: EndBug/add-and-commit@v9
with:
author_name: Revolt CI
author_email: [email protected]
tag: "${{ env.api_version }} --force"
message: "chore: bump version to ${{ env.api_version }} [skip ci]"
- name: Publish to NPM
if: ${{ steps.checkTag.outputs.exists }} != true
uses: JS-DevTools/npm-publish@v1
with:
token: ${{ secrets.NPM_TOKEN }}
- name: Checkout revolt.js repository
if: ${{ steps.checkTag.outputs.exists }} != true
uses: actions/checkout@v3
with:
repository: revoltchat/revolt.js
path: revolt.js
token: ${{ secrets.PAT }}
- name: Update revolt-api dependency
if: ${{ steps.checkTag.outputs.exists }} != true
run: cd revolt.js && pnpm add revolt-api@${{ env.api_version }}
- name: Commit changes
if: ${{ steps.checkTag.outputs.exists }} != true
uses: EndBug/add-and-commit@v4
with:
cwd: "revolt.js"
author_name: Revolt CI
author_email: [email protected]
message: "chore: update revolt-api to ${{ env.api_version }}"