simonw / datasette-plugin

Cookiecutter template for creating Datasette plugins
18 stars 5 forks source link

Action should publish newly tagged releases to PyPI #6

Closed simonw closed 4 years ago

simonw commented 4 years ago

This works for running tests. I'm spinning off a separate issue for getting the action to publish new tags as PyPI releases if the PYPI_TOKEN environment variable is set.

Originally posted by @simonw in https://github.com/simonw/datasette-plugin/issues/3#issuecomment-646893357

simonw commented 4 years ago

I think this needs if: secrets.PYPI_TOKEN in the step.

This should be documented in the README.

simonw commented 4 years ago

You create PyPI tokens for publishing to a repo at https://pypi.org/manage/account/token/

simonw commented 4 years ago

Looks like you need to create a token with "Entire account (all projects)" permission in order to publish the original package. Then you can replace that token with one that just has scoped access to the package.

simonw commented 4 years ago

I created one of those and added it as the PYPI_TOKEN secret to https://github.com/simonw/datasette-plugin-template-demo/settings/secrets

simonw commented 4 years ago

I'm going to try this action: https://github.com/actions/starter-workflows/blob/master/ci/python-publish.yml

Documented here: https://help.github.com/en/actions/language-and-framework-guides/using-python-with-github-actions#publishing-to-package-registries suggests

simonw commented 4 years ago

But I'm going to have it re-run the tests first.

simonw commented 4 years ago

I tried creating a new release in datasette-plugin-template-demo and got this error:

https://github.com/simonw/datasette-plugin-template-demo/actions/runs/141395948

The workflow is not valid. .github/workflows/publish.yml (Line: 30, Col: 11): Unrecognized named-value: 'secrets'. Located at position 14 within expression: success() && secrets.PYPI_TOKEN

Referring to this line:

https://github.com/simonw/datasette-plugin/blob/b2a601b9c8b116dfbee11594ed76f113ebf4d6b0/datasette-%7B%7Bcookiecutter.hyphenated%7D%7D/.github/workflows/publish.yml#L29-L33

simonw commented 4 years ago

I'll try adding ${{ <context> }}

simonw commented 4 years ago

It worked! https://pypi.org/project/datasette-plugin-template-demo/0.1/

Just needs documentation now.