This repository has been archived by the owner on Aug 2, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 63
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(action): add initial version of Github action
- Loading branch information
Showing
3 changed files
with
75 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"] | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |