diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..b9d90ba --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,57 @@ +name: 'Release new version' + +on: + push: + tags: + - 'v*.*.*' + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-python@v4 + with: + architecture: x64 + python-version: '3.10' + - name: Build packages + id: build_package + run: | + pip install flit + flit build + echo ::set-output name=targz::$(basename $(ls dist/*tar.gz)) + echo ::set-output name=wheel::$(basename $(ls dist/*whl)) + - name: Create release on GitHub + id: create_release + uses: actions/create-release@latest + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + tag_name: ${{ github.ref }} + release_name: Release ${{ github.ref }} + body: '' + draft: false + prerelease: false + - name: Upload sdist to GitHub + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ steps.create_release.outputs.upload_url }} + asset_path: dist/${{ steps.build_package.outputs.targz }} + asset_name: ${{ steps.build_package.outputs.targz }} + asset_content_type: application/gzip + - name: Upload wheel to GitHub + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ steps.create_release.outputs.upload_url }} + asset_path: dist/${{ steps.build_package.outputs.wheel }} + asset_name: ${{ steps.build_package.outputs.wheel }} + asset_content_type: application/zip + - name: Publish to PyPI + uses: pypa/gh-action-pypi-publish@release/v1 + with: + user: __token__ + password: ${{ secrets.PYPI_API_TOKEN }}