Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 63 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
name: "Build and optionally release PyPi and docker packages"

on:
workflow_dispatch:
pull_request:
push:
branches:
- "main"
tags:
- "v[0-9]+.[0-9]+.[0-9]+*"

concurrency:
group: "${{ github.workflow }}-${{ github.ref }}"
cancel-in-progress: true

env:
# Many color libraries just need this to be set to any value, but at least
# one distinguishes color depth, where "3" -> "256-bit color".
FORCE_COLOR: 3
DOCKER_IMAGE_NAME: "dataone-auth"
# GitHub Actions expressions don't have great conditional support, so
# writing a ternary expression looks a lot like bash. In Python, this
# would read as:
# github.ref_name if github.ref_type == 'tag' else 'latest'
# https://docs.github.com/en/actions/learn-github-actions/expressions
DOCKER_IMAGE_TAG:
"${{ github.ref_type == 'tag' && github.ref_name || 'latest' }}"

jobs:
#######################################################################
# Build Python
#######################################################################
build-python:
name: "Build python distributions (wheel & sdist)"
runs-on: "ubuntu-latest"

steps:
- uses: "actions/checkout@v7"
with:
fetch-depth: 0

- uses: "hynek/build-and-inspect-python-package@v3.0.1"

#######################################################################
# Publish python
#######################################################################
publish-python:
if: github.ref_type == 'tag'
# Only publish if both Python and Docker builds are successful.
needs: ["build-python"]
name: "Publish to PyPI"
environment: "pypi"
permissions:
id-token: "write"
runs-on: "ubuntu-latest"

steps:
- uses: "actions/download-artifact@v8"
with:
name: "Packages"
path: "dist"

- uses: "pypa/gh-action-pypi-publish@v1.14.2"
Loading