diff --git a/.github/workflows/python-publish.yml b/.github/workflows/python-publish.yml index af11f36..eb74a5e 100644 --- a/.github/workflows/python-publish.yml +++ b/.github/workflows/python-publish.yml @@ -10,8 +10,10 @@ name: Publish on: workflow_dispatch: - release: - types: [published] + push: + # Sequence of patterns matched against refs/tags + tags: + - 'release/v*' # Push events to matching v*, i.e. v1.0, v20.15.10 permissions: contents: read @@ -57,20 +59,52 @@ jobs: - name: Build package run: poetry build - - - name: Upload a Build Artifact - uses: actions/upload-artifact@v3.1.2 + - name: Set Versions + uses: actions/github-script@v4 + id: set_version with: - # Artifact name - name: "pip package" - # A file, directory or wildcard pattern that describes what to upload - path: "dist/*" - # The desired behavior if no files are found using the provided path. - if-no-files-found: error + script: | + const tag = context.ref.substring(18) + const no_v = tag.replace('v', '') + const dash_index = no_v.lastIndexOf('-') + const no_dash = (dash_index > -1) ? no_v.substring(0, dash_index) : no_v + core.setOutput('tag', tag) + core.setOutput('no-v', no_v) + core.setOutput('no-dash', no_dash) + + +# - name: Upload a Build Artifact +# uses: actions/upload-artifact@v3.1.2 +# with: +# # Artifact name +# name: "pip package" +# # A file, directory or wildcard pattern that describes what to upload +# path: "dist/*" +# # The desired behavior if no files are found using the provided path. +# if-no-files-found: error + + - name: Create Release + id: create_release + uses: actions/create-release@v1 + env: + GITHUB_TOKEN: ${{ github.token }} + with: + tag_name: ${{ github.ref }} + release_name: Release ${{ github.ref }} + draft: true + prerelease: false + + - name: Upload Release Artefact + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ github.token }} + with: + upload_url: ${{ steps.create_release.outputs.upload_url }} + asset_path: ./dist/rnsh-${{ steps.set_version.outputs.no-v }}-py3-none-any.whl + asset_name: rnsh-${{ steps.set_version.outputs.no-v }}-py3-none-any.whl + asset_content_type: application/zip - name: Publish to PyPI - env: - POETRY_PYPI_TOKEN_PYPI: ${{ secrets.PYPI_API_TOKEN }} - run: poetry publish + run: poetry publish --username __token__ --password ${{ secrets.PYPI_API_TOKEN }}