Skip to content

Commit

Permalink
Try to implement an "upload nightly" github action.
Browse files Browse the repository at this point in the history
All in one commit
  • Loading branch information
Carreau committed May 22, 2023
0 parents commit 8f0394f
Show file tree
Hide file tree
Showing 5 changed files with 143 additions and 0 deletions.
6 changes: 6 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
FROM continuumio/miniconda3:latest

COPY entrypoint.sh /entrypoint.sh
RUN chmod +x /entrypoint.sh

ENTRYPOINT ["/entrypoint.sh"]
29 changes: 29 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
BSD 3-Clause License

Copyright (c) 2022, Scientific Python
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:

1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.

2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.

3. Neither the name of the copyright holder nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
46 changes: 46 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# nightly uplolad.


This provides a standard GitHub Action to upload nightly builds to the
scientific-python nightly channel.

In your Continuous Intregration pipeline once you've built you wheel, you can
use the following snippet to upload to our central nightly repository:


```yml
jobs:
steps:
...
- name: Upload wheel
uses: scientific-python/upload-nightly-action@main
with:
artifacts_path: dist
anaconda_nightly_upload_token: ${{secrets.UPLOAD_TOKEN}}
```
To request access to the repository please open an issue on [this action
repository](https://github.com/scientific-python/upload-nightly-action). You can
then generate a token at `https://anaconda.org/<username>/settings/access`, check
minimum permissions and add the token as a secret to your GitHub repository.


# using nightly builds in CI.

To test those nightly build, you can use the following command to install from
the nightly package.

```
python -m pip install matplotlib -i https://pypi.org/simple -i https://pypi.anaconda.org/scientific-python-nightly-wheels/simple --upgrade --pre
```
Note that second `-i` parameter will take priority, it needs to come second if
you want to pull from nightly otherwise it will pull from pypi.
```
if package in nightly:
try to install from nightly
else:
try to install from pypi
```
20 changes: 20 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: Upload Nightly
description: A GitHub Action to upload artifacts nightly
permissions:
actions: read
contents: read
metadata: read
author: "Scientific-Python"
version: "1.0.0"

inputs:
artifacts_path:
description: 'Path to the artifacts directory where wheels to upload are present'
required: true
anaconda_nightly_upload_token:
description: 'Token to upload to scientific python org'
required: true

runs:
using: 'docker'
image: 'Dockerfile'
42 changes: 42 additions & 0 deletions entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#!/bin/bash

# fail on undefined variables
set -u
# Prevent pipe errors to be silenced
set -o pipefail
# Exit if any command exit as non-zero
set -e
# enable trace mode (print what it does)
set -x

# get the anaconda token from the github secrets
#
# this is to prevent accidental uploads
echo "Getting anaconda token from github secrets..."

ANACONDA_ORG="scientific-python-nightly-wheels"
ANACONDA_TOKEN="$INPUT_ANACONDA_NIGHTLY_UPLOAD_TOKEN"

# if the ANACONDA_TOKEN is empty, exit with status -1
# this is to prevent accidental uploads
if [ -z "$ANACONDA_TOKEN" ]; then
echo "ANACONDA_TOKEN is empty , exiting..."
exit -1
fi

# install anaconda-client
echo "Installing anaconda-client..."

conda install -y anaconda-client -c conda-forge

# trim trailing slashes from $INPUT_ARTIFACTS_PATH
INPUT_ARTIFACTS_PATH="${INPUT_ARTIFACTS_PATH%/}"

# debug, print env
env

# upload wheels
echo "Uploading wheels to anaconda.org..."

anaconda -t $ANACONDA_TOKEN upload --force -u "$ANACONDA_ORG" "$INPUT_ARTIFACTS_PATH"/*.whl
echo "Index: https://pypi.anaconda.org/$ANACONDA_ORG/simple"

0 comments on commit 8f0394f

Please sign in to comment.