Skip to content

Commit

Permalink
Migrate publishing to PyPI from Travis CI to GHA
Browse files Browse the repository at this point in the history
  • Loading branch information
webknjaz committed Jun 18, 2020
1 parent 2738977 commit 9072def
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 39 deletions.
62 changes: 61 additions & 1 deletion .github/workflows/tox-tests.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
name: 👷

on:
create: # branch or tag created, need to filter on publish
push:
pull_request:
schedule:
Expand All @@ -10,7 +11,7 @@ on:
# - cron: 2 18 * * 5

jobs:
tests:
test-matrix:
name: >-
Ansible ${{ matrix.ansible-version }}/${{ matrix.python-version }}@${{ matrix.os }}
runs-on: ${{ matrix.os }}
Expand Down Expand Up @@ -101,3 +102,62 @@ jobs:
with:
name: logs.zip
path: .tox/ansible${{ matrix.ansible-version }}/log/

publish-dists:
name: Publish 🐍📦 to (Test)PyPI
needs:
- test-matrix
runs-on: ubuntu-latest

env:
PY_COLORS: 1
TOXENV: build-dists,metadata-validation
TOX_PARALLEL_NO_SPINNER: 1

steps:
- name: Switch to using Python 3.8 by default
uses: actions/setup-python@v2
with:
python-version: 3.8
- name: Install tox
run: >-
python -m
pip install
--user
tox
- name: Check out src from Git
uses: actions/checkout@v2
- name: Get history and tags for SCM versioning to work
run: |
git fetch --prune --unshallow
git fetch --depth=1 origin +refs/tags/*:refs/tags/*
- name: Instruct setuptools-scm not to add a local version part
if: >-
github.event_name == 'push' &&
github.ref == format(
'refs/heads/{0}', github.event.repository.default_branch
)
run: |
echo 'local_scheme = "no-local-version"' >> pyproject.toml
git update-index --assume-unchanged pyproject.toml
- name: Pre-populate tox env
run: python -m tox -p auto --parallel-live -vvvv --notest
- name: Build dists
run: python -m tox -p auto --parallel-live -vvvv
- name: Publish 🐍📦 to TestPyPI
if: >-
github.event_name == 'push' &&
github.ref == format(
'refs/heads/{0}', github.event.repository.default_branch
)
uses: pypa/gh-action-pypi-publish@master
with:
password: ${{ secrets.testpypi_password }}
repository_url: https://test.pypi.org/legacy/
- name: Publish 🐍📦 to PyPI
if: >- # "create" workflows run separately from "push" & "pull_request"
github.event_name == 'create' &&
startsWith(github.event.ref_type, 'tag')
uses: pypa/gh-action-pypi-publish@master
with:
password: ${{ secrets.pypi_password }}
38 changes: 0 additions & 38 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -78,44 +78,6 @@ jobs:
env:
ANSIBLE_VERSION: devel

- &deploy-job
<<: *reset-prerequisites
stage: Deploy
name: Publishing current Git tagged version of dist to PyPI
if: repo == "ansible/ansible-lint" AND tag IS present
python: "3.8"
env:
TOXENV: build-dists,metadata-validation
before_deploy:
- echo > setup.py
deploy: &deploy-step
provider: pypi
user: ansible-lint
password:
secure: >
l4lT2SQmdtNOoOWd4eeozpshpsuSKirvzcJtRf7BhkcUh1T4OPTga8Qe2kQiQ/zOdd9E+Mtlyi1o6pipEVTQkLn2TvVM+lOt9NlpyNxUrDfwJ3dyqp6/rdNm+UWBOJA/sijZik2WyyXq5aN6va7ESSu4ShZtlOUYuLnEfQkgogbkn2IO0EhrAQIjBknvmIFPWpicxwi3aZaV5eEhYFCjxZDlQOq4B0pC9FIvbHQr32DB3Eibv7q0Svn0SuRAvrOKvgFlqcM24PHYV0gu1NAvuX7fj6ICvnHNLlDQ/iPNr90PqDal+zE/bdrGHFehT1Gp4heWEuP+xknysz4UrrO5j4V/MA+A5EfNwzku1lr4LeWPwxHVyv/4UYM3rAJFQLdkKErnChkrLUQaqNf+W9eznTsBKSXGbrkZmDsqT2cAW87Z5PTm5z+FtA3uOd5Ga8UZLoTMUjrHu1f23aC3TOYVvCWu2OKFtAowRdUxrbyJghzk6WORRhQCUAs8JUxObsd7TfeETSodtW3oALMVhrOnDTQF/Iif4X1hjorUlBvZR9vNJmZoyyUKc64FDPmoWLaYhed2iGOBW6QAz4+SolJ3QXdSI5odb7sSIq1uBMxnPMWrDtyHOv4iveOz4+vybCEbZt6xJrJodIQJD/nxlRBPVErrOUiSn3f0KXDqpY/bhFI=
distributions: dists
skip-cleanup: true
on:
all_branches: true

- <<: *deploy-job
# Always run, except if PR or cron, or non-master pushes:
if: >-
repo == "ansible/ansible-lint"
AND branch == "master"
AND type NOT IN (cron, pull_request)
name: Publishing current (unstable) Git revision of dist to Test PyPI
before_script:
- >-
echo
'local_scheme = "no-local-version"'
>>
pyproject.toml
deploy:
<<: *deploy-step
server: https://test.pypi.org/legacy/

env:
global:
TOXENV_TMPL: "'ansible${ANSIBLE_VERSION}'"
Expand Down

0 comments on commit 9072def

Please sign in to comment.