CI: update release workflow action (#410)

* Run test for uploading test.pypi.org only for releases/* branch

Signed-off-by: Hiroshi Miura <miurahr@linux.com>

* CI: update release workflow

- rename action script
- run on ubuntu 20.04

Signed-off-by: Hiroshi Miura <miurahr@linux.com>

* Update .github/workflows/publish-to-pypi.yml

Co-authored-by: Mozi <29089388+pzhlkj6612@users.noreply.github.com>

Co-authored-by: Mozi <29089388+pzhlkj6612@users.noreply.github.com>
This commit is contained in:
Hiroshi Miura
2021-10-17 23:57:23 -07:00
committed by GitHub
parent d5213142a8
commit 6ebbd68106

43
.github/workflows/publish-to-pypi.yml vendored Normal file
View File

@@ -0,0 +1,43 @@
name: Publish Python 🐍 distributions 📦 to PyPI
on:
push:
branches:
- master
- releases/*
- rel-*
tags:
- v*
jobs:
build-n-publish:
name: Build and publish Python 🐍 distributions 📦 to PyPI
runs-on: ubuntu-20.04
steps:
- name: Checkout 🛎️
uses: actions/checkout@v2
with:
fetch-depth: 50
- name: Fetch release tag
run: git fetch --depth=1 origin +refs/tags/*:refs/tags/*
- name: Set up Python 3.7🐍
uses: actions/setup-python@v1
with:
python-version: 3.7
- name: Install build and twine
run: python -m pip install build twine --user
- name: Build release assets
run: python -m build ./
- name: twine check
run: python -m twine check dist/*
- name: Publish distribution 📦 to Test PyPI when releases branch
if: ${{ startsWith(github.event.ref, 'refs/heads/releases') }}
uses: pypa/gh-action-pypi-publish@master
with:
password: ${{ secrets.testpypi_password }}
repository_url: https://test.pypi.org/legacy/
- name: Publish distribution 📦 to PyPI
if: ${{ startsWith(github.event.ref, 'refs/tags') }}
uses: pypa/gh-action-pypi-publish@master
with:
password: ${{ secrets.pypi_password }}