|
| 1 | +name: Release CI |
| 2 | +on: |
| 3 | + push: |
| 4 | + tags: |
| 5 | + - 'release/v?[0-9]*' |
| 6 | + |
| 7 | +env: |
| 8 | + RELEASE_TAG: ${{ github.ref_name }} |
| 9 | + |
| 10 | +jobs: |
| 11 | + publish: |
| 12 | + name: Publish to PyPI |
| 13 | + runs-on: ubuntu-latest |
| 14 | + steps: |
| 15 | + - name: Checkout code |
| 16 | + uses: actions/checkout@v3 |
| 17 | + with: |
| 18 | + path: main |
| 19 | + - name: Set up environment variables |
| 20 | + run: ./.github/scripts/publish_env.sh >> $GITHUB_ENV |
| 21 | + working-directory: ./main |
| 22 | + shell: bash |
| 23 | + - name: Setup Python |
| 24 | + uses: actions/setup-python@v4 |
| 25 | + with: |
| 26 | + python-version: '3.10' |
| 27 | + - name: Pack API client |
| 28 | + run: ./.github/scripts/pack.sh |
| 29 | + working-directory: ./main |
| 30 | + shell: bash |
| 31 | + - name: Prepare API client for publish |
| 32 | + run: ./.github/scripts/prepare.sh |
| 33 | + working-directory: ./main |
| 34 | + shell: bash |
| 35 | + - name: Publish API client |
| 36 | + if: ${{ env.DRY_RUN != '1' }} |
| 37 | + uses: pypa/gh-action-pypi-publish@release/v1 |
| 38 | + with: |
| 39 | + password: ${{ secrets.PYPI_PUBLISH_TOKEN }} |
| 40 | + packages-dir: ./main/dist/ |
| 41 | + - name: Write release body file |
| 42 | + run: CODE_PATH=./main ./main/.github/scripts/release_body.sh > ./dist/release_body.txt |
| 43 | + shell: bash |
| 44 | + - name: Create release (dry run) |
| 45 | + if: ${{ env.DRY_RUN == '1' }} |
| 46 | + run: cat ./dist/release_body.txt |
| 47 | + - name: Create GitHub release |
| 48 | + if: ${{ env.DRY_RUN != '1' }} |
| 49 | + uses: softprops/action-gh-release@v1 |
| 50 | + with: |
| 51 | + name: v${{ env.VERSION }} |
| 52 | + body_path: ./dist/release_body.txt |
| 53 | + files: | |
| 54 | + ./dist/${{ env.PACKAGE_FILENAME }} |
| 55 | + draft: false |
| 56 | + prerelease: ${{ env.PUBLISH_TAG != 'latest' }} |
0 commit comments