Skip to content

Commit 86fd239

Browse files
authored
Autorelease GitHub (#29)
GitHub auto-releases from master
1 parent b3da76f commit 86fd239

File tree

2 files changed

+51
-16
lines changed

2 files changed

+51
-16
lines changed

.circleci/config.yml

Lines changed: 49 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,6 @@
11
defaults: &defaults
22
parallelism: 1
33
shell: /bin/bash --login
4-
environment:
5-
CIRCLE_ARTIFACTS: /tmp/circleci-artifacts
6-
CIRCLE_TEST_REPORTS: /tmp/circleci-test-results
7-
# CODECOV_TOKEN: b0d35139-0a75-427a-907b-2c78a762f8f0
8-
VERSION: 0.1.0
9-
PANDOC_RELEASES_URL: https://github.com/jgm/pandoc/releases
10-
YARN_STATIC_DIR: notebooker/web/static/
11-
IMAGE_NAME: mangroup/notebooker
124
steps:
135
- checkout
146
- run: mkdir -p $CIRCLE_ARTIFACTS $CIRCLE_TEST_REPORTS
@@ -116,7 +108,7 @@ defaults: &defaults
116108
. ci/bin/activate
117109
pip install -e ".[docs]"
118110
python setup.py build_sphinx
119-
cp -r ./build /tmp/circleci-artifacts
111+
cp -r ./build "$CIRCLE_ARTIFACTS"
120112
# Build egg
121113
- run:
122114
name: Build egg
@@ -127,20 +119,21 @@ defaults: &defaults
127119
pip install Pygments
128120
python setup.py --long-description > ../README.rst
129121
cat ../README.rst | rst2html.py 1> ../README.html 2> ../log
130-
cp ../README.rst /tmp/circleci-artifacts
131-
cp ../log /tmp/circleci-artifacts
122+
cp ../README.rst "$CIRCLE_ARTIFACTS"
123+
cp ../log "$CIRCLE_ARTIFACTS"
132124
if [ -s ../log ] ; then
133125
cat ../log
134126
exit 1
135127
fi # rst2html.py alwaysexits with 0, check log size
136128
python setup.py bdist_wheel --universal
137129
python setup.py bdist_egg
138130
python setup.py sdist
139-
cp -r ./dist /tmp/circleci-artifacts
140-
# - run:
141-
# name: Build Docker image
142-
# command: docker build -t $IMAGE_NAME:latest .
143-
# Save test results
131+
mkdir -p "$CIRCLE_ARTIFACTS/dist"
132+
cp -r ./dist/* "$CIRCLE_ARTIFACTS/dist"
133+
- run:
134+
name: Upload to PyPI
135+
command: |
136+
echo $VERSION > "$CIRCLE_ARTIFACTS/version.txt"
144137
- run:
145138
name: Upload to PyPI
146139
command: |
@@ -159,21 +152,61 @@ defaults: &defaults
159152
path: /tmp/circleci-artifacts
160153
- store_artifacts:
161154
path: test-results
155+
- persist_to_workspace:
156+
root: /tmp/circleci-artifacts
157+
paths:
158+
- ./*/version.txt
159+
- ./*/dist/*
162160
version: 2
163161
jobs:
164162
build_3_6:
163+
environment:
164+
PYTHON_VERSION: "3_6"
165+
CIRCLE_ARTIFACTS: /tmp/circleci-artifacts/3_6
166+
CIRCLE_TEST_REPORTS: /tmp/circleci-test-results/3_6
167+
VERSION: 0.1.0
168+
PANDOC_RELEASES_URL: https://github.com/jgm/pandoc/releases
169+
YARN_STATIC_DIR: notebooker/web/static/
170+
IMAGE_NAME: mangroup/notebooker
165171
working_directory: ~/notebooker_3_6
166172
docker:
167173
- image: cimg/python:3.6-node
168174
<<: *defaults
169175
build_3_7:
176+
environment:
177+
CIRCLE_ARTIFACTS: /tmp/circleci-artifacts/3_7
178+
CIRCLE_TEST_REPORTS: /tmp/circleci-test-results/3_7
179+
VERSION: 0.1.0
180+
PANDOC_RELEASES_URL: https://github.com/jgm/pandoc/releases
181+
YARN_STATIC_DIR: notebooker/web/static/
182+
IMAGE_NAME: mangroup/notebooker
170183
working_directory: ~/notebooker_3_7
171184
docker:
172185
- image: cimg/python:3.7-node
173186
<<: *defaults
187+
publish-github-release:
188+
docker:
189+
- image: cibuilds/github:0.10
190+
steps:
191+
- attach_workspace:
192+
at: /tmp/circleci-artifacts
193+
- run:
194+
name: "Publish release on GitHub"
195+
command: |
196+
ls -la /tmp/circleci-artifacts/3_6
197+
VERSION=$(cat /tmp/circleci-artifacts/3_6/version.txt)
198+
ghr -t ${GITHUB_TOKEN} -u ${CIRCLE_PROJECT_USERNAME} -r ${CIRCLE_PROJECT_REPONAME} -c ${CIRCLE_SHA1} -delete ${VERSION} /tmp/circleci-artifacts/3_6/dist
174199
workflows:
175200
version: 2
176201
build_all:
177202
jobs:
178203
- build_3_6
179204
- build_3_7
205+
- publish-github-release:
206+
requires:
207+
- build_3_6
208+
- build_3_7
209+
filters:
210+
branches:
211+
only:
212+
- master

notebooker/_entrypoints.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
import click
55

6+
from notebooker._version import __version__
67
from notebooker.constants import DEFAULT_SERIALIZER
78
from notebooker.execute_notebook import execute_notebook_entrypoint
89
from notebooker.serialization import SERIALIZER_TO_CLI_OPTIONS
@@ -31,6 +32,7 @@ def filesystem_default_value(dirname):
3132

3233

3334
@click.group(cls=NotebookerEntrypoint)
35+
@click.version_option(__version__, prog_name="Notebooker")
3436
@click.option("--notebook-kernel-name", default=None, help="The name of the kernel which is running our notebook code.")
3537
@click.option(
3638
"--output-base-dir",

0 commit comments

Comments
 (0)