Skip to content

Commit

Permalink
Merge pull request #1241 from twm/gha-release
Browse files Browse the repository at this point in the history
GHA release pipeline
  • Loading branch information
twm authored Dec 4, 2024
2 parents 98b0821 + 1e2acb0 commit 3f5219e
Show file tree
Hide file tree
Showing 9 changed files with 153 additions and 23 deletions.
55 changes: 50 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,13 @@ name: CI
on:
push:
branches: ["trunk"]
tags: ["v*"]
pull_request:
branches: ["trunk"]

permissions:
contents: read

jobs:
tox:
name: "tox -e ${{ matrix.tox-env }}"
Expand All @@ -21,6 +25,8 @@ jobs:

steps:
- uses: actions/checkout@v4
with:
persist-credentials: false

- uses: actions/[email protected]
with:
Expand All @@ -32,8 +38,8 @@ jobs:
- run: "python -m pip install tox"

# Temporary hack: create files normally created by Webpack that are
# expected to exist by the manifest.json view test.
# Temporary hack: create files normally created by bin/compile-static.py
# that are expected to exist by the manifest.json view test.
- run: |
mkdir yarrharr/static
touch yarrharr/static/{icon,logotype,lettertype}-xyz.{ico,png,svg}
Expand All @@ -42,13 +48,13 @@ jobs:
- run: "python -m tox"

webpack:
name: "tox -e static"

build:
runs-on: ubuntu-24.04

steps:
- uses: actions/checkout@v4
with:
persist-credentials: false

- name: apt install
run: |
Expand All @@ -67,3 +73,42 @@ jobs:
- run: "python -m tox -e static --notest"

- run: "tox -e static"

- run: "bin/release.sh"

