Merge pull request #1299 from SylvainCorlay/update-mamba-1.4.9 #846
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
# This is a GitHub workflow defining a set of jobs with a set of steps. | |
# ref: https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions | |
# | |
name: Publish | |
on: | |
pull_request: | |
paths-ignore: | |
- "docs/**" | |
- "**.md" | |
- "**.rst" | |
- ".github/workflows/*" | |
- "!.github/workflows/release.yml" | |
- ".pre-commit-config.yaml" | |
push: | |
paths-ignore: | |
- "docs/**" | |
- "**.md" | |
- "**.rst" | |
- ".github/workflows/*" | |
- "!.github/workflows/release.yml" | |
- ".pre-commit-config.yaml" | |
branches-ignore: | |
- "dependabot/**" | |
- "pre-commit-ci-update-config" | |
tags: | |
- "**" | |
workflow_dispatch: | |
jobs: | |
build-n-publish: | |
runs-on: ubuntu-22.04 | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: actions/setup-python@v4 | |
with: | |
python-version: "3.9" | |
- name: install build requirements | |
run: | | |
pip install build | |
pip freeze | |
- name: build release | |
run: | | |
python -m build --sdist --wheel . | |
ls -l dist | |
# ref: https://github.com/actions/upload-artifact#readme | |
- uses: actions/upload-artifact@v3 | |
with: | |
name: repo2docker-${{ github.sha }} | |
path: "dist/*" | |
if-no-files-found: error | |
# 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@release/v1 | |
with: | |
password: ${{ secrets.PYPI_PASSWORD }} | |
publish-docker: | |
runs-on: ubuntu-22.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@v3 | |
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@v2 | |
- name: Set up Docker Buildx (for multi-arch builds) | |
uses: docker/setup-buildx-action@v2 | |
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@v4 | |
with: | |
context: . | |
platforms: linux/amd64,linux/arm64 | |
push: true | |
tags: ${{ env.TAGS }} |