Skip to content

Commit

Permalink
ci: switch from Travis CI to GitHub Actions
Browse files Browse the repository at this point in the history
  • Loading branch information
engineervix committed Aug 6, 2021
1 parent 753be63 commit ba1b1fb
Show file tree
Hide file tree
Showing 6 changed files with 127 additions and 51 deletions.
118 changes: 118 additions & 0 deletions .github/workflows/main.yml
@@ -0,0 +1,118 @@
name: Continuous Integration

env:
TERM: screen-256color

on:
pull_request:
branches: ["master", "main"]
paths-ignore: ["docs/**"]

push:
branches: ["master", "main"]
paths-ignore: ["docs/**"]
tags:
- "v*"

jobs:

# Runs all steps on the VM
test:

runs-on: ubuntu-20.04

strategy:
matrix:
python-version: [3.6, 3.7, 3.8, 3.9]

steps:

- name: Checkout Code Repository
uses: actions/checkout@v2

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}

- name: Install Dependencies
run: |
python -m pip install --upgrade pip
pip install tox tox-gh-actions
pip install codecov
- name: "Run tox targets for Python ${{ matrix.python-version }}"
run: |
tox
- name: Upload Coverage to Codecov
uses: "codecov/codecov-action@v2"
with:
fail_ci_if_error: true

# Runs all steps on the VM
# Deploy to PyPI & create a GitHub Release when the test job succeeds, and only on pushes to tags.
deploy:

needs: test

if: needs.test.result == 'success' && startsWith( github.ref, 'refs/tags/v' )

runs-on: ubuntu-20.04

steps:
- name: Checkout Code Repository
uses: actions/checkout@v2

- name: Set up Python 3.8
uses: actions/setup-python@v2
with:
python-version: 3.8

- name: Install Dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements_dev.txt
- name: Build Package
run: |
invoke dist
- name: Publish 🐍 distribution 📦 to Test PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.TEST_PYPI_API_TOKEN }}
repository_url: https://test.pypi.org/legacy/

- name: Publish 🐍 distribution 📦 to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}
verbose: true

- name: Get the version
id: get_version
run: |
echo "${{ github.ref }}"
echo ::set-output name=VERSION::${GITHUB_REF/refs\/tags\//}
- name: Generate Release Title
id: get_release_title
shell: bash
run: |
export TODAY="($(TZ=Africa/Lusaka date --iso))"
echo ::set-output name=RELEASE_NAME::"${{ steps.get_version.outputs.VERSION }} $TODAY"
- name: Extract Release Notes
# This creates a file LATEST_RELEASE_NOTES.md in the parent directory (../)
run: |
invoke get-release-notes
- name: GitHub Release
uses: softprops/action-gh-release@v1
with:
name: ${{ steps.get_release_title.outputs.RELEASE_NAME }}
body_path: ../LATEST_RELEASE_NOTES.md
files: dist/*
1 change: 1 addition & 0 deletions .pre-commit-config.yaml
Expand Up @@ -15,6 +15,7 @@ repos:
- id: detect-private-key
- id: end-of-file-fixer
- id: mixed-line-ending
exclude: .git/COMMIT_EDITMSG
- id: trailing-whitespace
- repo: https://github.com/psf/black
rev: 21.7b0
Expand Down
45 changes: 0 additions & 45 deletions .travis.yml

This file was deleted.

4 changes: 2 additions & 2 deletions README.md
Expand Up @@ -7,8 +7,8 @@
<a href="https://pypi.org/project/readme-coverage-badger" target="_blank">
<img src="https://img.shields.io/pypi/pyversions/readme-coverage-badger" alt="PyPI - Python Version">
</a>
<a href="https://travis-ci.com/engineervix/readme-coverage-badger" target="_blank">
<img src="https://travis-ci.com/engineervix/readme-coverage-badger.svg?branch=master" alt="Build Status">
<a href="https://github.com/engineervix/readme-coverage-badger/actions/workflows/main.yml" target="_blank">
<img src="https://github.com/engineervix/readme-coverage-badger/actions/workflows/main.yml/badge.svg" alt="Build Status">
</a>
<a href="https://codecov.io/gh/engineervix/readme-coverage-badger" target="_blank">
<img src="https://codecov.io/gh/engineervix/readme-coverage-badger/branch/master/graph/badge.svg" alt="codecov">
Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Expand Up @@ -96,7 +96,7 @@ testpaths = tests
envlist = lint, py36, py37, py38, py39
isolated_build = True

[travis]
[gh-actions]
python =
3.9: py39
3.8: lint, py38
Expand Down
8 changes: 5 additions & 3 deletions tasks.py
@@ -1,9 +1,10 @@
import os
from pathlib import Path

from colorama import Fore, init
from invoke import task

# from pathlib import Path


def execute_bump_hack(c):
"""A little hack that combines commitizen-tools and standard-version
Expand Down Expand Up @@ -230,7 +231,8 @@ def get_release_notes(c):
elif pattern_to_match in line and count == 1:
break

home = str(Path.home())
release_notes = os.path.join(home, "LATEST_RELEASE_NOTES.md")
# home = str(Path.home())
# release_notes = os.path.join(home, "LATEST_RELEASE_NOTES.md")
release_notes = os.path.join("../", "LATEST_RELEASE_NOTES.md")
with open(release_notes, "w") as f:
print("".join(lines), file=f, end="")

0 comments on commit ba1b1fb

Please sign in to comment.