Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add workflow to publish to PyPi #2

Merged
merged 13 commits into from
Nov 19, 2020
84 changes: 75 additions & 9 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,22 +1,57 @@
name: Esbonio VSCode
name: Esbonio

on:
pull_request:
branches:
- release
- develop
paths:
- 'code/**'
- '.github/workflows/release.yml'
push:
branches:
- release
paths:
- 'code/**'
- '.github/workflows/release.yml'

jobs:
build:
# Simple job the checks to see which parts we actually have to build.
trigger:
name: Trigger
runs-on: ubuntu-latest
outputs:
vscode: ${{steps.check-vscode.outputs.build}}
python: ${{steps.check-python.outputs.build}}
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0

- run: |
if [ -z "${BASE_REF}" ]; then
echo "BASE=HEAD^" >> $GITHUB_ENV
else
echo "BASE=origin/${BASE_REF}" >> $GITHUB_ENV
fi
name: Determine base
env:
BASE_REF: ${{ github.base_ref }}

- id: check-vscode
run: |
set -e
echo ${BASE}

./scripts/should-build.sh vscode
name: "Build VSCode?"

- id: check-python
run: |
set -e
echo ${BASE}

./scripts/should-build.sh python
name: "Build Python?"

vscode:
name: VSCode
needs: trigger
if: ${{ needs.trigger.outputs.vscode }}
runs-on: ubuntu-latest
steps:
- uses: 'actions/checkout@v2'
Expand All @@ -37,4 +72,35 @@ jobs:
npm run deploy
env:
VSCE_PAT: ${{ secrets.VSCODE_PAT }}
if: success() && startsWith(github.ref, 'refs/heads/release')
if: success() && startsWith(github.ref, 'refs/heads/release')

python:
name: Python
needs: trigger
if: ${{ needs.trigger.outputs.python }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

- uses: actions/setup-python@v1
with:
python-version: 3.8

- run: |
python --version
python -m pip install --upgrade pip
python -m pip install --upgrade tox
name: Setup Environment

- run: |
cd lib/esbonio
python -m tox -e py38
python -m tox -e pkg
name: Test & Package

- name: Publish
run: |
cd lib/esbonio
python -m pip install twine
python -m twine upload dist/* -u alcarney -p ${{ secrets.PYPI_PASS }}
if: success() && startsWith(github.ref, 'refs/heads/release')
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
.env
.tox
*.pyc
*.egg-info
*.log
__pycache__
_build

build
node_modules
dist
6 changes: 3 additions & 3 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"[restructuredtext]": {
"[rst]": {
"editor.tabSize": 3,
"editor.rulers": [
80
Expand All @@ -16,9 +16,9 @@
"**/.DS_Store": true,
"**/.pyc": true,
"**/__pycache__": true,
"**/*.egg-info": true
"**/*.egg-info": true,
"**/.tox": true
},
"python.pythonPath": ".env/bin/python3",
"python.formatting.provider": "black",
"restructuredtext.confPath": "${workspaceFolder}/lib/esbonio/docs"
}
2 changes: 1 addition & 1 deletion lib/esbonio/esbonio/_version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "0.1.0"
__version__ = "0.0.1"
23 changes: 23 additions & 0 deletions lib/esbonio/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
[build-system]
requires = ["setuptools >= 35.0.2", "wheel >= 0.29.0"]
build-backend = "setuptools.build_meta"

[tool.tox]
legacy_tox_ini = """
[tox]
isolated_build = True

[testenv]
deps =
pytest
commands =
pytest

[testenv:pkg]
deps =
wheel
usedevelop = True
commands =
python setup.py clean --all
python setup.py sdist bdist_wheel
"""
39 changes: 39 additions & 0 deletions scripts/should-build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#!/bin/bash
# Script to check if we should build a given component or not.

# File patterns to check for each component, if there's a match a build will be
# triggered
VSCODE="^code"
PYTHON="^lib/esbonio"

# Determine which files have changed
git diff --name-only ${BASE}..HEAD -- >> changes
echo -e "Files Changed:\n"
cat changes

case $1 in
vscode)
PATTERN=${VSCODE}
;;
python)
PATTERN=${PYTHON}
;;
*)
echo "Unknown component ${1}"
exit 1
;;
esac

changes=$(grep -E "${PATTERN}" changes)
echo
#echo $changes
#echo

rm changes

if [ -z "$changes" ]; then
echo "There is nothing to do."
else
echo "Changes detected, doing build!"
echo "::set-output name=build::true"
fi