Skip to content

Commit ec7bfaa

Browse files
committed
ci: rationalise workflows
1 parent 56ccb9a commit ec7bfaa

File tree

5 files changed

+92
-96
lines changed

5 files changed

+92
-96
lines changed

.github/workflows/main.yml

Lines changed: 7 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,16 @@
1+
name: Main
2+
13
on:
24
push:
35

46
jobs:
57
test:
68
name: Run tests
7-
uses: ./.github/workflows/tests-template.yml
9+
uses: ./.github/workflows/tests.yml
810
release:
9-
name: Create release
10-
if: ${{ github.ref == 'refs/heads/main' }}
11-
runs-on: ubuntu-24.04
11+
name: Release
12+
uses: ./.github/workflows/release.yml
13+
if: github.ref == 'refs/heads/main'
1214
permissions:
13-
# Required to allow release-it to create releases
1415
contents: write
15-
needs: [test]
16-
steps:
17-
- name: Checkout
18-
uses: actions/checkout@v4
19-
with:
20-
fetch-depth: 0
21-
- name: Set up Python
22-
uses: actions/setup-python@v5
23-
with:
24-
python-version: "3.12"
25-
- name: Install poetry
26-
uses: abatilo/actions-poetry@v3
27-
- name: Configure git
28-
run: |
29-
git config user.name "${GITHUB_ACTOR}"
30-
git config user.email "${GITHUB_ACTOR}@users.noreply.github.com"
31-
- name: Create release
32-
run: npx -p @release-it/bumper -p @release-it/conventional-changelog release-it
33-
env:
34-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
35-
- name: Upload artifacts for publication
36-
uses: actions/upload-artifact@v4
37-
with:
38-
name: python-dist
39-
path: dist/*
16+
id-token: write

.github/workflows/pypi-template.yml

Lines changed: 0 additions & 48 deletions
This file was deleted.

.github/workflows/pypi.yml

Lines changed: 30 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,34 @@
1-
name: Publish Release to PyPI
1+
name: PyPI
22

33
on:
4-
release:
5-
types: [published]
4+
workflow_call:
5+
inputs:
6+
environment-name:
7+
required: true
8+
type: string
9+
environment-url:
10+
required: true
11+
type: string
12+
repository-url:
13+
required: true
14+
type: string
615

716
jobs:
8-
test-pypi-publish:
9-
name: Publish to Test PyPI
10-
uses: ./.github/workflows/pypi-template.yml
11-
with:
12-
environment-name: test-pypi
13-
environment-url: https://test.pypi.org/p/pydantic-gitlab-webhooks
14-
repository-url: https://test.pypi.org/legacy/
15-
pypi-publish:
16-
name: Publish to PyPI
17-
needs: [test-pypi-publish]
18-
uses: ./.github/workflows/pypi-template.yml
19-
with:
20-
environment-name: pypi
21-
environment-url: https://pypi.org/p/pydantic-gitlab-webhooks
22-
repository-url: https://pypi.org/legacy/
17+
publish:
18+
name: Publish PyPI package
19+
runs-on: ubuntu-24.04
20+
permissions:
21+
id-token: write
22+
environment:
23+
name: ${{ inputs.environment-name }}
24+
url: ${{ inputs.environment-url }}
25+
steps:
26+
- name: Download assets
27+
uses: robinraju/release-downloader@v1
28+
with:
29+
tag: "${{ github.tag }}"
30+
out-file-path: dist/
31+
- name: Publish package distributions to PyPI
32+
uses: pypa/gh-action-pypi-publish@release/v1
33+
with:
34+
repository-url: ${{ inputs.repository-url }}

.github/workflows/release.yml

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
name: Publish release
2+
3+
on:
4+
workflow_call:
5+
6+
jobs:
7+
release:
8+
name: Create
9+
runs-on: ubuntu-24.04
10+
permissions:
11+
contents: write
12+
steps:
13+
- name: Checkout
14+
uses: actions/checkout@v4
15+
with:
16+
fetch-depth: 0
17+
- name: Set up Python
18+
uses: actions/setup-python@v5
19+
with:
20+
python-version: "3.12"
21+
- name: Install poetry
22+
uses: abatilo/actions-poetry@v3
23+
- name: Configure git
24+
run: |
25+
git config user.name "${GITHUB_ACTOR}"
26+
git config user.email "${GITHUB_ACTOR}@users.noreply.github.com"
27+
- name: Create release
28+
run: npx -p @release-it/bumper -p @release-it/conventional-changelog release-it
29+
env:
30+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
31+
- name: Upload artifacts for publication
32+
uses: actions/upload-artifact@v4
33+
with:
34+
name: python-dist
35+
path: dist/*
36+
test-pypi-publish:
37+
name: Publish to Test PyPI
38+
uses: ./.github/workflows/pypi.yml
39+
needs: [release]
40+
permissions:
41+
id-token: write
42+
with:
43+
environment-name: test-pypi
44+
environment-url: https://test.pypi.org/p/pydantic-gitlab-webhooks
45+
repository-url: https://test.pypi.org/legacy/
46+
pypi-publish:
47+
name: Publish to PyPI
48+
needs: [test-pypi-publish]
49+
permissions:
50+
id-token: write
51+
uses: ./.github/workflows/pypi.yml
52+
with:
53+
environment-name: pypi
54+
environment-url: https://pypi.org/p/pydantic-gitlab-webhooks
55+
repository-url: https://pypi.org/legacy/
File renamed without changes.

0 commit comments

Comments
 (0)