Skip to content

Commit

Permalink
Refactor release workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
staticdev committed Jan 26, 2025
1 parent 451f2e8 commit e8b21ea
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 24 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/constraints.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
pip==23.2
virtualenv==20.17.1
pip==24.3.1
virtualenv==20.29.1
1 change: 1 addition & 0 deletions .github/workflows/hatch-constraints.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
hatch==1.14.0
30 changes: 30 additions & 0 deletions .github/workflows/release-dev.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
---
name: Release Dev

"on":
push:
branches:
- main

jobs:
release:
if: github.repository_owner == 'PyCQA'
name: Release
runs-on: ubuntu-latest
steps:
- name: Check out the repository
uses: actions/checkout@v4
with:
fetch-depth: 2

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.13"

- name: Install UV
uses: astral-sh/setup-uv@v5

- name: Build package
run: |
uv build
32 changes: 12 additions & 20 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ name: Release

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

jobs:
release:
Expand All @@ -17,16 +17,24 @@ jobs:
with:
fetch-depth: 2

- name: Set Tag env
run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.12"
python-version: "3.13"

- name: Upgrade pip
run: |
pip install --constraint=.github/workflows/constraints.txt pip
pip --version
- name: Install Hatch
run: |
pip install --constraint=.github/workflows/hatch-constraints.txt hatch
hatch --version
- name: Install UV
uses: astral-sh/setup-uv@v5

Expand All @@ -35,25 +43,9 @@ jobs:
run: |
echo "::set-output name=sha::$(git rev-parse --verify --quiet HEAD^)"
- name: Detect and tag new version
id: check-version
if: steps.check-parent-commit.outputs.sha
uses: salsify/action-detect-and-tag-new-version@v2
with:
tag-template: "{VERSION}"
version-command: |
bash -o pipefail -c "poetry version | awk '{ print \$2 }'"
- name: Bump version for developmental release
if: "! steps.check-version.outputs.tag"
run: |
poetry version patch &&
version=$(poetry version | awk '{ print $2 }') &&
poetry version $version.dev.$(date +%s)
- name: Build package
run: |
poetry build --ansi
uv build
- name: Publish package on PyPI
if: steps.check-version.outputs.tag
Expand Down
10 changes: 8 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ line-length = 100

[project]
name = "isort"
version = "5.13.2"
dynamic = ["version"]
description = "A Python utility / library to sort Python imports."
authors = [{name = "Timothy Crosley", email = "[email protected]"}, {name = "staticdev", email = "[email protected]"}]
license = "MIT"
Expand Down Expand Up @@ -42,6 +42,12 @@ requires-python = ">=3.9.0"

dependencies = []

[tool.hatch.version]
source = "vcs"

[tool.hatch.version.raw-options]
local_scheme = "no-local-version"

[project.scripts]
isort = "isort.main:main"
isort-identify-imports = "isort.main:identify_imports_main"
Expand Down Expand Up @@ -132,7 +138,7 @@ logo = "art/logo.png"
palette = {scheme = "isort"}

[build-system]
requires = ["hatchling"]
requires = ["hatchling", "hatch-vcs"]
build-backend = "hatchling.build"

[tool.mypy]
Expand Down

0 comments on commit e8b21ea

Please sign in to comment.