Skip to content

Commit

Permalink
👷 Create draft release and publish from GHA.
Browse files Browse the repository at this point in the history
  • Loading branch information
rafalkrupinski committed Oct 26, 2024
1 parent 2db831f commit a34bd8d
Show file tree
Hide file tree
Showing 5 changed files with 86 additions and 29 deletions.
39 changes: 39 additions & 0 deletions .github/workflows/draft-release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: Draft Release

on:
workflow_run:
workflows: ["Test"]
types:
- completed
branches:
- main
workflow_dispatch: {}

jobs:
release-draft:
permissions:
contents: write
runs-on: ubuntu-latest
if: >
github.event.workflow_run.conclusion == 'success' &&
startsWith(github.event.workflow_run.head_commit.message, 'refs/tags/')
steps:
- name: Checkout Repository
uses: actions/checkout@v4
- name: Install uv
uses: astral-sh/setup-uv@v3
with:
enable-cache: true
- name: Build
run: uv build

- name: Create release
env:
tag: ${{ github.ref_name }}
run: |
gh release create -d "$tag" \
--repo="$GITHUB_REPOSITORY" \
--title="${GITHUB_REPOSITORY#*/} ${tag#v}" \
--generate-notes \
--latest \
dist/*.tar.gz dist/*.whl
24 changes: 24 additions & 0 deletions .github/workflows/pypi.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# .github/workflows/publish-to-pypi.yml

name: Publish to PyPI

on:
release:
types:
- published

jobs:
publish_pypi:
runs-on: ubuntu-latest

steps:
- name: Checkout Repository
uses: actions/checkout@v4

- name: Install uv
uses: astral-sh/setup-uv@v3
with:
enable-cache: true

- name: Publish Package
run: uv publish
46 changes: 22 additions & 24 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
name: Test

on:
- push
on: push

concurrency:
group: tests-${{ github.head_ref || github.ref }}
Expand Down Expand Up @@ -41,25 +40,24 @@ jobs:
run:
shell: bash
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

- name: Install uv
uses: astral-sh/setup-uv@v3
with:
enable-cache: true

- name: Check lock file
run: uv lock --locked

- name: Install dependencies
run: uv sync --all-extras

- name: Run pytest
run: uv run pytest
- uses: actions/checkout@v4
with:
ref: ${{ github.event.release.tag_name }}
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

- name: Install uv
uses: astral-sh/setup-uv@v3
with:
enable-cache: true

- name: Check lock file
run: uv lock --locked

- name: Install dependencies
run: uv sync --all-extras

- name: Run pytest
run: uv run pytest
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
/.coverage
/dist/
/.venv/
5 changes: 0 additions & 5 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,7 @@ dev-dependencies = [

[tool.hatch.build]
exclude = [
"/.github",
"/.venv",
"/.git",
"/.idea",
"/.gitignore",
"/.pre-commit-config.yaml",
]


Expand Down

0 comments on commit a34bd8d

Please sign in to comment.