Skip to content
This repository has been archived by the owner on Aug 9, 2023. It is now read-only.

Commit

Permalink
Merge pull request #53 from wellcometrust/feature/antonio/create_rele…
Browse files Browse the repository at this point in the history
…ase_programatically

Create release programatically and change docs
  • Loading branch information
aCampello authored May 20, 2020
2 parents 7dd9ac6 + 3c9c83c commit 912ab25
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 5 deletions.
5 changes: 1 addition & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,7 @@ update-requirements-txt:

.PHONY: dist
dist:
$(VIRTUALENV)/bin/python3 setup.py sdist bdist_wheel
aws s3 sync dist/ s3://datalabs-packages/wellcomeml
aws s3 cp --recursive --acl public-read dist/ s3://datalabs-public/wellcomeml
$(VIRTUALENV)/bin/python -m twine upload --repository pypi --username ${TWINE_USERNAME} --password ${TWINE_PASSWORD} dist/*
./create_release.sh

# Spacy is require for testing spacy_to_prodigy

Expand Down
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,12 @@ pip install wellcomeml-2020.1.0-py3-none-any.whl[deep-learning]
make
```

### 2.2 Build the wheel (and upload to aws s3)
### 2.2 Build the wheel (and upload to aws s3/pypi/github)

Create a [github token](https://help.github.com/en/github/authenticating-to-github/creating-a-personal-access-token-for-the-command-line) with artifact write access and export it to the env variables:
```bash
export GITHUB_TOKEN=...
```
After making changes, in order to buil a new wheel, run:

```
Expand Down
41 changes: 41 additions & 0 deletions create_release.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#!/bin/sh
VERSION=$(python setup.py --version)
VIRTUALENV=build/virtualenv

echo "\x1B[31m******* DANGER ********\x1B[0m"
echo Creating a new release for v$VERSION
echo This is going to upload files to upload files to AWS, create a github release and change the pypi registry
read -p 'Are you sure you want to proceed (y/n)? ' PROCEED

if [[ ! $PROCEED =~ ^[Yy]$ ]]
then
exit 1
fi

$VIRTUALENV/bin/python3 setup.py sdist bdist_wheel
aws s3 sync dist/ s3://datalabs-packages/wellcomeml
aws s3 cp --recursive --acl public-read dist/ s3://datalabs-public/wellcomeml
$VIRTUALENV/bin/python -m twine upload --repository pypi --username $TWINE_USERNAME --password $TWINE_PASSWORD dist/*


curl --request POST \
--url https://api.github.com/repos/wellcometrust/wellcomeml/releases \
--header 'authorization: token '$GITHUB_TOKEN'' \
--header 'content-type: application/json' \
--data '{
"tag_name": "v'$VERSION'",
"target_commitish": "master",
"name": "v'$VERSION'",
"prerelease": true
}'


RELEASE_ID=$(curl -XGET --silent "https://api.github.com/repos/wellcometrust/WellcomeML/releases/tags/v$VERSION" | jq .id)

cd dist/

curl --request POST --silent --header "Authorization: token $GITHUB_TOKEN" -H "Content-Type: $(file -b --mime-type wellcomeml-$VERSION.tar.gz)" --data-binary @wellcomeml-$VERSION.tar.gz --url "https://uploads.github.com/repos/wellcometrust/WellcomeML/releases/$RELEASE_ID/assets?name=wellcomeml-$VERSION.tar.gz"
curl --request POST --silent --header "Authorization: token $GITHUB_TOKEN" -H "Content-Type: $(file -b --mime-type wellcomeml-$VERSION.tar.gz)" --data-binary @wellcomeml-$VERSION.tar.gz --url "https://uploads.github.com/repos/wellcometrust/WellcomeML/releases/$RELEASE_ID/assets?name=wellcomeml-$VERSION-py3-none-any.whl"

echo "Release created"
echo "Please change the description at https://github.com/wellcometrust/WellcomeML/releases/tag/v$VERSION"

0 comments on commit 912ab25

Please sign in to comment.