name: Upload Python Package on: # 当master分支有push时,触发action push: branches: - master # 当一个pr被合并到master时,触发action pull_request: branches: - master # 当发布时,触发action #release: # types: [created] jobs: build: runs-on: ubuntu-latest strategy: matrix: python-version: ["3.6", "3.7", "3.8"] steps: # 此步骤使用 GitHub 的 https://github.com/actions/checkout - uses: actions/checkout@v2 # 设置python环境 # 此步骤使用 GitHub 的 https://github.com/actions/setup-python - name: Set up Python ${{ matrix.python-version }} uses: actions/setup-python@v2 with: python-version: ${{ matrix.python-version }} # 安装依赖 - name: Install dependencies run: | python -m pip install --upgrade pip pip install setuptools wheel twine # 构建和发布 - name: Build and publish env: TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }} TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }} run: | python setup.py sdist bdist_wheel twine upload dist/*