Skip to content

Commit 69707b3

Browse files
committed
update release workflow and bump version to 0.1.1
1 parent 458457e commit 69707b3

3 files changed

Lines changed: 137 additions & 54 deletions

File tree

.github/workflows/publish.yml

Lines changed: 14 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,28 @@
11
name: Publish
22

33
on:
4-
workflow_run:
5-
workflows:
6-
- CI
4+
release:
75
types:
8-
- completed
9-
branches:
10-
- main
6+
- published
117

128
concurrency:
13-
group: publish-${{ github.event.workflow_run.head_sha }}
9+
group: publish-${{ github.event.release.tag_name }}
1410
cancel-in-progress: true
1511

1612
jobs:
17-
build:
18-
name: Build distributions
19-
if: github.event.workflow_run.conclusion == 'success'
13+
publish:
14+
name: Publish to PyPI
2015
runs-on: ubuntu-latest
16+
permissions:
17+
id-token: write
18+
contents: read
19+
environment:
20+
name: pypi
21+
url: https://pypi.org/project/django-returns/
2122
steps:
2223
- uses: actions/checkout@v4
2324
with:
24-
ref: ${{ github.event.workflow_run.head_sha }}
25+
ref: ${{ github.event.release.tag_name }}
2526

2627
- name: Set up Python
2728
uses: actions/setup-python@v5
@@ -34,47 +35,8 @@ jobs:
3435
- name: Build sdist and wheel
3536
run: uv build
3637

37-
- name: Upload dist artifacts
38-
uses: actions/upload-artifact@v4
39-
with:
40-
name: dist
41-
path: dist/
42-
43-
publish:
44-
name: Publish to PyPI
45-
needs: build
46-
runs-on: ubuntu-latest
47-
permissions:
48-
id-token: write
49-
contents: read
50-
environment:
51-
name: pypi
52-
url: https://pypi.org/project/django-returns/
53-
steps:
54-
- name: Download dist artifacts
55-
uses: actions/download-artifact@v4
56-
with:
57-
name: dist
58-
path: dist/
59-
60-
- name: Check if version already exists on PyPI
61-
shell: bash
62-
run: |
63-
set -euo pipefail
64-
wheel_file="$(ls -1 dist/*.whl | head -n 1)"
65-
wheel_base="$(basename "$wheel_file")"
66-
version="$(echo "$wheel_base" | cut -d- -f2)"
67-
68-
echo "Detected version: $version"
69-
70-
if curl -fsSL "https://pypi.org/pypi/django-returns/${version}/json" >/dev/null; then
71-
echo "Version ${version} already exists on PyPI; skipping publish."
72-
echo "SKIP_PUBLISH=true" >> "$GITHUB_ENV"
73-
else
74-
echo "Version ${version} not found on PyPI; will publish."
75-
fi
76-
7738
- name: Publish
78-
if: env.SKIP_PUBLISH != 'true'
7939
uses: pypa/gh-action-pypi-publish@release/v1
40+
with:
41+
skip-existing: true
8042

