colossalai
68 строк · 1.9 Кб
1name: Publish to PyPI
2
3on:
4workflow_dispatch:
5pull_request:
6paths:
7- 'version.txt'
8types:
9- closed
10
11jobs:
12build-n-publish:
13if: github.event_name == 'workflow_dispatch' || github.repository == 'hpcaitech/ColossalAI' && github.event.pull_request.merged == true && github.base_ref == 'main'
14name: Build and publish Python 🐍 distributions 📦 to PyPI
15runs-on: ubuntu-latest
16timeout-minutes: 20
17steps:
18- uses: actions/checkout@v2
19
20- uses: actions/setup-python@v2
21with:
22python-version: '3.8.14'
23
24- run: python setup.py sdist build
25
26# publish to PyPI if executed on the main branch
27- name: Publish package to PyPI
28id: publish
29uses: pypa/gh-action-pypi-publish@release/v1
30with:
31user: __token__
32password: ${{ secrets.PYPI_API_TOKEN }}
33verbose: true
34
35notify:
36name: Notify Lark via webhook
37needs: build-n-publish
38runs-on: ubuntu-latest
39if: ${{ always() }}
40steps:
41- uses: actions/checkout@v2
42
43- uses: actions/setup-python@v2
44with:
45python-version: '3.8.14'
46
47- name: Install requests
48run: pip install requests
49
50- name: Notify Lark
51id: message-preparation
52run: |
53url=$SERVER_URL/$REPO/actions/runs/$RUN_ID
54
55if [ "$STATUS" == 'success' ]
56then
57msg="The Colossal-AI latest version has been successfully released to PyPI."
58else
59msg="Failed to release Colossal-AI to PyPI, please visit $url for details."
60fi
61echo $msg
62python .github/workflows/scripts/send_message_to_lark.py -m "$msg" -u $WEBHOOK_URL
63env:
64SERVER_URL: ${{github.server_url }}
65REPO: ${{ github.repository }}
66RUN_ID: ${{ github.run_id }}
67WEBHOOK_URL: ${{ secrets.LARK_NOTIFICATION_WEBHOOK_URL }}
68STATUS: ${{ needs.build-n-publish.result }}
69