Skip to content

Commit

Permalink
[gha] Create cd.yml
Browse files Browse the repository at this point in the history
This commit adds the release github action which generates
a package, tests it with different python versions, publishes
the release on GitHub, and uploads the packages to PyPI whenever
a tag is generated and pushed.

Signed-off-by: Venu Vardhan Reddy Tekula <venu@bitergia.com>
  • Loading branch information
vchrombie committed Apr 20, 2021
1 parent 79c67e0 commit 606e2d5
Showing 1 changed file with 97 additions and 0 deletions.
97 changes: 97 additions & 0 deletions .github/workflows/cd.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
name: release

on:
push:
tags:
- '*.*.*'

jobs:

build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.x'
- name: Install poetry
run: |
curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py | python
echo "PATH=$HOME/.poetry/bin:$PATH" >> $GITHUB_ENV
- name: Build distributions
run: |
poetry build
- name: Upload distribution artifacts
uses: actions/upload-artifact@v2
with:
name: toolkit-dist
path: dist

test:
needs: [build]
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.6, 3.7, 3.8]
steps:
- uses: actions/checkout@v2
- name: Download distribution artifact
uses: actions/download-artifact@v2
with:
name: toolkit-dist
path: dist
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Test package
run: |
PACKAGE_NAME=`(cd dist && ls *whl | cut -f 1 -d "-")` && echo $PACKAGE_NAME
pip install --pre --find-links ./dist/ $PACKAGE_NAME
cd tests && python run_tests.py
release:
needs: [test]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Get release tag
id: tag
run: |
echo ::set-output name=tag::${GITHUB_REF#refs/tags/}
- name: Create release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ steps.tag.outputs.tag }}
release_name: ${{ steps.tag.outputs.tag }}
body_path: ./releases/${{ steps.tag.outputs.tag }}.md

publish:
needs: [test]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Download distribution artifact
uses: actions/download-artifact@v2
with:
name: toolkit-dist
path: dist
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.x'
- name: Install poetry
run: |
curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py | python
echo "PATH=$HOME/.poetry/bin:$PATH" >> $GITHUB_ENV
- name: Configure pypi credentials
env:
PYPI_API_TOKEN: ${{ secrets.PYPI_API_TOKEN }}
run: |
poetry config http-basic.pypi __token__ "$PYPI_API_TOKEN"
- name: Publish release to pypi
run: |
poetry publish

0 comments on commit 606e2d5

Please sign in to comment.