Skip to content

Commit

Permalink
[26] Add PyPi support in Github Actions
Browse files Browse the repository at this point in the history
  • Loading branch information
llaumgui committed Aug 26, 2020
1 parent 700aded commit 925d94c
Showing 1 changed file with 105 additions and 88 deletions.
193 changes: 105 additions & 88 deletions .github/workflows/python.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ on:
[push, pull_request]

jobs:

##############################################################################
# Build job
#
build:
runs-on: ubuntu-latest
name: Build and test
Expand All @@ -15,57 +19,64 @@ jobs:

steps:

- name: Git checkout
uses: actions/checkout@v2

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

- name: Install Dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install -r requirements-dev.txt
- name: Make all tests with make
run: make test

- name: SonarCloud Scan
if: matrix.python-version == '3.8'
uses: sonarsource/sonarcloud-github-action@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}

- name: Package
if: matrix.python-version == '3.8'
run: make dist

- name: Archive package
if: matrix.python-version == '3.8'
uses: actions/upload-artifact@v2
with:
name: seedboxsync-${{ github.sha }}.tar.gz
path: dist/*.tar.gz

- name: Git checkout
uses: actions/checkout@v2

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

- name: Install Dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install -r requirements-dev.txt
- name: Make all tests with make
run: make test

- name: SonarCloud Scan
if: matrix.python-version == '3.8'
uses: sonarsource/sonarcloud-github-action@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}

- name: Package
if: matrix.python-version == '3.8'
run: make dist

- name: Archive package
if: matrix.python-version == '3.8'
uses: actions/upload-artifact@v2
with:
name: seedboxsync-${{ github.sha }}.tar.gz
path: dist/*.tar.gz


##############################################################################
# Markdownlint job
#
markdownlint:
runs-on: ubuntu-latest
name: MarkdownLint

steps:

- name: Git checkout
uses: actions/checkout@v2
- name: Git checkout
uses: actions/checkout@v2

- name: markdownlint-cli
uses: nosborn/[email protected]
with:
files: "*.md docs/*.md"
config_file: ".markdownlint.yaml"

- name: markdownlint-cli
if: matrix.python-version == '3.8'
uses: nosborn/[email protected]
with:
files: "*.md docs/*.md"
config_file: ".markdownlint.yaml"

##############################################################################
# Realse job
#
release:
needs: [
build,
Expand All @@ -76,48 +87,54 @@ jobs:
name: Release on GitHub and PyPi

steps:
- name: Git checkout
uses: actions/checkout@v2

- name: Set env
run: echo ::set-env name=RELEASE_VERSION::${GITHUB_REF:11}

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

- name: Install Dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install -r requirements-dev.txt
- name: Package
run: make dist

- name: Create GitHub release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: Release ${{ github.ref }}
body: |
Changes in this Release
- First Change
- Second Change
draft: true
prerelease: false

- name: Upload asset in GitHub release
id: upload-release-asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps
asset_path: dist/seedboxsync-${{ env.RELEASE_VERSION }}.tar.gz
asset_name: seedboxsync-${{ env.RELEASE_VERSION }}.tar.gz
asset_content_type: application/tar+gzip
- name: Git checkout
uses: actions/checkout@v2

- name: Set env
run: echo ::set-env name=RELEASE_VERSION::${GITHUB_REF:11}

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

- name: Install Dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install -r requirements-dev.txt
- name: Package
run: make dist

- name: Create GitHub release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: Release ${{ github.ref }}
body: |
Changes in this Release
- First Change
- Second Change
draft: true
prerelease: false

- name: Upload asset in GitHub release
id: upload-release-asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps
asset_path: dist/seedboxsync-${{ env.RELEASE_VERSION }}.tar.gz
asset_name: seedboxsync-${{ env.RELEASE_VERSION }}.tar.gz
asset_content_type: application/tar+gzip

- name: Publish package
uses: pypa/gh-action-pypi-publish@master
with:
user: __token__
password: ${{ secrets.PYPI_PASSWORD }}

0 comments on commit 925d94c

Please sign in to comment.