-
Notifications
You must be signed in to change notification settings - Fork 0
69 lines (54 loc) · 2.46 KB
/
release-base.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
name: Create Release
on:
workflow_dispatch:
inputs:
package-name:
type: string
description: Package name
required: true
version:
type: string
description: Package version
required: true
type:
type: string
description: Package type (api or sdk)
required: false
enum: [api, sdk]
jobs:
create-release:
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v4
- name: Create Release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
RELEASE_NAME="${{ inputs.package-name }}"
BASE_NAME="${RELEASE_NAME#@api-client-sdk-streamline-sample/}"
API_BASE="${BASE_NAME%-client}"
DISPLAY_NAME="$(echo "${API_BASE%%-*}" | awk '{print toupper(substr($0,1,1)) tolower(substr($0,2))}') API"
TAG_NAME="${BASE_NAME}-v${{ inputs.version }}"
SWAGGER_URL="https://app.swaggerhub.com/apis/junjie.wu/sample-${API_BASE}/${{ inputs.version }}"
if [[ "${{ inputs.type }}" == "api" ]]; then
NOTES="## ${{ inputs.package-name }} v${{ inputs.version }}
This API version is ready for:
- Pushing the OpenAPI specification to SwaggerHub
- Generating and publishing the client SDK package
After pushing to SwaggerHub, the API specification will be available at:
📄 [@api-client-sdk-streamline-sample | ${DISPLAY_NAME}](${SWAGGER_URL})
After generating and publishing the SDK, the NPM package will be available at:
📦 [@api-client-sdk-streamline-sample/${API_BASE}-client](https://www.npmjs.com/package/@api-client-sdk-streamline-sample/${API_BASE}-client)"
elif [[ "${{ inputs.type }}" == "sdk" ]]; then
NOTES="## ${{ inputs.package-name }} v${{ inputs.version }}
NPM Package:
📦 [${{ inputs.package-name }}](https://www.npmjs.com/package/${{ inputs.package-name }})
Generated from the corresponding OpenAPI specification:
📄 [@api-client-sdk-streamline-sample | ${DISPLAY_NAME}](${SWAGGER_URL})"
else
NOTES="## ${{ inputs.package-name }} v${{ inputs.version }}
fi
gh release create "$TAG_NAME" \
--title "${{ inputs.package-name }} v${{ inputs.version }}" \
--notes "$NOTES"