v1.0.0 #22
Workflow file for this run
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
name: publish_conda | |
on: | |
release: | |
types: [published] | |
# Allows you to run this workflow manually from the Actions tab | |
workflow_dispatch: | |
jobs: | |
publish: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Set up Python | |
uses: actions/setup-python@v3 | |
with: | |
python-version: '3.12' | |
- name: Install build environment | |
run: | | |
conda --version | |
conda install -y anaconda-client conda-build conda-verify | |
- name: Fetch tags and show version | |
run: | | |
git fetch --prune --unshallow --tags # checkout action does not get these | |
git describe --tags --dirty --always | |
- name: Check for meta.yaml | |
run: | | |
if [ ! -f conda-recipe/meta.yaml ]; then | |
echo "meta.yaml file not found in conda-recipe directory" | |
exit 1 | |
fi | |
- name: List all files in the current directory | |
run: ls -R | |
- name: List files in conda-recipe directory | |
run: ls -R conda-recipe | |
- name: Build package | |
run: | | |
export current_dir=$(pwd) | |
export INPUT_SUBDIR=$current_dir/'conda-recipe' | |
export OUTPUT_SUBDIR=$current_dir/'conda-recipe/output' | |
export INPUT_PLATFORMS='win osx linux' | |
echo $current_dir | |
echo $INPUT_SUBDIR | |
echo $OUTPUT_SUBDIR | |
set -ex | |
set -o pipefail | |
go_to_build_dir() { | |
if [ ! -z $INPUT_SUBDIR ]; then | |
cd $INPUT_SUBDIR | |
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 | |
} | |
build_package(){ | |
# Build for Linux | |
mkdir -p output | |
# for some reason, a newer version of conda build renames the workfolder, causing trouble downstream. | |
#conda build -c conda-forge -c pytorch -c os-simopt --no-test --output-folder $OUTPUT_SUBDIR . | |
conda build -c conda-forge -c pytorch -c os-simopt --no-test --keep-old-work --output-folder $OUTPUT_SUBDIR . | |
# Convert to other platforms: OSX, WIN | |
if [[ $INPUT_PLATFORMS == *"osx"* ]]; then | |
conda convert -p osx-64 $OUTPUT_SUBDIR/linux-64/*.tar.bz2 -o $OUTPUT_SUBDIR | |
fi | |
if [[ $INPUT_PLATFORMS == *"win"* ]]; then | |
conda convert -p win-64 $OUTPUT_SUBDIR/linux-64/*.tar.bz2 -o $OUTPUT_SUBDIR | |
fi | |
} | |
go_to_build_dir() { | |
cd $current_dir | |
} | |
go_to_build_dir | |
check_if_meta_yaml_file_exists | |
build_package | |
go_to_curr_dir | |
- name: List files in output | |
run: | | |
export current_dir=$(pwd) | |
export INPUT_SUBDIR=$current_dir/'conda-recipe' | |
export OUTPUT_SUBDIR=$current_dir/'conda-recipe/output' | |
pwd | |
echo $current_dir | |
echo $OUTPUT_SUBDIR | |
ls -R $OUTPUT_SUBDIR | |
- name: publish-to-conda | |
run: | | |
export INPUT_ANACONDATOKEN=${{ secrets.ANACONDA_TOKEN }} | |
export current_dir=$(pwd) | |
export INPUT_SUBDIR=$current_dir/'conda-recipe' | |
export OUTPUT_SUBDIR=$current_dir/'conda-recipe/output' | |
# could use a check if any of the expected files actually exist... | |
upload_package(){ | |
export ANACONDA_API_TOKEN=$INPUT_ANACONDATOKEN | |
if [[ $INPUT_PLATFORMS == *"osx"* ]]; then | |
anaconda upload --label main $OUTPUT_SUBDIR/osx-64/*.tar.bz2 | |
fi | |
if [[ $INPUT_PLATFORMS == *"linux"* ]]; then | |
anaconda upload --label main $OUTPUT_SUBDIR/linux-64/*.tar.bz2 | |
fi | |
if [[ $INPUT_PLATFORMS == *"win"* ]]; then | |
anaconda upload --label main $OUTPUT_SUBDIR/win-64/*.tar.bz2 | |
fi | |
} | |
upload_package | |