Skip to content

Commit 8f0394f

Browse files
committed
Try to implement an "upload nightly" github action.
All in one commit
0 parents  commit 8f0394f

5 files changed

Lines changed: 143 additions & 0 deletions

File tree

Dockerfile

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
FROM continuumio/miniconda3:latest
2+
3+
COPY entrypoint.sh /entrypoint.sh
4+
RUN chmod +x /entrypoint.sh
5+
6+
ENTRYPOINT ["/entrypoint.sh"]

LICENSE

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
BSD 3-Clause License
2+
3+
Copyright (c) 2022, Scientific Python
4+
All rights reserved.
5+
6+
Redistribution and use in source and binary forms, with or without
7+
modification, are permitted provided that the following conditions are met:
8+
9+
1. Redistributions of source code must retain the above copyright notice, this
10+
list of conditions and the following disclaimer.
11+
12+
2. Redistributions in binary form must reproduce the above copyright notice,
13+
this list of conditions and the following disclaimer in the documentation
14+
and/or other materials provided with the distribution.
15+
16+
3. Neither the name of the copyright holder nor the names of its
17+
contributors may be used to endorse or promote products derived from
18+
this software without specific prior written permission.
19+
20+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
24+
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
26+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
27+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
28+
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

README.md

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# nightly uplolad.
2+
3+
4+
This provides a standard GitHub Action to upload nightly builds to the
5+
scientific-python nightly channel.
6+
7+
In your Continuous Intregration pipeline once you've built you wheel, you can
8+
use the following snippet to upload to our central nightly repository:
9+
10+
11+
```yml
12+
jobs:
13+
steps:
14+
...
15+
- name: Upload wheel
16+
uses: scientific-python/upload-nightly-action@main
17+
with:
18+
artifacts_path: dist
19+
anaconda_nightly_upload_token: ${{secrets.UPLOAD_TOKEN}}
20+
```
21+
22+
23+
To request access to the repository please open an issue on [this action
24+
repository](https://github.com/scientific-python/upload-nightly-action). You can
25+
then generate a token at `https://anaconda.org/<username>/settings/access`, check
26+
minimum permissions and add the token as a secret to your GitHub repository.
27+
28+
29+
# using nightly builds in CI.
30+
31+
To test those nightly build, you can use the following command to install from
32+
the nightly package.
33+
34+
```
35+
python -m pip install matplotlib -i https://pypi.org/simple -i https://pypi.anaconda.org/scientific-python-nightly-wheels/simple --upgrade --pre
36+
```
37+
38+
Note that second `-i` parameter will take priority, it needs to come second if
39+
you want to pull from nightly otherwise it will pull from pypi.
40+
41+
```
42+
if package in nightly:
43+
try to install from nightly
44+
else:
45+
try to install from pypi
46+
```

action.yml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
name: Upload Nightly
2+
description: A GitHub Action to upload artifacts nightly
3+
permissions:
4+
actions: read
5+
contents: read
6+
metadata: read
7+
author: "Scientific-Python"
8+
version: "1.0.0"
9+
10+
inputs:
11+
artifacts_path:
12+
description: 'Path to the artifacts directory where wheels to upload are present'
13+
required: true
14+
anaconda_nightly_upload_token:
15+
description: 'Token to upload to scientific python org'
16+
required: true
17+
18+
runs:
19+
using: 'docker'
20+
image: 'Dockerfile'

entrypoint.sh

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
#!/bin/bash
2+
3+
# fail on undefined variables
4+
set -u
5+
# Prevent pipe errors to be silenced
6+
set -o pipefail
7+
# Exit if any command exit as non-zero
8+
set -e
9+
# enable trace mode (print what it does)
10+
set -x
11+
12+
# get the anaconda token from the github secrets
13+
#
14+
# this is to prevent accidental uploads
15+
echo "Getting anaconda token from github secrets..."
16+
17+
ANACONDA_ORG="scientific-python-nightly-wheels"
18+
ANACONDA_TOKEN="$INPUT_ANACONDA_NIGHTLY_UPLOAD_TOKEN"
19+
20+
# if the ANACONDA_TOKEN is empty, exit with status -1
21+
# this is to prevent accidental uploads
22+
if [ -z "$ANACONDA_TOKEN" ]; then
23+
echo "ANACONDA_TOKEN is empty , exiting..."
24+
exit -1
25+
fi
26+
27+
# install anaconda-client
28+
echo "Installing anaconda-client..."
29+
30+
conda install -y anaconda-client -c conda-forge
31+
32+
# trim trailing slashes from $INPUT_ARTIFACTS_PATH
33+
INPUT_ARTIFACTS_PATH="${INPUT_ARTIFACTS_PATH%/}"
34+
35+
# debug, print env
36+
env
37+
38+
# upload wheels
39+
echo "Uploading wheels to anaconda.org..."
40+
41+
anaconda -t $ANACONDA_TOKEN upload --force -u "$ANACONDA_ORG" "$INPUT_ARTIFACTS_PATH"/*.whl
42+
echo "Index: https://pypi.anaconda.org/$ANACONDA_ORG/simple"

0 commit comments

Comments
 (0)