Create Release #39
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" |