Refreeze Dockerfile's requirements.txt #238
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
# This is a GitHub workflow defining a set of jobs with a set of steps. | |
# ref: https://docs.github.com/en/free-pro-team@latest/actions/reference/workflow-syntax-for-github-actions | |
# | |
name: Publish | |
# Always build releases/images but only publish to PyPI/quay.io on pushed tags | |
on: | |
pull_request: | |
paths: | |
- "Dockerfile" | |
- "requirements.in" | |
- "requirements.txt" | |
- ".github/workflows/refreeze-dockerfile-requirements-txt.yaml" | |
push: | |
paths: | |
- "Dockerfile" | |
- "requirements.in" | |
- "requirements.txt" | |
- ".github/workflows/refreeze-dockerfile-requirements-txt.yaml" | |
branches-ignore: | |
- "dependabot/**" | |
- "pre-commit-ci-update-config" | |
- "update-*" | |
tags: ["**"] | |
workflow_dispatch: | |
jobs: | |
build-and-publish-package: | |
runs-on: ubuntu-22.04 | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-python@v5 | |
with: | |
python-version: "3.11" | |
- name: install build package | |
run: | | |
pip install --upgrade pip | |
pip install build | |
pip freeze | |
- name: build release | |
run: | | |
python -m build --sdist --wheel . | |
ls -l dist | |
- name: publish to pypi | |
uses: pypa/gh-action-pypi-publish@release/v1 | |
if: startsWith(github.ref, 'refs/tags/') | |
with: | |
user: __token__ | |
password: ${{ secrets.pypi_password }} | |
build-and-publish-image: | |
runs-on: ubuntu-22.04 | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-python@v5 | |
with: | |
python-version: "3.11" | |
# This action will output a list of useful image tags. | |
# | |
# For example, if a tag 1.2.3 is pushed, then this action will output: | |
# | |
# [{prefix}:1.2.3, {prefix}:1.2, {prefix}:1, {prefix}:latest] | |
# | |
# Then for example, if the tag 1.1.1 is pushed after 1.2.3, then this | |
# action will output: | |
# | |
# [{prefix}:1.1.1, {prefix}:1.1, {prefix}:1] | |
# | |
# https://github.com/jupyterhub/action-major-minor-tag-calculator | |
- name: Get list of jupyterhub tags | |
id: image-tags | |
uses: jupyterhub/action-major-minor-tag-calculator@v3 | |
with: | |
githubToken: "${{ secrets.GITHUB_TOKEN }}" | |
prefix: "quay.io/jupyterhub/docker-image-cleaner:" | |
defaultTag: "quay.io/jupyterhub/docker-image-cleaner:noref" | |
branchRegex: ^\w[\w-.]*$ | |
- name: Set up QEMU (for docker buildx) | |
uses: docker/setup-qemu-action@v3 | |
- name: Set up Docker Buildx (for multi-arch builds) | |
uses: docker/setup-buildx-action@v3 | |
- name: Setup credentials to container registry | |
if: startsWith(github.ref, 'refs/tags/') | |
run: docker login quay.io -u "${{ secrets.DOCKER_REGISTRY_USERNAME }}" -p "${{ secrets.DOCKER_REGISTRY_PASSWORD }}" | |
- name: Build image (and push on tags) | |
uses: docker/build-push-action@v5 | |
with: | |
context: . | |
platforms: linux/amd64,linux/arm64 | |
push: ${{ startsWith(github.ref, 'refs/tags/') }} | |
# tags parameter must be a string input so convert `gettags` JSON | |
# array into a comma separated list of tags | |
tags: ${{ join(fromJson(steps.image-tags.outputs.tags)) }} |