- uses: actions/upload-artifact@v4
with:
name: dist
path: dist/*.*
if-no-files-found: error

release:
if: startsWith(github.ref, 'refs/tags/v')
needs: [build]

runs-on: ubuntu-24.04

permissions:
contents: write

steps:

- uses: actions/download-artifact@v4
with:
name: dist
path: dist/

- run: |
set -eux
tag="${TAG_REF##*/}"
version=${tag#v}
gh release create "$tag" \
--repo twm/yarrharr \
--verify-tag \
--title "Yarrharr $version" \
--generate-notes \
"dist/yarrharr-${version}.tar.gz" \
"dist/yarrharr-${version}"*.whl
env:
GH_TOKEN: ${{ github.token }}
TAG_REF: ${{ github.ref }}
8 changes: 8 additions & 0 deletions bin/release.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/usr/bin/env bash
set -exu -o pipefail
git diff --quiet HEAD || exit 1
tox -e release --notest
version=$(.tox/release/bin/hatch version)
.tox/release/bin/python -m build
.tox/release/bin/python -m twine check "dist/yarrharr-${version}.tar.gz" "dist/yarrharr-${version}-py3-none-any.whl"
git tag "v${version}"
9 changes: 1 addition & 8 deletions justfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,7 @@ _static:
tox -e static

release: _static
#!/usr/bin/env bash
set -exu -o pipefail
git diff --quiet HEAD || exit 1
tox -e release --notest
version=$(grep -oP '(?<=__version__ = ")([^"]+)(?=")' yarrharr/__init__.py)
.tox/release/bin/python -m build
.tox/release/bin/python -m twine check "dist/yarrharr-${version}.tar.gz" "dist/yarrharr-${version}-py3-none-any.whl"
git tag "v${version}"
bin/release.sh

devserver: _static
tox -e run -- django-admin migrate
Expand Down
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[build-system]
requires = ["hatchling"]
requires = ["hatchling", "incremental>=24.7.2"]
build-backend = "hatchling.build"

[project]
Expand Down Expand Up @@ -48,7 +48,7 @@ packages = ["yarrharr"]
artifacts = ["/yarrharr/static"]

[tool.hatch.version]
path = "yarrharr/__init__.py"
source = "incremental"

[tool.ruff]
line-length = 150
Expand Down
1 change: 0 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ treq==24.9.1
twisted[tls]==24.7.0
# via
# treq
# twisted
# yarrharr (pyproject.toml)
typing-extensions==4.7.1
# via
Expand Down
1 change: 1 addition & 0 deletions requirements_release.in
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
build
twine
hatch
83 changes: 77 additions & 6 deletions requirements_release.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,55 @@
#
# pip-compile --output-file=requirements_release.txt requirements_release.in
#
anyio==4.6.2.post1
# via httpx
bleach==6.0.0
# via readme-renderer
build==1.2.1
# via -r requirements_release.in
certifi==2024.8.30
# via requests
# via
# httpcore
# httpx
# requests
cffi==1.15.1
# via cryptography
charset-normalizer==3.2.0
# via requests
click==8.1.7
# via
# hatch
# userpath
cryptography==43.0.3
# via secretstorage
distlib==0.3.9
# via virtualenv
docutils==0.20.1
# via readme-renderer
editables==0.5
# via hatchling
exceptiongroup==1.2.2
# via anyio
filelock==3.16.1
# via virtualenv
h11==0.14.0
# via httpcore
hatch==1.9.7
# via -r requirements_release.in
hatchling==1.21.1
# via hatch
httpcore==1.0.7
# via httpx
httpx==0.27.2
# via hatch
hyperlink==21.0.0
# via hatch
idna==3.7
# via requests
# via
# anyio
# httpx
# hyperlink
# requests
importlib-metadata==6.8.0
# via
# build
Expand All @@ -32,7 +65,9 @@ jeepney==0.8.0
# keyring
# secretstorage
keyring==24.2.0
# via twine
# via
# hatch
# twine
markdown-it-py==3.0.0
# via rich
mdurl==0.1.2
Expand All @@ -42,9 +77,22 @@ more-itertools==10.0.0
packaging==23.1
# via
# build
# twine
pkginfo==1.9.6
# hatch
# hatchling
pathspec==0.12.1
# via hatchling
pexpect==4.9.0
# via hatch
pkginfo==1.10.0
# via twine
platformdirs==4.3.6
# via
# hatch
# virtualenv
pluggy==1.5.0
# via hatchling
ptyprocess==0.7.0
# via pexpect
pycparser==2.21
# via cffi
pygments==2.15.1
Expand All @@ -64,22 +112,45 @@ requests-toolbelt==1.0.0
rfc3986==2.0.0
# via twine
rich==13.5.2
# via twine
# via
# hatch
# twine
secretstorage==3.3.3
# via keyring
shellingham==1.5.4
# via hatch
six==1.16.0
# via bleach
sniffio==1.3.1
# via
# anyio
# httpx
tomli==2.0.1
# via
# build
# hatchling
# pyproject-hooks
tomli-w==1.1.0
# via hatch
tomlkit==0.13.2
# via hatch
trove-classifiers==2024.10.21.16
# via hatchling
twine==6.0.1
# via -r requirements_release.in
typing-extensions==4.12.2
# via anyio
urllib3==2.2.2
# via
# requests
# twine
userpath==1.9.2
# via hatch
virtualenv==20.25.3
# via hatch
webencodings==0.5.1
# via bleach
zipp==3.19.2
# via importlib-metadata
zstandard==0.23.0
# via hatch
4 changes: 3 additions & 1 deletion yarrharr/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
# such a combination shall include the source code for the parts of
# OpenSSL used as well as that of the covered work.

from importlib.metadata import version

__author__ = "Tom Most"
__author_email__ = "[email protected]"
__version__ = "2024.11.0"
__version__ = version("yarrharr")
11 changes: 11 additions & 0 deletions yarrharr/_version.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
"""
Provides yarrharr version information.
"""

# This file is auto-generated! Do not edit!
# Use `incremental` to change this file.

from incremental import Version

__version__ = Version("yarrharr", 24, 11, 0)
__all__ = ["__version__"]

0 comments on commit 3f5219e

Please sign in to comment.