Skip to content

pypa actions update #372

pypa actions update

pypa actions update #372

Workflow file for this run

name: "Create PyPi Package and Docker Image"
defaults:
run:
working-directory: ./pypi
on:
push:
branches:
- 'ci_dev'
- 'main'
tags:
- 'v*'
workflow_dispatch:
inputs:
release_version:
description: The version that you would like to create a release for.
required: true
default: "v1.2.3"
trigger_docker_latest:
description: Generate a :latest docker image using self-hosted runners.
required: true
default: "no"
trigger_docker_latest_cloud:
description: Generate a :latest docker image using cloud compute.
required: true
default: "no"
trigger_docker_release_cloud:
description: Generate docker release build (using release_version) via cloud.
required: true
default: "no"
trigger_docker_testing_cloud:
description: Allows generating a :testing docker image using cloud runners.
required: true
default: "no"
trigger_pypi_dev:
description: "Should we trigger the pypi-dev upload action? This will create a fake version number for upload."
required: true
default: "no"
trigger_pypi_prod:
description: "Should we trigger a pypi package upload using self-hosted runners?"
required: true
default: "no"
trigger_pypi_cloud:
description: "Should we trigger a pypi package upload using cloud runners?"
required: true
default: "no"
jobs:
pypi-dev:
name: Build a PyPi Package if this is a commit to the ci_dev branch
runs-on: [ "self-hosted", "build_host" ]
if: |
(vars.build_env == 'self-hosted' && github.event_name == 'push' && startsWith(github.ref, 'refs/heads/ci_dev')) ||
(github.event_name == 'workflow_dispatch' && github.event.inputs.trigger_pypi_dev == 'yes')
steps:
- name: Check out Repository
uses: actions/checkout@v3
with:
path: ./pypi-dev
- name: Set up Python 3.7
uses: actions/setup-python@v4
with:
python-version: 3.7
- name: Install pypa/build
run: >-
python -m
pip install
build
--user
- name: Obtain current commit hash
id: vars
shell: bash
run: |
echo "::set-output name=commit::$(git rev-parse --short HEAD)"
echo "::set-output name=commitint::$(git rev-parse HEAD | tr -d -c 0-9)"
- name: Set dummy version number in setup.py for publishing unique version
shell: bash
run: |
sed -i -E s/'version="(.+)",'/'version="0.0.'${{ steps.vars.outputs.commitint }}'"',/g setup.py
- name: Build a binary wheel and a source tarball
run: >-
python -m
build
--sdist
--wheel
--outdir dist/
.
- name: Publish distribution package to Test PyPI
uses: ngardiner/gh-action-pypi-publish-proxy@master
with:
password: ${{ secrets.TEST_PYPI_API_TOKEN }}
skip-existing: true
repository_url: https://test.pypi.org/legacy/
pypi-dev-cloud:
name: Build a PyPi Package if this is a commit to the ci_dev branch
runs-on: ubuntu-latest
if: |
(vars.build_env == 'cloud' && github.event_name == 'push' && startsWith(github.ref, 'refs/heads/ci_dev')) ||
(github.event_name == 'workflow_dispatch' && github.event.inputs.trigger_pypi_dev == 'yes')
steps:
- name: Check out Repository
uses: actions/checkout@v3
- name: Set up Python 3.7
uses: actions/setup-python@v4
with:
python-version: 3.7
- name: Install pypa/build
run: >-
python -m
pip install
build
--user
- name: Obtain current commit hash
id: vars
shell: bash
run: |
echo "::set-output name=commit::$(git rev-parse --short HEAD)"
echo "::set-output name=commitint::$(git rev-parse HEAD | tr -d -c 0-9)"
- name: Set dummy version number in setup.py for publishing unique version
shell: bash
run: |
sed -i -E s/'version="(.+)",'/'version="0.0.'${{ steps.vars.outputs.commitint }}'"',/g setup.py
- name: Build a binary wheel and a source tarball
run: >-
python -m
build
--sdist
--wheel
--outdir dist/
.
- name: Publish distribution package to Test PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.TEST_PYPI_API_TOKEN }}
skip-existing: true
repository_url: https://test.pypi.org/legacy/
pypi:
name: Build a PyPi Package if this is a tagged release commit
runs-on: [ "self-hosted", "build_host" ]
if: |
(vars.build_env == 'self-hosted' && github.event_name == 'push' && startsWith(github.ref, 'refs/tags')) ||
(github.event_name == 'workflow_dispatch' && github.event.inputs.trigger_pypi_prod == 'yes')
steps:
- name: Check out Repository
uses: actions/checkout@v3
with:
path: ./pypi
- name: Set up Python 3.7
uses: actions/setup-python@v4
with:
python-version: 3.7
- name: Install pypa/build
run: >-
python -m
pip install
build
--user
- name: Build a binary wheel and a source tarball
run: >-
python -m
build
--sdist
--wheel
--outdir dist/
.
- name: Publish distribution package to Test PyPI
uses: ngardiner/gh-action-pypi-publish-proxy@master
with:
password: ${{ secrets.TEST_PYPI_API_TOKEN }}
skip-existing: true
repository_url: https://test.pypi.org/legacy/
- name: Publish distribution package to Production PyPI
uses: ngardiner/gh-action-pypi-publish-proxy@master
with:
password: ${{ secrets.PYPI_API_TOKEN }}
pypi-cloud:
name: Build a PyPi Package if this is a tagged release commit
runs-on: ubuntu-latest
if: |
(vars.build_env == 'cloud' && github.event_name == 'push' && startsWith(github.ref, 'refs/tags')) ||
(github.event_name == 'workflow_dispatch' && github.event.inputs.trigger_pypi_cloud == 'yes')
steps:
- name: Check out Repository
uses: actions/checkout@v3
- name: Set up Python 3.7
uses: actions/setup-python@v4
with:
python-version: 3.7
- name: Install pypa/build
run: |
python -m pip install build --user
- name: Install wheel
run: |
python -m pip install wheel --user
- name: Build a binary wheel and a source tarball
run: |
python -m build --sdist --wheel --outdir dist/ .
- name: Publish distribution package to Test PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.TEST_PYPI_API_TOKEN }}
skip-existing: true
repository-url: https://test.pypi.org/legacy/
- name: Publish distribution package to Production PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.PYPI_API_TOKEN }}
docker-latest:
name: Create docker-latest Docker Image from current head
runs-on: [ "self-hosted", "build_host" ]
if: |
(vars.build_env == 'self-hosted' && github.event_name == 'push') ||
(github.event_name == 'workflow_dispatch' && github.event.inputs.trigger_docker_latest == 'yes')
steps:
- name: Check out Repository
uses: actions/checkout@v3
with:
path: ./docker-latest
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
id: buildx
with:
driver-opts: |
env.http_proxy=http://192.0.2.1:3128
env.https_proxy=http://192.0.2.1:3128
- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push
uses: docker/build-push-action@v2
with:
context: contrib/docker
platforms: linux/amd64,linux/arm64,linux/arm/v7
push: true
tags: twcmanager/twcmanager:latest
build-args: |
http_proxy=http://192.0.2.1:3128
https_proxy=http://192.0.2.1:3128
docker-latest-cloud:
name: Create docker-latest Docker Image from current head (Cloud)
runs-on: [ "ubuntu-latest" ]
if: |
( github.event_name == 'push' && vars.build_env == 'cloud') ||
github.event_name == 'workflow_dispatch' && github.event.inputs.trigger_docker_latest_cloud == 'yes'
steps:
- name: Check out Repository
uses: actions/checkout@v3
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
id: buildx
- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push
uses: docker/build-push-action@v5
with:
context: contrib/docker
platforms: linux/amd64,linux/arm64,linux/arm/v7
push: true
tags: twcmanager/twcmanager:latest
docker-release-cloud:
name: Create docker-release Docker Image for release version (Cloud)
runs-on: ubuntu-latest
if: |
(vars.build_env == 'cloud' && github.event_name == 'push' && startsWith(github.ref, 'refs/tags')) ||
(github.event_name == 'workflow_dispatch' && github.event.inputs.trigger_docker_release_cloud == 'yes')
steps:
- name: Check out Repository
uses: actions/checkout@v3
with:
ref: ${{ github.event.inputs.release_version }}
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
id: buildx
- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push
uses: docker/build-push-action@v2
with:
context: contrib/docker
platforms: linux/amd64,linux/arm64,linux/arm/v7
push: true
tags: twcmanager/twcmanager:${{ github.event.inputs.release_version }}
docker-release:
name: Create docker-release Docker Image for release version
runs-on: [ "self-hosted", "build_host" ]
if: |
(vars.build_env == 'self-hosted' && github.event_name == 'push' && startsWith(github.ref, 'refs/tags')) ||
(github.event_name == 'workflow_dispatch' && github.event.inputs.trigger_docker_release == 'yes')
steps:
- name: Check out Repository
uses: actions/checkout@v3
with:
path: ./docker-release
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
id: buildx
with:
driver-opts: |
env.http_proxy=http://192.0.2.1:3128
env.https_proxy=http://192.0.2.1:3128
- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push
uses: docker/build-push-action@v2
with:
context: contrib/docker
platforms: linux/amd64,linux/arm64,linux/arm/v7
push: true
tags: twcmanager/twcmanager:${{ github.ref_name }}
build-args: |
http_proxy=http://192.0.2.1:3128
https_proxy=http://192.0.2.1:3128
docker-testing-cloud:
name: Create docker-testing Docker Image (Cloud)
runs-on: ubuntu-latest
if: |
github.event_name == 'workflow_dispatch' && github.event.inputs.trigger_docker_testing_cloud == 'yes'
steps:
- name: Check out Repository
uses: actions/checkout@v3
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
id: buildx
- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push
uses: docker/build-push-action@v2
with:
context: contrib/docker
platforms: linux/amd64,linux/arm64,linux/arm/v7
push: true
tags: twcmanager/twcmanager:testing