Skip to content

phyluce v1.7.3

phyluce v1.7.3 #27

Workflow file for this run

name: Packaging
on:
release:
types: [published]
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
jobs:
dependencies:
name: Make conda environment file
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-20.04, macos-latest]
# If we set the default shell here, it catches the activated conda
# and we don't need to keep calling it.
defaults:
run:
shell: bash -l {0}
steps:
- name: Check out Git repository
uses: actions/checkout@v2
# setup cache for conda files
- name: Cache conda packages
uses: actions/cache@v1
env:
# Increase this value to reset cache if
# etc/example-environment.yml has not changed
CACHE_NUMBER: 0
with:
path: ~/conda_pkgs_dir
key:
${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-${{hashFiles('etc/phyluce-testing-environment.yml') }}
# we'll use the handy conda incubator miniconda package
- name: Set miniconda up
uses: conda-incubator/setup-miniconda@v2.0.1
with:
auto-update-conda: true
python-version: 3.6
environment-file: etc/phyluce-testing-environment.yml
- name: Create environment variables for output
run: |
VERSION=$(python setup.py --version)
echo "phyluce_outf=distrib/phyluce-${VERSION}-py36-${{ runner.os }}-conda.yml" >> $GITHUB_ENV
echo "phyluce_ver=$VERSION" >> $GITHUB_ENV
# echo ${{ github.event.release.tag_name }} >> distrib/linux.yml
- name: Add environment to file and commit
run: |
mkdir -p distrib
conda env export --no-builds | grep -v "^channels:" | grep -v "^name: " | grep -v "^prefix: " > temp-environment.yml
echo "# `date`" > ${{ env.phyluce_outf }}
echo "channels:" >> ${{ env.phyluce_outf }}
cat temp-environment.yml >> ${{ env.phyluce_outf }}
rm temp-environment.yml
echo " - phyluce=${{ env.phyluce_ver }}" >> ${{ env.phyluce_outf }}
git config user.name github-actions
git config user.email github-actions@github.com
git pull origin main
git checkout main
git add .
git commit -m "Auto-updating dependency files"
git push origin main
build-package:
name: Build conda package
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-20.04, macos-latest]
# If we set the default shell here, it catches the activated conda
# and we don't need to keep calling it.
defaults:
run:
shell: bash -l {0}
steps:
- name: Check out Git repository
uses: actions/checkout@v2
- name: Set miniconda up
uses: conda-incubator/setup-miniconda@v2.0.1
with:
auto-update-conda: true
python-version: 3.6
- name: Install conda build tools
run: |
conda install conda-build anaconda-client
- name: Build phyluce
run: |
cd conda
conda build phyluce --token ${{ secrets.ANACONDA_TOKEN }} --label phyluce
build-docker:
name: Build docker image
needs: [dependencies, build-package]
runs-on: ubuntu-20.04
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Prepare
id: prep
run: |
echo "PHYLUCE_VERSION=$(python setup.py --version)" >> $GITHUB_ENV
DOCKER_IMAGE=fairclothlab/phyluce
VERSION=$(python setup.py --version)
TAGS="${DOCKER_IMAGE}:${VERSION},${DOCKER_IMAGE}:latest"
if [ "${{ github.event_name }}" = "push" ]; then
TAGS="$TAGS,${DOCKER_IMAGE}:sha-${GITHUB_SHA::8}"
fi
echo ::set-output name=version::${VERSION}
echo ::set-output name=tags::${TAGS}
echo ::set-output name=created::$(date -u +'%Y-%m-%dT%H:%M:%SZ')
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Login to DockerHub
if: github.event_name != 'pull_request'
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Build and push
uses: docker/build-push-action@v2
with:
context: .
file: docker/Dockerfile
build-args: PHYLUCE_VERSION=${{ env.PHYLUCE_VERSION }}
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.prep.outputs.tags }}
labels: |
org.opencontainers.image.source=${{ github.event.repository.html_url }}
org.opencontainers.image.created=${{ steps.prep.outputs.created }}
org.opencontainers.image.revision=${{ github.sha }}