mirror of
https://github.com/pypiserver/pypiserver
synced 2025-02-22 19:19:37 +01:00
chore(package-release-from-gh-actions): Adding release management to GitHub actions (#423)
* Basic attempt for a release workflow in GH Actions * move docker release to `release.yml` * return the docker steps to ci.yml * return the deploy-docker step to release.yml * add wait for tests GA
This commit is contained in:
parent
eb3d6941b1
commit
4d81ea7124
193
.github/workflows/ci.yml
vendored
193
.github/workflows/ci.yml
vendored
@ -14,7 +14,6 @@ on:
|
|||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
test-cpython:
|
test-cpython:
|
||||||
|
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
@ -25,64 +24,62 @@ jobs:
|
|||||||
python-version: ["3.6", "3.7", "3.8"]
|
python-version: ["3.6", "3.7", "3.8"]
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
- name: Set up Python ${{ matrix.python-version }}
|
- name: Set up Python ${{ matrix.python-version }}
|
||||||
uses: actions/setup-python@v2
|
uses: actions/setup-python@v2
|
||||||
with:
|
with:
|
||||||
python-version: ${{ matrix.python-version }}
|
python-version: ${{ matrix.python-version }}
|
||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
run: pip install tox
|
run: pip install tox
|
||||||
- name: Run tests
|
- name: Run tests
|
||||||
# Create a tox env specification by stripping the dot out of the version
|
# Create a tox env specification by stripping the dot out of the version
|
||||||
# specification and appending it to "py"
|
# specification and appending it to "py"
|
||||||
run: |
|
run: |
|
||||||
tox -e "py$(echo ${{ matrix.python-version }} | tr -d .)"
|
tox -e "py$(echo ${{ matrix.python-version }} | tr -d .)"
|
||||||
|
|
||||||
test-pypy:
|
test-pypy:
|
||||||
|
|
||||||
# Run a a separate job so we don't need to mess with conditionally
|
# Run a a separate job so we don't need to mess with conditionally
|
||||||
# splitting the python version from the build matrix. Also the pypy
|
# splitting the python version from the build matrix. Also the pypy
|
||||||
# tests take freaking forever.
|
# tests take freaking forever.
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
- name: Set up Python
|
- name: Set up Python
|
||||||
uses: actions/setup-python@v2
|
uses: actions/setup-python@v2
|
||||||
with:
|
with:
|
||||||
python-version: pypy3
|
python-version: pypy3
|
||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
run: pip install tox
|
run: pip install tox
|
||||||
- name: Run tests
|
- name: Run tests
|
||||||
run: tox -e pypy3
|
run: tox -e pypy3
|
||||||
|
|
||||||
check:
|
check:
|
||||||
|
|
||||||
# These checks only need to be done once, not for every python version we s
|
# These checks only need to be done once, not for every python version we s
|
||||||
# upport
|
# upport
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
- name: Set up Python
|
- name: Set up Python
|
||||||
uses: actions/setup-python@v2
|
uses: actions/setup-python@v2
|
||||||
with:
|
with:
|
||||||
# Pretty much any python version will do
|
# Pretty much any python version will do
|
||||||
python-version: "3.9"
|
python-version: "3.9"
|
||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
run: |
|
run: |
|
||||||
pip install -r "requirements/dev.pip"
|
pip install -r "requirements/dev.pip"
|
||||||
pip install types-pkg_resources # one of mypy required stubs
|
pip install types-pkg_resources # one of mypy required stubs
|
||||||
- name: Check types
|
- name: Check types
|
||||||
# individual mypy files for now, until we get the rest
|
# individual mypy files for now, until we get the rest
|
||||||
# of the project typechecking
|
# of the project typechecking
|
||||||
run: >-
|
run: >-
|
||||||
mypy
|
mypy
|
||||||
docker/test_docker.py
|
docker/test_docker.py
|
||||||
pypiserver/config.py
|
pypiserver/config.py
|
||||||
tests/test_init.py
|
tests/test_init.py
|
||||||
- name: Check formatting
|
- name: Check formatting
|
||||||
run: black --diff --check .
|
run: black --diff --check .
|
||||||
- name: Validate README
|
- name: Validate README
|
||||||
run: ./bin/check_readme.sh
|
run: ./bin/check_readme.sh
|
||||||
|
|
||||||
# Full-flow docker tests, again not python version dependent
|
# Full-flow docker tests, again not python version dependent
|
||||||
# We _could_ test this on MacOS, but it takes forever to get docker
|
# We _could_ test this on MacOS, but it takes forever to get docker
|
||||||
@ -93,19 +90,18 @@ jobs:
|
|||||||
test-docker:
|
test-docker:
|
||||||
runs-on: "ubuntu-latest"
|
runs-on: "ubuntu-latest"
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
- name: Set up Python
|
- name: Set up Python
|
||||||
uses: actions/setup-python@v2
|
uses: actions/setup-python@v2
|
||||||
with:
|
with:
|
||||||
# Pretty much any python version will do
|
# Pretty much any python version will do
|
||||||
python-version: "3.9"
|
python-version: "3.9"
|
||||||
- name: Install test dependencies
|
- name: Install test dependencies
|
||||||
run: pip install -r "requirements/test.pip"
|
run: pip install -r "requirements/test.pip"
|
||||||
- name: Install package
|
- name: Install package
|
||||||
run: pip install -r "requirements/exe.pip"
|
run: pip install -r "requirements/exe.pip"
|
||||||
- name: Run tests
|
- name: Run tests
|
||||||
run: "pytest docker/test_docker.py"
|
run: "pytest docker/test_docker.py"
|
||||||
|
|
||||||
|
|
||||||
tests:
|
tests:
|
||||||
runs-on: "ubuntu-latest"
|
runs-on: "ubuntu-latest"
|
||||||
@ -117,82 +113,3 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
- name: "Everything is good!"
|
- name: "Everything is good!"
|
||||||
run: "echo true"
|
run: "echo true"
|
||||||
|
|
||||||
# figure out which docker tags we need to push
|
|
||||||
docker-determine-tags:
|
|
||||||
runs-on: "ubuntu-latest"
|
|
||||||
needs:
|
|
||||||
- "tests"
|
|
||||||
steps:
|
|
||||||
- uses: "actions/checkout@v2"
|
|
||||||
|
|
||||||
- uses: "actions/setup-python@v2"
|
|
||||||
with:
|
|
||||||
python-version: "3.9"
|
|
||||||
|
|
||||||
# This script prints a JSON array of needed docker tags, depending on the
|
|
||||||
# ref. That array is then used to construct the matrix of the
|
|
||||||
# deploy-docker job
|
|
||||||
- name: "Get expected docker tags"
|
|
||||||
id: "tags"
|
|
||||||
run: >-
|
|
||||||
echo "::set-output name=tags::$(bin/ci_helper.py ${{ github.ref }} docker_tags)"
|
|
||||||
|
|
||||||
# This is needed because GH actions will fail on an empty matrix, so
|
|
||||||
# we need to be sure the `if` condition is false on the next job if
|
|
||||||
# the matrix will be empty. The script prints 'true' if the array is
|
|
||||||
# not empty, or 'false' otherwise.
|
|
||||||
- name: "Determine whether any tags are needed"
|
|
||||||
id: "has_tags"
|
|
||||||
run: >-
|
|
||||||
echo "::set-output name=has_tags::$(bin/ci_helper.py ${{ github.ref }} has_tags)"
|
|
||||||
|
|
||||||
outputs:
|
|
||||||
tags: "${{ steps.tags.outputs.tags }}"
|
|
||||||
has_tags: "${{ steps.has_tags.outputs.has_tags }}"
|
|
||||||
|
|
||||||
# Deploy any needed docker tags
|
|
||||||
deploy-docker:
|
|
||||||
runs-on: "ubuntu-latest"
|
|
||||||
needs:
|
|
||||||
- "tests"
|
|
||||||
- "docker-determine-tags"
|
|
||||||
if: "${{ fromJson(needs.docker-determine-tags.outputs.has_tags) }}"
|
|
||||||
strategy:
|
|
||||||
matrix:
|
|
||||||
tag: "${{ fromJson(needs.docker-determine-tags.outputs.tags) }}"
|
|
||||||
steps:
|
|
||||||
- uses: "actions/checkout@v2"
|
|
||||||
|
|
||||||
- name: "Cache Docker layers"
|
|
||||||
uses: "actions/cache@v2"
|
|
||||||
with:
|
|
||||||
path: "/tmp/.buildx-cache"
|
|
||||||
key: "${{ runner.os }}-buildx-${{ github.sha }}"
|
|
||||||
restore-keys: |
|
|
||||||
${{ runner.os }}-buildx-
|
|
||||||
|
|
||||||
- name: "Login to Docker Hub"
|
|
||||||
uses: "docker/login-action@v1"
|
|
||||||
with:
|
|
||||||
username: "${{ secrets.DOCKER_HUB_USER }}"
|
|
||||||
password: "${{ secrets.DOCKER_HUB_TOKEN }}"
|
|
||||||
|
|
||||||
- name: "Set up Docker Buildx"
|
|
||||||
id: "buildx"
|
|
||||||
uses: "docker/setup-buildx-action@v1"
|
|
||||||
|
|
||||||
- name: "Build and push"
|
|
||||||
id: "docker_build"
|
|
||||||
uses: "docker/build-push-action@v2"
|
|
||||||
with:
|
|
||||||
context: "./"
|
|
||||||
file: "./Dockerfile"
|
|
||||||
builder: "${{ steps.buildx.outputs.name }}"
|
|
||||||
push: true
|
|
||||||
tags: "pypiserver/pypiserver:${{ matrix.tag }}"
|
|
||||||
cache-from: "type=local,src=/tmp/.buildx-cache"
|
|
||||||
cache-to: "type=local,dest=/tmp/.buildx-cache"
|
|
||||||
|
|
||||||
- name: "Image digest"
|
|
||||||
run: "echo ${{ steps.docker_build.outputs.digest }}"
|
|
||||||
|
131
.github/workflows/rls.yml
vendored
Normal file
131
.github/workflows/rls.yml
vendored
Normal file
@ -0,0 +1,131 @@
|
|||||||
|
# Workflow management for new tag releases.
|
||||||
|
# Inspired on the Python packaging guide.
|
||||||
|
# https://packaging.python.org/en/latest/guides/publishing-package-distribution-releases-using-github-actions-ci-cd-workflows/
|
||||||
|
name: Publish new pypiserver release
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
tags:
|
||||||
|
- v*
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
|
||||||
|
########
|
||||||
|
# PYPI #
|
||||||
|
########
|
||||||
|
|
||||||
|
build_wheel_and_push_to_pypi:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Wait for tests to succeed
|
||||||
|
uses: lewagon/wait-on-check-action@v1.0.0
|
||||||
|
with:
|
||||||
|
ref: ${{ github.ref }}
|
||||||
|
check-name: 'tests'
|
||||||
|
repo-token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
wait-interval: 10
|
||||||
|
|
||||||
|
- uses: actions/checkout@master
|
||||||
|
- name: Set up Python 3.8
|
||||||
|
uses: actions/setup-python@v1
|
||||||
|
with:
|
||||||
|
python-version: 3.8
|
||||||
|
|
||||||
|
- name: Build distribution _wheel_.
|
||||||
|
run: |
|
||||||
|
/bin/package.sh
|
||||||
|
|
||||||
|
- name: Publish distribution 📦 to PyPI.
|
||||||
|
if: startsWith(github.ref, 'refs/tags')
|
||||||
|
uses: pypa/gh-action-pypi-publish@master
|
||||||
|
with:
|
||||||
|
password: ${{ secrets.PYPI_API_TOKEN }}
|
||||||
|
print_hash: true
|
||||||
|
|
||||||
|
##########
|
||||||
|
# Docker #
|
||||||
|
##########
|
||||||
|
|
||||||
|
# figure out which docker tags we need to push
|
||||||
|
docker-determine-tags:
|
||||||
|
runs-on: "ubuntu-latest"
|
||||||
|
steps:
|
||||||
|
- name: Wait for tests to succeed
|
||||||
|
uses: lewagon/wait-on-check-action@v1.0.0
|
||||||
|
with:
|
||||||
|
ref: ${{ github.ref }}
|
||||||
|
check-name: 'tests'
|
||||||
|
repo-token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
wait-interval: 10
|
||||||
|
|
||||||
|
- uses: "actions/checkout@v2"
|
||||||
|
|
||||||
|
- uses: "actions/setup-python@v2"
|
||||||
|
with:
|
||||||
|
python-version: "3.9"
|
||||||
|
|
||||||
|
# This script prints a JSON array of needed docker tags, depending on the
|
||||||
|
# ref. That array is then used to construct the matrix of the
|
||||||
|
# deploy-docker job
|
||||||
|
- name: "Get expected docker tags"
|
||||||
|
id: "tags"
|
||||||
|
run: >-
|
||||||
|
echo "::set-output name=tags::$(bin/ci_helper.py ${{ github.ref }} docker_tags)"
|
||||||
|
|
||||||
|
# This is needed because GH actions will fail on an empty matrix, so
|
||||||
|
# we need to be sure the `if` condition is false on the next job if
|
||||||
|
# the matrix will be empty. The script prints 'true' if the array is
|
||||||
|
# not empty, or 'false' otherwise.
|
||||||
|
- name: "Determine whether any tags are needed"
|
||||||
|
id: "has_tags"
|
||||||
|
run: >-
|
||||||
|
echo "::set-output name=has_tags::$(bin/ci_helper.py ${{ github.ref }} has_tags)"
|
||||||
|
|
||||||
|
outputs:
|
||||||
|
tags: "${{ steps.tags.outputs.tags }}"
|
||||||
|
has_tags: "${{ steps.has_tags.outputs.has_tags }}"
|
||||||
|
|
||||||
|
# Deploy any needed docker tags
|
||||||
|
deploy-docker:
|
||||||
|
runs-on: "ubuntu-latest"
|
||||||
|
needs:
|
||||||
|
- "docker-determine-tags"
|
||||||
|
if: "${{ fromJson(needs.docker-determine-tags.outputs.has_tags) }}"
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
tag: "${{ fromJson(needs.docker-determine-tags.outputs.tags) }}"
|
||||||
|
steps:
|
||||||
|
- uses: "actions/checkout@v2"
|
||||||
|
|
||||||
|
- name: "Cache Docker layers"
|
||||||
|
uses: "actions/cache@v2"
|
||||||
|
with:
|
||||||
|
path: "/tmp/.buildx-cache"
|
||||||
|
key: "${{ runner.os }}-buildx-${{ github.sha }}"
|
||||||
|
restore-keys: |
|
||||||
|
${{ runner.os }}-buildx-
|
||||||
|
|
||||||
|
- name: "Login to Docker Hub"
|
||||||
|
uses: "docker/login-action@v1"
|
||||||
|
with:
|
||||||
|
username: "${{ secrets.DOCKER_HUB_USER }}"
|
||||||
|
password: "${{ secrets.DOCKER_HUB_TOKEN }}"
|
||||||
|
|
||||||
|
- name: "Set up Docker Buildx"
|
||||||
|
id: "buildx"
|
||||||
|
uses: "docker/setup-buildx-action@v1"
|
||||||
|
|
||||||
|
- name: "Build and push"
|
||||||
|
id: "docker_build"
|
||||||
|
uses: "docker/build-push-action@v2"
|
||||||
|
with:
|
||||||
|
context: "./"
|
||||||
|
file: "./Dockerfile"
|
||||||
|
builder: "${{ steps.buildx.outputs.name }}"
|
||||||
|
push: true
|
||||||
|
tags: "pypiserver/pypiserver:${{ matrix.tag }}"
|
||||||
|
cache-from: "type=local,src=/tmp/.buildx-cache"
|
||||||
|
cache-to: "type=local,dest=/tmp/.buildx-cache"
|
||||||
|
|
||||||
|
- name: "Image digest"
|
||||||
|
run: "echo ${{ steps.docker_build.outputs.digest }}"
|
Loading…
Reference in New Issue
Block a user