Skip to content

Commit

Permalink
simplify workflow inputs
Browse files Browse the repository at this point in the history
  • Loading branch information
sslivkoff committed Dec 30, 2023
1 parent 2658d6c commit 4c0c73c
Showing 1 changed file with 6 additions and 43 deletions.
49 changes: 6 additions & 43 deletions .github/workflows/python_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,21 @@
#
name: python-release

# adapted from https://github.com/astral-sh/ruff/blob/main/.github/workflows/release.yaml
on:
workflow_dispatch:
inputs:
tag:
description: "The version to tag, without the leading 'v'. If omitted, will initiate a dry run (no uploads)."
type: string
sha:
description: "The full sha of the commit to be released. If omitted, the latest commit on the default branch will be used."
default: ""
type: string
release:
description: 'Set to true to run the release on pypi, dry run otherwise'
required: true
default: 'false'
pull_request:
paths:
# When we change pyproject.toml, we want to ensure that the maturin builds still work
- pyproject.toml
# And when we change this workflow itself...
- .github/workflows/python_release.yaml


permissions:
contents: read

Expand Down Expand Up @@ -125,49 +121,15 @@ jobs:
name: wheels
path: dist

# adapted from https://github.com/astral-sh/ruff/blob/main/.github/workflows/release.yaml
validate-tag:
name: Validate tag
runs-on: ubuntu-latest
# If you don't set an input tag, it's a dry run (no uploads).
if: ${{ inputs.tag }}
steps:
- uses: actions/checkout@v4
with:
ref: main # We checkout the main branch to check for the commit
- name: Check main branch
if: ${{ inputs.sha }}
run: |
# Fetch the main branch since a shallow checkout is used by default
git fetch origin main --unshallow
if ! git branch --contains ${{ inputs.sha }} | grep -E '(^|\s)main$'; then
echo "The specified sha is not on the main branch" >&2
exit 1
fi
- name: Check tag consistency
run: |
# Switch to the commit we want to release
git checkout ${{ inputs.sha }}
version=$(grep "version = " pyproject.toml | sed -e 's/version = "\(.*\)"/\1/g')
if [ "${{ inputs.tag }}" != "${version}" ]; then
echo "The input tag does not match the version from pyproject.toml:" >&2
echo "${{ inputs.tag }}" >&2
echo "${version}" >&2
exit 1
else
echo "Releasing ${version}"
fi
release:
name: Release
runs-on: ubuntu-latest
if: "startsWith(github.ref, 'refs/tags/')"
if: "github.event.inputs.release == 'true'"
needs:
- linux
- windows
- macos
- sdist
- validate-tag
environment:
name: pypi
url: https://pypi.org/p/cryo-python
Expand All @@ -182,3 +144,4 @@ jobs:
with:
skip-existing: true
packages-dir: ./

0 comments on commit 4c0c73c

Please sign in to comment.