Browse Source

twisted-alike (so similar) automatic publishing on gha (#315)

pull/333/head
Kyle Altendorf 1 year ago committed by GitHub
parent
commit
7267fb56e2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 57
      .github/workflows/ci.yml
  2. 1
      MANIFEST.in
  3. 34
      admin/check_tag_version_match.py
  4. 2
      src/towncrier/_version.py
  5. 0
      src/towncrier/newsfragments/315.misc.rst
  6. 9
      tox.ini
  7. 10
      tox_build.sh

57
.github/workflows/ci.yml

@ -3,6 +3,7 @@ name: CI
on:
push:
branches: [ master ]
tags: [ "**" ]
pull_request:
branches: [ master ]
@ -53,7 +54,8 @@ jobs:
test:
name: ${{ matrix.task.name}} - ${{ matrix.os.name }} ${{ matrix.python.name }}
runs-on: ${{ matrix.os.runs-on }}
needs: build
needs:
- build
strategy:
fail-fast: false
matrix:
@ -125,6 +127,8 @@ jobs:
check:
name: ${{ matrix.task.name}} - ${{ matrix.python.name }}
runs-on: ubuntu-latest
needs:
- build
strategy:
fail-fast: false
matrix:
@ -137,8 +141,6 @@ jobs:
task:
- name: Flake8
tox: flake8
- name: Check Manifest
tox: check-manifest
- name: Check Newsfragment
tox: check-newsfragment
@ -147,6 +149,12 @@ jobs:
with:
fetch-depth: 0
- name: Download package files
uses: actions/download-artifact@v2
with:
name: dist
path: dist/
- name: Set up ${{ matrix.python.name }}
uses: actions/setup-python@v2
with:
@ -160,6 +168,48 @@ jobs:
- name: Tox
run: tox -c tox.ini -e ${{ matrix.task.tox }}
pypi-publish:
# https://github.community/t/is-it-possible-to-require-all-github-actions-tasks-to-pass-without-enumerating-them/117957/4?u=graingert
name: Check tag and publish
runs-on: ubuntu-latest
needs:
- build
- test
- check
steps:
- uses: actions/checkout@v2
- name: Download package files
uses: actions/download-artifact@v2
with:
name: dist
path: dist/
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: 3.8
- name: Install dependencies
run: |
python -m pip install --upgrade pip setuptools wheel
python -m pip install pep517
- name: Display structure of files to be pushed
run: ls --recursive dist/
- name: Check matched tag version and branch version - on tag
if: startsWith(github.ref, 'refs/tags/')
run: python admin/check_tag_version_match.py "${{ github.ref }}"
- name: Publish to PyPI - on tag
if: startsWith(github.ref, 'refs/tags/')
uses: pypa/gh-action-pypi-publish@v1.4.2
with:
password: ${{ secrets.PYPI_TOKEN }}
verbose: true
all:
name: All
runs-on: ubuntu-latest
@ -167,6 +217,7 @@ jobs:
- build
- test
- check
- pypi-publish
steps:
- name: This
shell: python

1
MANIFEST.in

@ -5,6 +5,7 @@ include CODE_OF_CONDUCT.md
include pyproject.toml
include tox.ini
include tox_build.sh
include tox_check-release.sh
recursive-include src *.rst
exclude bin

34
admin/check_tag_version_match.py

@ -0,0 +1,34 @@
#
# Used during the release process to make sure that we release based on a
# tag that has the same version as the current twisted.__version.
#
# Designed to be conditionally called inside GitHub Actions release job.
# Tags should use PEP440 version scheme.
#
# To be called as: admin/check_tag_version_match.py refs/tags/twisted-20.3.0
#
import sys
import pep517.meta
TAG_PREFIX = "refs/tags/"
if len(sys.argv) < 2:
print("No tag check requested.")
sys.exit(0)
branch_version = pep517.meta.load(".").version
run_version = sys.argv[1]
if not run_version.startswith(TAG_PREFIX):
print("Not a twisted release tag name '{}.".format(run_version))
sys.exit(1)
run_version = run_version[len(TAG_PREFIX) :]
if run_version != branch_version:
print("Branch is at '{}' while tag is '{}'".format(branch_version, run_version))
exit(1)
print("All good. Branch and tag versions match for '{}'.".format(branch_version))
sys.exit(0)

2
src/towncrier/_version.py

@ -7,5 +7,5 @@ Provides towncrier version information.
from incremental import Version
__version__ = Version("towncrier", 19, 2, 0)
__version__ = Version("towncrier", 21, 3, 0, dev=4)
__all__ = ["__version__"]

0
src/towncrier/newsfragments/315.misc.rst

9
tox.ini

@ -10,13 +10,6 @@ deps =
commands =
flake8 src/towncrier/
[testenv:check-manifest]
skip_install = True
deps =
check_manifest
commands =
check-manifest -v
[testenv:check-newsfragment]
commands =
python -m towncrier.check
@ -44,6 +37,8 @@ allowlist_externals =
changedir = {envtmpdir}
deps =
build
check-manifest>=0.44
twine
setenv =
toxinidir={toxinidir}
skip_install = true

10
tox_build.sh

@ -1,6 +1,16 @@
# build the sdist
set -evx
check-manifest --verbose ${toxinidir}
python -m build --sdist --outdir ${toxinidir}/dist/ ${toxinidir}
tar -xvf ${toxinidir}/dist/*
cd *
# build the wheel from the sdist
python -m build --wheel --outdir ${toxinidir}/dist/ .
cd -
twine check ${toxinidir}/dist/*

Loading…
Cancel
Save