.github/workflows/release.yml

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
name: GitHub Release
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
jobs:
9+
release:
10+
name: Create GitHub release (on version bump)
11+
runs-on: ubuntu-latest
12+
permissions:
13+
contents: write
14+
steps:
15+
- uses: actions/checkout@v4
16+
with:
17+
fetch-depth: 0
18+
19+
- name: Detect pyproject version bump
20+
id: detect
21+
shell: bash
22+
run: |
23+
set -euo pipefail
24+
25+
if ! git diff --name-only "${{ github.event.before }}" "${{ github.sha }}" | grep -q '^pyproject\.toml$'; then
26+
echo "pyproject.toml did not change; skipping release."
27+
echo "changed=false" >> "$GITHUB_OUTPUT"
28+
exit 0
29+
fi
30+
31+
new_version="$(awk -F'"' '/^version\s*=\s*"/ {print $2; exit}' pyproject.toml)"
32+
33+
before="${{ github.event.before }}"
34+
if [[ "$before" == "0000000000000000000000000000000000000000" ]]; then
35+
old_version=""
36+
else
37+
old_version="$(git show "${before}:pyproject.toml" | awk -F'"' '/^version\s*=\s*"/ {print $2; exit}' || true)"
38+
fi
39+
40+
if [[ -z "$new_version" ]]; then
41+
echo "Could not parse version from pyproject.toml"
42+
exit 1
43+
fi
44+
45+
echo "Old version: ${old_version:-<none>}"
46+
echo "New version: ${new_version}"
47+
48+
if [[ "$new_version" == "$old_version" ]]; then
49+
echo "Version did not change; skipping release."
50+
echo "changed=false" >> "$GITHUB_OUTPUT"
51+
exit 0
52+
fi
53+
54+
echo "changed=true" >> "$GITHUB_OUTPUT"
55+
echo "version=${new_version}" >> "$GITHUB_OUTPUT"
56+
echo "tag=v${new_version}" >> "$GITHUB_OUTPUT"
57+
58+
- name: Skip if tag already exists
59+
id: tagexists
60+
if: steps.detect.outputs.changed == 'true'
61+
shell: bash
62+
run: |
63+
set -euo pipefail
64+
tag="${{ steps.detect.outputs.tag }}"
65+
if git rev-parse -q --verify "refs/tags/${tag}" >/dev/null; then
66+
echo "Tag ${tag} already exists; skipping release."
67+
echo "skip=true" >> "$GITHUB_OUTPUT"
68+
else
69+
echo "skip=false" >> "$GITHUB_OUTPUT"
70+
fi
71+
72+
- name: Install uv
73+
if: steps.detect.outputs.changed == 'true' && steps.tagexists.outputs.skip != 'true'
74+
uses: astral-sh/setup-uv@v4
75+
76+
- name: Build sdist and wheel
77+
if: steps.detect.outputs.changed == 'true' && steps.tagexists.outputs.skip != 'true'
78+
run: uv build
79+
80+
- name: Create GitHub release
81+
if: steps.detect.outputs.changed == 'true' && steps.tagexists.outputs.skip != 'true'
82+
uses: softprops/action-gh-release@v2
83+
with:
84+
tag_name: ${{ steps.detect.outputs.tag }}
85+
target_commitish: ${{ github.sha }}
86+
generate_release_notes: true
87+
files: |
88+
dist/*

pyproject.toml

Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,56 @@
11
[project]
22
name = "django-returns"
3-
version = "0.1.0"
3+
version = "0.1.1"
44
description = "Meaningful, typed, safe Django utils"
55
readme = "README.md"
6+
license = { file = "LICENSE" }
67
authors = [
78
{ name = "brunodantas", email = "bruno.welldm@gmail.com" }
89
]
910
requires-python = ">=3.10"
1011
dependencies = [
12+
"Django>=4.2",
1113
"returns>=0.26.0",
1214
]
1315

16+
keywords = ["django", "orm", "functional-programming", "monads", "returns", "result", "maybe", "railway-oriented-programming"]
17+
18+
classifiers = [
19+
"Development Status :: 3 - Alpha",
20+
"Framework :: Django",
21+
"Intended Audience :: Developers",
22+
"License :: OSI Approved :: GNU General Public License v3 (GPLv3)",
23+
"Programming Language :: Python :: 3",
24+
"Programming Language :: Python :: 3 :: Only",
25+
"Programming Language :: Python :: 3.10",
26+
"Programming Language :: Python :: 3.11",
27+
"Programming Language :: Python :: 3.12",
28+
"Programming Language :: Python :: 3.13",
29+
"Programming Language :: Python :: 3.14",
30+
"Typing :: Typed",
31+
]
32+
33+
[project.urls]
34+
Homepage = "https://github.com/brunodantas/django-returns"
35+
Repository = "https://github.com/brunodantas/django-returns"
36+
Issues = "https://github.com/brunodantas/django-returns/issues"
37+
38+
[project.optional-dependencies]
39+
dev = [
40+
"django-stubs>=5.2.8",
41+
"mypy>=1.19.1",
42+
"pytest>=9.0.2",
43+
"pytest-asyncio>=1.3.0",
44+
"pytest-django>=4.11.1",
45+
"ruff>=0.14.13",
46+
]
47+
1448
[build-system]
1549
requires = ["uv_build>=0.9.0,<0.10.0"]
1650
build-backend = "uv_build"
1751

1852
[dependency-groups]
1953
dev = [
20-
"django>=4.2",
2154
"django-stubs>=5.2.8",
2255
"ipython>=8.38.0",
2356
"mypy>=1.19.1",

0 commit comments

Comments
 (0)