Skip to content

Commit

Permalink
Pypi2 (#16)
Browse files Browse the repository at this point in the history
* add publish to pypi
  • Loading branch information
Florian Maas committed Apr 12, 2022
1 parent 1f55773 commit 06901fc
Show file tree
Hide file tree
Showing 7 changed files with 108 additions and 31 deletions.
30 changes: 1 addition & 29 deletions .github/workflows/on-merge-to-main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,32 +19,4 @@ jobs:
uses: ./.github/workflows/setup-poetry-env

- name: Run checks
uses: ./.github/workflows/run-checks

docs:
needs: Quality
runs-on: ubuntu-latest
steps:

- name: Check out
uses: actions/checkout@v2

- name: Set up the environment
uses: ./.github/workflows/setup-poetry-env

- name: Test documentation
run: |
source .venv/bin/activate
make docs-test
- name: Generate documentation
run: |
source .venv/bin/activate
make docs-clean
make docs-build
- name: Deploy documentation to GitHub pages
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.MY_GITHUB_TOKEN }}
publish_dir: ./docs/_build
uses: ./.github/workflows/run-checks
67 changes: 67 additions & 0 deletions .github/workflows/on-release-main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
on:
release:
types: [published]
branches: [main]

name: release-main

jobs:

quality:
runs-on: ubuntu-latest
steps:

- name: Check out
uses: actions/checkout@v2

- name: Set up the environment
uses: ./.github/workflows/setup-poetry-env

- name: Run checks
uses: ./.github/workflows/run-checks

release:
needs: Quality
runs-on: ubuntu-latest
steps:

- name: Check out
uses: actions/checkout@v2

- name: Set up the environment
uses: ./.github/workflows/setup-poetry-env

- name: Set output
id: vars
run: echo ::set-output name=tag::${GITHUB_REF#refs/*/}

- name: Build and publish
run: |
source .venv/bin/activate
poetry version $RELEASE_VERSION
make build-and-publish
env:
PYPI_TOKEN: ${{ secrets.PYPI_TOKEN }}
RELEASE_VERSION: ${{ steps.vars.outputs.tag }}

documentation:
needs: Release
runs-on: ubuntu-latest
steps:

- name: Check out
uses: actions/checkout@v2

- name: Set up the environment
uses: ./.github/workflows/setup-poetry-env

- name: Generate documentation
run: |
source .venv/bin/activate
make docs-build
- name: Deploy documentation to GitHub pages
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./docs/_build
16 changes: 16 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,22 @@ test: ## Test the code with pytest
@echo "🚀 Testing code: Running pytest"
@pytest --doctest-modules tests

build: clean-build ## Build wheel file using poetry
@echo "🚀 Creating wheel file"
@poetry build

clean-build: ## clean build artifacts
@rm -rf dist

publish: ## publish a release to pypi.
@echo "🚀 Publishing: Dry run."
@poetry config pypi-token.pypi $(PYPI_TOKEN)
@poetry publish --dry-run
@echo "🚀 Publishing."
@poetry publish

build-and-publish: build publish ## Build and publish.

docs-test: ## Test Sphinx documentation.
@sphinx-build docs docs/_build -W --keep-going

Expand Down
Empty file added poetry_cookiecutter/__init__.py
Empty file.
7 changes: 7 additions & 0 deletions poetry_cookiecutter/cli.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import os


def main():
cwd = os.path.dirname(__file__)
package_dir = os.path.abspath(os.path.join(cwd, ".."))
os.system(f"cookiecutter {package_dir}")
16 changes: 14 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,8 +1,18 @@
[tool.poetry]
name = "cookiecutter-poetry"
version = "0.1.0"
description = ""
description = "A python cookiecutter application to create a new python project that uses poetry to manage its dependencies."
authors = ["Florian Maas <fpgmaas@gmail.com>"]
repository = "https://github.com/fpgmaas/cookiecutter-poetry"
documentation = "https://fpgmaas.github.io/cookiecutter-poetry/"
packages = [
{include = "poetry_cookiecutter"}
]
include = [
'{{cookiecutter.project_name}}/**/*',
'cookiecutter.json',
'hooks/*'
]

[tool.poetry.dependencies]
python = "^3.9"
Expand All @@ -21,7 +31,6 @@ black = "^22.3.0"
requires = ["poetry-core>=1.0.0"]
build-backend = "poetry.core.masonry.api"


[tool.black]
line-length = 120
include = '\.pyi?$'
Expand All @@ -43,3 +52,6 @@ exclude = '''
[tool.isort]
profile = "black"
skip = ["{{cookiecutter.project_name}}",".venv"]

[tool.poetry.scripts]
pcc = 'poetry_cookiecutter.cli:main'
3 changes: 3 additions & 0 deletions {{cookiecutter.project_name}}/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@

{{cookiecutter.project_description}}

* **Github repository**: `https://github.com/{{cookiecutter.github_author_handle}}/{{cookiecutter.project_name}}/ <https://github.com/{{cookiecutter.github_author_handle}}/{{cookiecutter.project_name}}/>`_
* **Documentation**: `https://{{cookiecutter.github_author_handle}}.github.io/{{cookiecutter.project_name}}/ <https://{{cookiecutter.github_author_handle}}.github.io/{{cookiecutter.project_name}}/>`_


Releasing a new version
-----------------------------
Expand Down

0 comments on commit 06901fc

Please sign in to comment.