Skip to content

Commit

Permalink
Merge pull request #3 from mmacata/wheel-build-adjustments
Browse files Browse the repository at this point in the history
Prepare for wheel building
  • Loading branch information
mmacata authored Jan 7, 2020
2 parents 63236de + 1be6d69 commit f7d9317
Show file tree
Hide file tree
Showing 5 changed files with 87 additions and 2 deletions.
33 changes: 33 additions & 0 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
FROM alpine:edge as build

RUN apk add git python3
RUN pip3 install --upgrade pip pep517 wheel

# Build
COPY . /src/actinia_statistic_plugin
WORKDIR /src/actinia_statistic_plugin
# TODO: include tests. Currently only running whith actinia_core installed
# RUN pip3 install -r requirements.txt && python3 setup.py test
RUN python3 -m pep517.build --out-dir /build . && \
pip3 wheel -r requirements.txt -w /build


FROM alpine:edge

COPY --from=build /build/actinia*.whl /build/
COPY docker/create_release_with_asset.sh .

ARG release_url=https://api.github.com/repos/mundialis/actinia_statistic_plugin/releases
ARG tag=0.0
ARG credentials=dummy:dummy
ARG file=/build/actinia*.whl

ENV env_release_url=$release_url
ENV env_tag=$tag
ENV env_credentials=$credentials
ENV env_file=$file

RUN apk add curl jq

ENTRYPOINT ["/bin/sh"]
CMD ["./create_release_with_asset.sh"]
21 changes: 21 additions & 0 deletions docker/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
To create a new release, you can use this docker to build the wheel and add
to the release.

The `docker build` command builds the wheel and integrated the build-args for
the github release.

The `docker run` command creates the build and uploads the
before created wheel as asset.


```
git clone [email protected]:mundialis/actinia_statistic_plugin.git
cd actinia_statistic_plugin
tag=0.0
credentials=mygithubuser:mygithubpw
docker build --file docker/Dockerfile --build-arg tag=$tag --build-arg credentials=$credentials --tag actinia_statistic_plugin:build .
docker run --rm actinia_statistic_plugin:build
```
28 changes: 28 additions & 0 deletions docker/create_release_with_asset.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/bin/sh

# needed to be set as ENVs before:
#env_release_url
#env_tag
#env_credentials
#env_file

filefull=`ls $env_file`
filename=$(basename $filefull)


echo "{\"tag_name\": \"$env_tag\",\"target_commitish\": \"master\",\"name\":\"$env_tag\",\"body\": \"Automatically created by CI\",\"draft\": false,\"prerelease\": false}" > /tmp/release_payload.json

# Create release
curl -u $env_credentials -X POST -H 'Content-Type: application/json' -d @/tmp/release_payload.json $env_release_url > resp.json && cat resp.json

# parse response to create upload_url
upload_url=`cat resp.json | jq '.upload_url' | tr -d '"' | cut -d '{' -f1`
url=$upload_url?name=$filename

if [ "$upload_url" == "null" ]
then
echo "Failed to create release, aborting."
exit 1
fi

curl -u $env_credentials -H "Accept: application/vnd.github.manifold-preview" -H "Content-Type: application/zip" --data-binary @$filefull "$url" > resp.json && cat resp.json
3 changes: 3 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[build-system]
requires = ["setuptools>=40.6.0", "wheel"]
build-backend = "setuptools.build_meta"
4 changes: 2 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
# Remember to also add them in setup.cfg but unpinned.
#
# iny sync with requirements for actinia_core
Flask==0.12.3
Flask-RESTful==0.3.6
Flask>=0.12.3
Flask-RESTful>=0.3.6

0 comments on commit f7d9317

Please sign in to comment.