repo2docker/.github/workflows/release.yml

106 wiersze
3.4 KiB
YAML

name: Publish
on:
push:
pull_request:
jobs:
build-n-publish:
runs-on: ubuntu-18.04
steps:
- uses: actions/checkout@v2
- name: "Setup Python 3.8"
uses: actions/setup-python@v2
with:
python-version: "3.8"
- name: "Install dependencies"
run: |
pip install --upgrade setuptools pip
pip install --upgrade -r dev-requirements.txt
pip freeze
- name: "Build distribution archives"
run: |
python setup.py sdist bdist_wheel
# This step is only run when a new tag is pushed
# all previous steps always run in order to exercise them
- name: Publish distribution to PyPI
if: startsWith(github.ref, 'refs/tags')
uses: pypa/gh-action-pypi-publish@master
with:
password: ${{ secrets.PYPI_PASSWORD }}
publish-docker:
runs-on: ubuntu-20.04
env:
DEFAULT_REGISTRY: quay.io
IMAGE_NAME: jupyterhub/repo2docker
services:
# So that we can test this in PRs/branches
local-registry:
image: registry:2
ports:
- 5000:5000
steps:
- name: Should we push this image to a public registry?
run: |
if [ "${{ startsWith(github.ref, 'refs/tags/') || (github.ref == 'refs/heads/main') }}" = "true" ]; then
REGISTRY=$DEFAULT_REGISTRY
else
REGISTRY=localhost:5000
fi
echo "REGISTRY=$REGISTRY" >> $GITHUB_ENV
echo "Publishing to $REGISTRY"
# versioneer requires the full git history for non-tags
- uses: actions/checkout@v2
with:
fetch-depth: 0
# Setup docker to build for multiple platforms, see:
# https://github.com/docker/build-push-action/tree/v2.4.0#usage
# https://github.com/docker/build-push-action/blob/v2.4.0/docs/advanced/multi-platform.md
- name: Set up QEMU (for docker buildx)
uses: docker/setup-qemu-action@25f0500ff22e406f7191a2a8ba8cda16901ca018
- name: Set up Docker Buildx (for multi-arch builds)
uses: docker/setup-buildx-action@2a4b53665e15ce7d7049afb11ff1f70ff1610609
with:
# Allows pushing to registry on localhost:5000
driver-opts: network=host
- name: Setup push rights to Docker registry
if: env.REGISTRY != 'localhost:5000'
run: |
docker login -u "${{ secrets.DOCKER_REGISTRY_USERNAME }}" -p "${{ secrets.DOCKER_REGISTRY_TOKEN }}" "${{ env.REGISTRY }}"
# when building jupyter/repo2docker:master
# also push jupyter/repo2docker:1.2.3-3.abcd1234 (replace + with -)
- name: Get list of repo2docker docker tags
run: |
VERSION=$(python3 -c 'import versioneer; print(versioneer.get_version().replace("+", "-"))')
TAGS="${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:$VERSION"
if [ "${{ github.ref }}" == "refs/heads/main" ]; then
TAGS="$TAGS,${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:main"
fi
if [ "${{ startsWith(github.ref, 'refs/tags/') }}" = "true" ]; then
TAGS="$TAGS,${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest"
fi
echo "TAGS=$TAGS"
echo "TAGS=$TAGS" >> $GITHUB_ENV
- name: Build and push repo2docker
uses: docker/build-push-action@e1b7f96249f2e4c8e4ac1519b9608c0d48944a1f
with:
context: .
platforms: linux/amd64
push: true
tags: ${{ env.TAGS }}