-
Notifications
You must be signed in to change notification settings - Fork 0
71 lines (68 loc) · 2.42 KB
/
generate.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
59
60
61
62
63
64
65
66
67
68
69
70
71
name: Generate SDK
on:
workflow_dispatch:
inputs:
version:
description: The SDK version to generate as "X.Y.Z".
default: "X.Y.Z"
required: true
type: string
openapi-generator-version:
description: The openapi-generator version to use. '' for the version used during the last generation, 'latest' for latest, 'x.y.z' for version x.y.z.
default: "latest"
required: true
type: string
env:
# Go / Node / PostgreSQL version to use in the CI
NODE_VER: "18"
jobs:
generate:
name: Generate SDK
runs-on: ubuntu-22.04
timeout-minutes: 10
env:
OPENAPI_GENERATOR_VERSION: "${{ github.event.inputs.openapi-generator-version }}"
permissions:
contents: write
steps:
- name: Check Tag
id: check-tag
run: |
if ! [[ ${{ github.event.inputs.version }} =~ ^[0-9]+\.[0-9]+\.[0-9]+(-.+)?$ ]]; then
echo "::error ::The provided version has incorrect format: it should match '[0-9]+\.[0-9]+\.[0-9]+(-.+)?'" 1>&2
exit 1
fi
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: "${{ env.NODE_VER }}"
registry-url: https://registry.npmjs.org/
- name: Generate SDK to check for changes
run: ./generate.sh
- name: Check for changes
run: |
if ! git status --porcelain=v1 | grep -v -e openapitools.json -e .openapi-generator/VERSION | tee /dev/stderr | [ $(wc -l) -ne 0 ]; then
echo "::error ::No changes to the Multibaas APIv0 specifications detected." 1>&2
exit 1
fi
- name: Generate SDK with new package version
run: ./generate.sh ${{ github.event.inputs.version }}
- name: Setup Git Configurations
run: |
git config --global user.name "GitHub Actions Bot"
git config --global user.email "<>"
- name: Push if there are changes
run: |
git add .
git commit -am "Auto-generated SDK v${{ github.event.inputs.version }}"
git tag "v${{ github.event.inputs.version }}" main
git push origin "v${{ github.event.inputs.version }}"
git push origin main
- name: Publish
env:
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
run: npm publish --access public