├── example_conda_folder ├── conda_build_config.yaml └── meta.yaml ├── example_.github_folder └── workflows │ └── publish_conda.yml ├── action.yml ├── Dockerfile_old ├── Dockerfile ├── LICENSE ├── README.md └── entrypoint.sh /example_conda_folder/conda_build_config.yaml: -------------------------------------------------------------------------------- 1 | python: 2 | - 3.5 3 | - 3.6 4 | - 3.7 5 | -------------------------------------------------------------------------------- /example_.github_folder/workflows/publish_conda.yml: -------------------------------------------------------------------------------- 1 | name: Publish Conda Package 2 | 3 | on: 4 | release: 5 | types: [published, edited] 6 | 7 | jobs: 8 | publish: 9 | runs-on: ubuntu-latest 10 | steps: 11 | - uses: actions/checkout@master 12 | - name: publish-to-conda 13 | uses: fcakyon/conda-publish-action@master 14 | with: 15 | subdir: 'conda' 16 | anacondatoken: ${{ secrets.ANACONDA_TOKEN }} 17 | platforms: 'win osx linux' -------------------------------------------------------------------------------- /action.yml: -------------------------------------------------------------------------------- 1 | name: 'Publish Conda' 2 | description: 'Build and Publish Conda package to Anaconda' 3 | author: 'Fatih C Akyon' 4 | branding: 5 | icon: 'package' 6 | color: 'purple' 7 | inputs: 8 | subdir: 9 | description: 'Sub-directory with conda recipe' 10 | default: '.' 11 | anacondatoken: 12 | description: 'Anaconda access token' 13 | platforms: 14 | description: 'Platforms to publish [osx/linux/win]' 15 | default: 'win osx linux' 16 | runs: 17 | using: 'docker' 18 | image: 'Dockerfile' 19 | -------------------------------------------------------------------------------- /example_conda_folder/meta.yaml: -------------------------------------------------------------------------------- 1 | {% set data = load_setup_py_data() %} 2 | 3 | package: 4 | name: albumentations 5 | version: {{ data['version'] }} 6 | 7 | source: 8 | path: .. 9 | 10 | build: 11 | number: 0 12 | script: python setup.py install --single-version-externally-managed --record=record.txt 13 | 14 | requirements: 15 | build: 16 | - python 17 | - numpy>=1.11.1,<1.16.0 18 | - scipy 19 | - opencv 20 | 21 | run: 22 | - python 23 | - numpy>=1.11.1,<1.16.0 24 | - scipy 25 | - opencv 26 | 27 | test: 28 | imports: 29 | - albumentations 30 | 31 | about: 32 | home: {{ data['url'] }} 33 | license: {{ data['license'] }} 34 | summary: {{ data['description'] }} 35 | -------------------------------------------------------------------------------- /Dockerfile_old: -------------------------------------------------------------------------------- 1 | FROM continuumio/miniconda3:4.7.10 2 | 3 | LABEL "repository"="https://github.com/fcakyon/conda-package-publish-action" 4 | LABEL "maintainer"="Fatih C Akyon" 5 | 6 | RUN apt-get update 7 | # to fix: import cv2 > ImportError: libGL.so.1: cannot open shared object file: No such file or directory 8 | RUN apt-get install -y libgl1-mesa-dev 9 | 10 | # to fix: import cv2 > ImportError: libjasper.so.1: cannot open shared object file: No such file or directory 11 | RUN apt-get install -y software-properties-common 12 | RUN apt-get update 13 | RUN add-apt-repository "deb http://security.ubuntu.com/ubuntu xenial-security main" 14 | RUN apt-get update 15 | RUN apt-get install libjasper1 16 | 17 | RUN conda install -y anaconda-client conda-build conda-verify 18 | 19 | COPY entrypoint.sh /entrypoint.sh 20 | ENTRYPOINT ["/entrypoint.sh"] 21 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM ubuntu:16.04 2 | ENV PATH="/root/miniconda3/bin:${PATH}" 3 | ARG PATH="/root/miniconda3/bin:${PATH}" 4 | RUN apt-get update 5 | 6 | RUN apt-get install -y wget && rm -rf /var/lib/apt/lists/* 7 | 8 | # install miniconda 9 | RUN wget \ 10 | https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh \ 11 | && mkdir /root/.conda \ 12 | && bash Miniconda3-latest-Linux-x86_64.sh -b \ 13 | && rm -f Miniconda3-latest-Linux-x86_64.sh \ 14 | RUN conda --version 15 | 16 | LABEL "repository"="https://github.com/fcakyon/conda-publish-action" 17 | LABEL "maintainer"="Fatih C Akyon" 18 | 19 | RUN apt-get update 20 | # to fix: import cv2 > ImportError: libGL.so.1: cannot open shared object file: No such file or directory 21 | RUN apt-get install -y libgl1-mesa-dev 22 | 23 | # to fix: import cv2 > ImportError: libjasper.so.1: cannot open shared object file: No such file or directory 24 | RUN apt-get install -y libjasper1 25 | 26 | RUN conda install -y anaconda-client conda-build conda-verify 27 | 28 | COPY entrypoint.sh /entrypoint.sh 29 | ENTRYPOINT ["/entrypoint.sh"] -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2019 Andrew Prokhorenkov, 2020 Fatih C Akyon 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Publish Anaconda Package 2 | 3 | A Github Action to publish your software package to an Anaconda repository. 4 | 5 | ### Example workflow to publish to conda every time you make a new release 6 | 7 | ```yaml 8 | name: publish_conda 9 | 10 | on: 11 | release: 12 | types: [published] 13 | 14 | jobs: 15 | publish: 16 | runs-on: ubuntu-latest 17 | steps: 18 | - uses: actions/checkout@v2 19 | - name: publish-to-conda 20 | uses: fcakyon/conda-publish-action@v1.3 21 | with: 22 | subdir: 'conda' 23 | anacondatoken: ${{ secrets.ANACONDA_TOKEN }} 24 | platforms: 'win osx linux' 25 | ``` 26 | 27 | ### Example project structure 28 | 29 | ``` 30 | . 31 | ├── LICENSE 32 | ├── README.md 33 | ├── setup.py 34 | ├── myproject 35 | │   ├── __init__.py 36 | │   └── myproject.py 37 | ├── conda 38 | │ ├── conda_build_config.yaml 39 | │   └── meta.yaml 40 | ├── .github 41 | │   └── workflows 42 | │   └── publish_conda.yml 43 | ├── .gitignore 44 | ``` 45 | 46 | ### ANACONDA_TOKEN 47 | 48 | 1. Get an Anaconda token (with read and write API access) at `anaconda.org/USERNAME/settings/access` 49 | 2. Add it to the Secrets of the Github repository as `ANACONDA_TOKEN` 50 | 51 | ### Supported anaconda channels 52 | - conda-forge 53 | - pytorch 54 | - fcakyon 55 | - districtdatalabs 56 | -------------------------------------------------------------------------------- /entrypoint.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -ex 4 | set -o pipefail 5 | 6 | go_to_build_dir() { 7 | if [ ! -z $INPUT_SUBDIR ]; then 8 | cd $INPUT_SUBDIR 9 | fi 10 | } 11 | 12 | check_if_setup_file_exists() { 13 | if [ ! -f setup.py ]; then 14 | echo "setup.py must exist in the directory that is being packaged and published." 15 | exit 1 16 | fi 17 | } 18 | 19 | check_if_meta_yaml_file_exists() { 20 | if [ ! -f meta.yaml ]; then 21 | echo "meta.yaml must exist in the directory that is being packaged and published." 22 | exit 1 23 | fi 24 | } 25 | 26 | build_package(){ 27 | # Build for Linux 28 | conda build -c conda-forge -c pytorch -c fcakyon -c districtdatalabs --output-folder . . 29 | 30 | # Convert to other platforms: OSX, WIN 31 | if [[ $INPUT_PLATFORMS == *"osx"* ]]; then 32 | conda convert -p osx-64 linux-64/*.tar.bz2 33 | fi 34 | if [[ $INPUT_PLATFORMS == *"win"* ]]; then 35 | conda convert -p win-64 linux-64/*.tar.bz2 36 | fi 37 | } 38 | 39 | upload_package(){ 40 | export ANACONDA_API_TOKEN=$INPUT_ANACONDATOKEN 41 | if [[ $INPUT_PLATFORMS == *"osx"* ]]; then 42 | anaconda upload --label main osx-64/*.tar.bz2 43 | fi 44 | if [[ $INPUT_PLATFORMS == *"linux"* ]]; then 45 | anaconda upload --label main linux-64/*.tar.bz2 46 | fi 47 | if [[ $INPUT_PLATFORMS == *"win"* ]]; then 48 | anaconda upload --label main win-64/*.tar.bz2 49 | fi 50 | } 51 | 52 | check_if_setup_file_exists 53 | go_to_build_dir 54 | check_if_meta_yaml_file_exists 55 | build_package 56 | upload_package 57 | --------------------------------------------------------------------------------