Skip to content

Commit

Permalink
Add automatic publish to PyPI workflow with automatic release note (#34)
Browse files Browse the repository at this point in the history
* Add Release-drafter config file

* Remove the Publish to PyPI workflow

* Add a release management workflow

* Bump action setup-python to v2.1.3

* Remove __version__ from .py file

According to cjolowicz/cookiecutter-hypermodern-python#154,
there is no need to have __version__ coputed at runtime by default.
If users need it there are alternative ways to get it.

* Apply suggestions from code review

Fix typo in comments

Co-authored-by: Quentame <[email protected]>

Co-authored-by: Quentame <[email protected]>
  • Loading branch information
oncleben31 and Quentame authored Oct 7, 2020
1 parent b28f0f9 commit c4ff36b
Show file tree
Hide file tree
Showing 5 changed files with 107 additions and 27 deletions.
29 changes: 29 additions & 0 deletions .github/release-drafter.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
categories:
- title: ":boom: Breaking Changes"
label: "breaking"
- title: ":rocket: Features"
label: "enhancement"
- title: ":fire: Removals and Deprecations"
label: "removal"
- title: ":beetle: Fixes"
label: "bug"
- title: ":racehorse: Performance"
label: "performance"
- title: ":rotating_light: Testing"
label: "testing"
- title: ":construction_worker: Continuous Integration"
label: "ci"
- title: ":books: Documentation"
label: "documentation"
- title: ":hammer: Refactoring"
label: "refactoring"
- title: ":lipstick: Style"
label: "style"
- title: ":package: Dependencies"
labels:
- "dependencies"
- "build"
template: |
## Changes
$CHANGES
25 changes: 0 additions & 25 deletions .github/workflows/publish.yml

This file was deleted.

78 changes: 78 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
name: Release

on:
push:
branches:
- master

jobs:
release:
name: Release
runs-on: ubuntu-latest
steps:
- name: Check out the repository
uses: actions/[email protected]
with:
fetch-depth: 2

- name: Set up Python
uses: actions/[email protected]
with:
python-version: "3.8"

- name: Upgrade pip
run: |
pip install --constraint=.github/workflows/constraints.txt pip
pip --version
- name: Install Poetry
run: |
pip install --constraint=.github/workflows/constraints.txt poetry
poetry --version
- name: Check if there is a parent commit
id: check-parent-commit
run: |
echo "::set-output name=sha::$(git rev-parse --verify --quiet HEAD^)"
- name: Detect and tag new version
id: check-version
if: steps.check-parent-commit.outputs.sha
uses: salsify/[email protected]
with:
version-command: |
bash -o pipefail -c "poetry version | awk '{ print \$2 }'"
- name: Bump version for development release
if: "! steps.check-version.outputs.tag"
run: |
poetry version patch &&
version=$(poetry version | awk '{ print $2 }') &&
poetry version $version.dev.$(date +%s)
- name: Build package
run: |
poetry build --ansi
- name: Publish package on PyPI
if: steps.check-version.outputs.tag
uses: pypa/[email protected]
with:
user: __token__
password: ${{ secrets.PYPI_TOKEN }}

- name: Publish package on TestPyPI
if: "! steps.check-version.outputs.tag"
uses: pypa/[email protected]
with:
user: __token__
password: ${{ secrets.TEST_PYPI_TOKEN }}
repository_url: https://test.pypi.org/legacy/

- name: Publish release notes
uses: release-drafter/[email protected]
with:
publish: ${{ steps.check-version.outputs.tag != '' }}
tag: ${{ steps.check-version.outputs.tag }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
1 change: 0 additions & 1 deletion src/meteofrance/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
"""Météo-France API."""
__version__ = "0.1.1"
1 change: 0 additions & 1 deletion src/meteofrance/const.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# -*- coding: utf-8 -*-
"""Consts for Météo-France weather forecast python API."""
# TODO: add package version
METEOFRANCE_API_URL = "http://webservice.meteofrance.com"
# Additionan API URL used with getDetail, getAllVigilances, getVigilance
METEOFRANCE_WS_API_URL = "http://ws.meteofrance.com/ws"
Expand Down

0 comments on commit c4ff36b

Please sign in to comment.