Skip to content

Version 3.1.3, automatic PyPI uploads #199

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

Merged
merged 1 commit into from
Jul 2, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 56 additions & 3 deletions circle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,6 @@ jobs:
virtualenv venv
. venv/bin/activate
pip install -U pip wheel
# Temporarily pin setuptools to a specific version.
# See commit message of https://github.com/open-craft/problem-builder/commit/51277a34fb426724616618c1afdb893ab2de4c6b for more info:
pip install setuptools==24.3.1
pip install -e git://github.com/edx/xblock-sdk.git@bddf9f4a2c6e4df28a411c8f632cc2250170ae9d#egg=xblock-sdk
pip install -r requirements.txt
pip install -r venv/src/xblock-sdk/requirements/base.txt
Expand Down Expand Up @@ -45,3 +42,59 @@ jobs:
if [ $CIRCLE_NODE_INDEX = '1' ]; then pylint problem_builder --disable=all --enable=function-redefined,undefined-variable,unused-import,unused-variable; fi
TESTFILES=$(circleci tests glob "problem_builder/v1/tests/**/*.py" "problem_builder/tests/**/*.py"| circleci tests split)
xvfb-run --server-args="-screen 0 1280x1024x24" python run_tests.py ${TESTFILES}

deploy:
docker:
- image: circleci/python:2.7.14
steps:
- checkout
- restore_cache:
key: dependencies-{{ checksum "circle.yml" }}-{{ checksum "setup.py" }}
- run:
name: Install dependencies
command: |
virtualenv venv
. venv/bin/activate
pip install -U pip twine wheel
- save_cache:
key: dependencies-{{ checksum "circle.yml" }}-{{ checksum "setup.py" }}
paths:
- "venv"
- run:
name: Verify commit is tagged and tag matches version
command: |
. venv/bin/activate
python setup.py verify_tag
- run:
name: Initialize .pypirc
command: |
echo -e "[pypi]" >> ~/.pypirc
echo -e "username = opencraft" >> ~/.pypirc
echo -e "password = $PYPI_PASSWORD" >> ~/.pypirc
- run:
name: Create packages
command: |
python setup.py sdist
python setup.py bdist_wheel
- run:
name: Upload to pypi
command: |
. venv/bin/activate
twine upload dist/*

workflows:
version: 2
build_and_deploy:
jobs:
- build:
filters:
tags:
only: /.*/
- deploy:
requires:
- build
filters:
tags:
only: /v[0-9]+(\.[0-9]+)*/
branches:
ignore: /.*/
26 changes: 25 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,14 @@
# Imports ###########################################################

import os
import sys
from setuptools import setup, find_packages
from setuptools.command.install import install


# Constants #########################################################

VERSION = '3.1.3'


# Functions #########################################################
Expand All @@ -37,6 +44,20 @@ def package_data(pkg, root_list):
return {pkg: data}


class VerifyTagCommand(install):
"""Custom command to verify that the git tag matches the current version."""
description = 'verify that the git tag matches the current version'

def run(self):
tag = os.getenv('CIRCLE_TAG')

if tag != 'v{}'.format(VERSION):
info = "Git tag: {0} does not match the version of this app: {1}".format(
tag, VERSION
)
sys.exit(info)


# Main ##############################################################

BLOCKS = [
Expand Down Expand Up @@ -72,7 +93,7 @@ def package_data(pkg, root_list):

setup(
name='xblock-problem-builder',
version='3.1.2',
version=VERSION,
description='XBlock - Problem Builder',
packages=find_packages(),
install_requires=[
Expand All @@ -83,4 +104,7 @@ def package_data(pkg, root_list):
'xblock.v1': BLOCKS,
},
package_data=package_data("problem_builder", ["templates", "public", "migrations"]),
cmdclass={
'verify_tag': VerifyTagCommand,
},
)