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
name: Build and upload to PyPI and ghcr.io | |
on: | |
workflow_dispatch: | |
release: | |
types: | |
- published | |
jobs: | |
build: | |
name: Build universal wheel and source distribution | |
runs-on: ${{ matrix.os }} | |
strategy: | |
fail-fast: false | |
matrix: | |
os: ["ubuntu-22.04"] | |
python-version: ["3.10"] | |
# https://github.com/marketplace/actions/setup-miniconda#use-a-default-shell | |
defaults: | |
run: | |
shell: bash -l {0} | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: ./.github/actions/install-python-and-package | |
with: | |
python-version: ${{ matrix.python-version }} | |
extras-require: publishing | |
pkg-installation-type: "repository" | |
- name: Build wheel and source distribution | |
run: python3 -m build | |
- uses: actions/upload-artifact@v3 | |
with: | |
path: dist/* | |
upload_test_pypi: | |
needs: build | |
runs-on: ubuntu-22.04 | |
if: github.event_name == 'workflow_dispatch' | |
steps: | |
- uses: actions/download-artifact@v3 | |
with: | |
name: artifact | |
path: dist | |
- uses: pypa/[email protected] | |
with: | |
user: __token__ | |
password: ${{ secrets.TEST_PYPI_TOKEN_DEEPRANK2 }} | |
repository_url: https://test.pypi.org/legacy/ | |
upload_pypi: | |
needs: build | |
runs-on: ubuntu-22.04 | |
if: github.event_name == 'release' && github.event.action == 'published' | |
steps: | |
- uses: actions/download-artifact@v3 | |
with: | |
name: artifact | |
path: dist | |
- uses: pypa/[email protected] | |
with: | |
user: __token__ | |
password: ${{ secrets.PYPI_TOKEN_DEEPRANK2 }} | |
read_only_version: | |
needs: upload_pypi | |
name: Read version from TOML | |
runs-on: ubuntu-22.04 | |
outputs: | |
version: ${{ steps.get_version.outputs.VERSION }} | |
repo_lowercase: ${{ steps.repo_lowercase.outputs.REPO_LOWERCASE }} | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Read version from TOML | |
id: get_version | |
run: | | |
VERSION=$(grep '^version =' pyproject.toml | awk -F '"' '{print $2}') | |
echo "VERSION=$VERSION" >> $GITHUB_OUTPUT | |
- name: Convert repository name to lowercase | |
id: repo_lowercase | |
run: | | |
REPO_LOWERCASE=$(echo "${{ github.repository }}" | tr '[:upper:]' '[:lower:]') | |
echo "REPO_LOWERCASE=$REPO_LOWERCASE" >> $GITHUB_OUTPUT | |
upload_docker_image: | |
needs: read_only_version | |
name: Upload Docker image to ghcr.io | |
uses: ./.github/workflows/_ghcr.yml | |
with: | |
ghcr_user: ${{github.actor}} | |
base_image_name: ghcr.io/${{ needs.read_only_version.outputs.repo_lowercase }} | |
image_tag: ${{ needs.read_only_version.outputs.version }} | |
dockerfile: ./Dockerfile | |
docker_context: . | |
secrets: | |
token: ${{secrets.GITHUB_TOKEN}} |