Skip to content

Generate client library + Publish 📦 to PyPI + Publish to GitHub Releases #23

Generate client library + Publish 📦 to PyPI + Publish to GitHub Releases

Generate client library + Publish 📦 to PyPI + Publish to GitHub Releases #23

Workflow file for this run

name: Generate client library + Publish 📦 to PyPI + Publish to GitHub Releases
on:
workflow_dispatch:
inputs:
version:
required: true
defaults:
run:
shell: bash
permissions:
contents: read
id-token: write
env:
GENERATOR_VERSION: 3.0.54
GENERATOR_NAME: swagger-codegen-cli.jar
JAR_ASANA: codegen/swagger/target/AsanaClientCodegen-swagger-codegen-1.0.0.jar
ACTUAL_LANG: com.asana.codegen.PythonClientCodegenGenerator
NAME: asana
jobs:
generate-python-library:
name: Generate Python client library
runs-on: ubuntu-latest
steps:
- name: Authenticate to AWS
uses: aws-actions/configure-aws-credentials@v4
with:
aws-region: us-east-1
role-to-assume: arn:aws:iam::403483446840:role/autogen_role_beta_github_actions_release_asana_client_libraries
- name: Get GitHub app token
uses: asana/get-github-app-token@v1
id: get-token
with:
github-app-name: asana-publish-client-libraries
- name: Checkout repo files and set the git token
uses: actions/checkout@v4
with:
token: ${{ steps.get-token.outputs.app-token }}
- uses: actions/setup-java@v4
with:
distribution: "temurin"
java-version: "17"
- name: Download generator
run: |
wget -q -O $GENERATOR_NAME https://repo1.maven.org/maven2/io/swagger/codegen/v3/swagger-codegen-cli/${{ env.GENERATOR_VERSION }}/swagger-codegen-cli-${{ env.GENERATOR_VERSION }}.jar
- name: Build custom code
run: |
pushd codegen/swagger >/dev/null
mvn package
popd >/dev/null
- name: Generate library
run: >-
java -cp "${{ env.JAR_ASANA }}:${{ env.GENERATOR_NAME }}"
io.swagger.codegen.v3.cli.SwaggerCodegen
generate
--input-spec https://raw.githubusercontent.com/Asana/openapi/master/defs/asana_sdk_oas.yaml
--template-dir "codegen/templates"
--lang "${{ env.ACTUAL_LANG }}"
-DpackageName=${{ env.NAME }}
--additional-properties "packageVersion=${{ inputs.version }},projectName=${{ env.NAME }},packageName=${{ env.NAME }}"
- name: Clean up generator
run: rm -rf codegen/swagger/target ${{ env.GENERATOR_NAME }}
- name: Push changes to master branch
run: |
git config user.name asana-publish-client-libraries[bot]
git config user.email 159857493+asana-publish-client-libraries[bot]@users.noreply.github.com
git add .
git commit -m 'Updated Python SDK: v${{ inputs.version }}'
git push origin master
git pull
git tag 'v${{ inputs.version }}' --force
git push origin --tags --force
publish-to-pypi:
needs: generate-python-library
name: Build and publish Python 🐍 distributions 📦 to TestPyPI and PyPI
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
ref: master
- name: Set up Python 3.7
uses: actions/setup-python@v5
with:
python-version: 3.7
- name: Install pypa/build
run: >-
python -m
pip install
build
--user
- name: Build a binary wheel and a source tarball
run: >-
python -m
build
--sdist
--wheel
--outdir dist/
.
- name: Publish distribution 📦 to Test PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
repository-url: https://test.pypi.org/legacy/
- name: Publish distribution 📦 to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
publish-to-github-releases:
needs: publish-to-pypi
name: Publish to GitHub Releases
runs-on: ubuntu-latest
steps:
- name: Authenticate to AWS
uses: aws-actions/configure-aws-credentials@v4
with:
aws-region: us-east-1
role-to-assume: arn:aws:iam::403483446840:role/autogen_role_beta_github_actions_release_asana_client_libraries
- name: Get GitHub app token
uses: asana/get-github-app-token@v1
id: get-token
with:
github-app-name: asana-publish-client-libraries
- uses: actions/checkout@v4
with:
fetch-depth: 0
ref: master
- name: Publish to GitHub Releases
run: gh release create v${{ inputs.version }}
env:
GH_TOKEN: ${{ steps.get-token.outputs.app-token }}