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

Commit

Permalink
feat(action): add initial version of Github action
Browse files Browse the repository at this point in the history
  • Loading branch information
m0nhawk committed Apr 1, 2019
1 parent 2834e26 commit c5921c9
Show file tree
Hide file tree
Showing 3 changed files with 75 additions and 0 deletions.
14 changes: 14 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
FROM continuumio/miniconda3:4.5.12

LABEL "com.github.actions.name"="Publish Anaconda Package"
LABEL "com.github.actions.description"="Package and publish Anaconda modules."
LABEL "com.github.actions.icon"="package"
LABEL "com.github.actions.color"="purple"

LABEL "repository"="https://github.com/m0nhawk/conda-package-publish-action"
LABEL "maintainer"="Andrew Prokhorenkov <[email protected]>"

RUN conda install anaconda-client conda-build

ADD entrypoint.sh /entrypoint.sh
ENTRYPOINT ["/entrypoint.sh"]
25 changes: 25 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Publish Anacond Package
A Github Action to publish your Python package to Anaconda repository.

## Use
Doesn't take any arguments.

### Environment Variables/Secrets
- Login credentials for the package repo:
- `ANACONDA_USERNAME`=`foo`
- `ANACONDA_PASSWORD`=`bar`
etc.
- `SUBDIR` (optional): if your `setup.py` and `meta.yaml` is in a subdirectory of your repo. This will just change the working directory to the `SUBDIR` before running the rest of the script.

### Example workflow
```hcl
workflow "Publish" {
resolves = ["publish-to-conda"]
on = "release"
}
action "publish-to-conda" {
uses = "m0nhawk/conda-package-publish-action@master"
secrets = ["ANACONDA_USERNAME", "ANACONDA_PASSWORD"]
}
```
36 changes: 36 additions & 0 deletions entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#!/bin/bash

set -ex
set -o pipefail

go_to_build_dir() {
if [ ! -z $SUBDIR ]; then
cd $SUBDIR
fi
}

check_if_setup_file_exists() {
if [ ! -f setup.py ]; then
echo "setup.py must exist in the directory that is being packaged and published."
exit 1
fi
}

check_if_meta_yaml_file_exists() {
if [ ! -f meta.yaml ]; then
echo "meta.yaml must exist in the directory that is being packaged and published."
exit 1
fi
}

upload_package(){
conda config --set anaconda_upload yes
anaconda login --username $ANACONDA_USERNAME --password $ANACONDA_PASSWORD
conda build .
anaconda logout
}

go_to_build_dir
check_if_setup_file_exists
check_if_meta_yaml_file_exists
upload_package

0 comments on commit c5921c9

Please sign in to comment.