Skip to content

Commit 0b51483

Browse files
committed
ci: automate semantic release workflows
1 parent f216f63 commit 0b51483

18 files changed

Lines changed: 293 additions & 828 deletions

.github/workflows/codeql-analysis.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,11 @@ jobs:
3838

3939
steps:
4040
- name: Checkout repository
41-
uses: actions/checkout@v3
41+
uses: actions/checkout@v6
4242

4343
# Initializes the CodeQL tools for scanning.
4444
- name: Initialize CodeQL
45-
uses: github/codeql-action/init@v2
45+
uses: github/codeql-action/init@v4
4646
with:
4747
languages: ${{ matrix.language }}
4848
# If you wish to specify custom queries, you can do so here or in a config file.
@@ -53,7 +53,7 @@ jobs:
5353
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
5454
# If this step fails, then you should remove it and run the build manually (see below)
5555
# - name: Autobuild
56-
# uses: github/codeql-action/autobuild@v2
56+
# uses: github/codeql-action/autobuild@v4
5757

5858
# ℹ️ Command-line programs to run using the OS shell.
5959
# 📚 https://git.io/JvXDl
@@ -67,4 +67,4 @@ jobs:
6767
# make release
6868

6969
- name: Perform CodeQL Analysis
70-
uses: github/codeql-action/analyze@v2
70+
uses: github/codeql-action/analyze@v4

.github/workflows/continuous_deployment.yml

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

.github/workflows/continuous_integration.yml

Lines changed: 9 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -26,56 +26,16 @@ on:
2626
- ".editorconfig"
2727
jobs:
2828
build:
29-
name: ${{matrix.os}} / ${{ matrix.python-version }}
30-
runs-on: ${{ matrix.os }}-latest
29+
name: ${{ matrix.runner }} / Python ${{ matrix.python-version }}
3130
strategy:
3231
fail-fast: false
3332
matrix:
34-
# python-version: [2.7, 3.6, 3.7, 3.8, 3.9]
35-
# os: [MacOS, Ubuntu, Windows]
36-
# architecture: [x64, x86]
37-
python-version: [3.7, 3.8, 3.9]
38-
os: [MacOS, Ubuntu, Windows]
33+
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]
34+
runner: [macos-latest, ubuntu-latest, windows-latest]
3935
architecture: [x64]
40-
steps:
41-
- uses: actions/checkout@v1
42-
43-
- name: Set up Python ${{ matrix.python-version }}
44-
uses: actions/setup-python@v5
45-
with:
46-
python-version: ${{ matrix.python-version }}
47-
architecture: ${{ matrix.architecture }}
48-
49-
- name: Get python path
50-
id: python-path
51-
run: |
52-
echo ::set-output name=path::$(python -c "import sys; print(sys.executable)")
53-
54-
- name: Install latest pip
55-
run: |
56-
python -m pip install --upgrade pip pipenv --upgrade-strategy=eager
57-
58-
- name: Install
59-
env:
60-
PIPENV_DEFAULT_PYTHON_VERSION: ${{ matrix.python-version }}
61-
PYTHONWARNINGS: ignore:DEPRECATION
62-
PYTHONIOENCODING: "utf-8"
63-
GIT_ASK_YESNO: "false"
64-
run: |
65-
git submodule sync
66-
git submodule update --init --recursive
67-
python -m pip install -e . --upgrade
68-
pipenv install --deploy --dev --python=${{ steps.python-path.outputs.path }}
69-
70-
- name: Run tests
71-
env:
72-
PIPENV_DEFAULT_PYTHON_VERSION: ${{ matrix.python-version }}
73-
PYTHONWARNINGS: ignore:DEPRECATION
74-
PIPENV_NOSPIN: "1"
75-
CI: "1"
76-
GIT_ASK_YESNO: "false"
77-
PYPI_VENDOR_DIR: "./tests/pypi/"
78-
PYTHONIOENCODING: "utf-8"
79-
GIT_SSH_COMMAND: ssh -o StrictHostKeyChecking=accept-new -o CheckHostIP=no
80-
run: |
81-
pipenv run pytest
36+
uses: ./.github/workflows/test.yml
37+
with:
38+
python-version: ${{ matrix.python-version }}
39+
runner: ${{ matrix.runner }}
40+
architecture: ${{ matrix.architecture }}
41+
build-distribution: ${{ matrix.runner == 'ubuntu-latest' && matrix.python-version == '3.13' }}

.github/workflows/dependency-review.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,6 @@ jobs:
1515
runs-on: ubuntu-latest
1616
steps:
1717
- name: 'Checkout Repository'
18-
uses: actions/checkout@v3
18+
uses: actions/checkout@v6
1919
- name: 'Dependency Review'
20-
uses: actions/dependency-review-action@v1
20+
uses: actions/dependency-review-action@v5

.github/workflows/greetings.yml

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

.github/workflows/prerelease.yml

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
name: Prerelease
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- master
7+
types:
8+
- opened
9+
- synchronize
10+
- reopened
11+
12+
permissions:
13+
contents: read
14+
15+
jobs:
16+
test:
17+
name: Test
18+
uses: ./.github/workflows/test.yml
19+
with:
20+
python-version: "3.13"
21+
runner: ubuntu-latest
22+
build-distribution: true
23+
24+
prerelease:
25+
name: Prerelease to PyPI
26+
if: github.event.pull_request.head.repo.full_name == github.repository
27+
needs: test
28+
runs-on: ubuntu-latest
29+
environment: pypi-prerelease
30+
concurrency:
31+
group: ${{ github.workflow }}-pr-${{ github.event.pull_request.number }}
32+
cancel-in-progress: false
33+
permissions:
34+
contents: write
35+
id-token: write
36+
pull-requests: read
37+
env:
38+
CI: "1"
39+
40+
steps:
41+
- name: Checkout pull request branch
42+
uses: actions/checkout@v6
43+
with:
44+
repository: ${{ github.event.pull_request.head.repo.full_name }}
45+
ref: ${{ github.event.pull_request.head.ref }}
46+
fetch-depth: 0
47+
fetch-tags: true
48+
token: ${{ secrets.GITHUB_TOKEN }}
49+
50+
- name: Create prerelease tag and distributions
51+
id: prerelease
52+
uses: python-semantic-release/python-semantic-release@v10.5.3
53+
with:
54+
github_token: ${{ secrets.GITHUB_TOKEN }}
55+
prerelease: "true"
56+
prerelease_token: "dev"
57+
commit: "false"
58+
tag: "true"
59+
push: "true"
60+
vcs_release: "false"
61+
changelog: "false"
62+
63+
- name: Publish prerelease distributions to PyPI
64+
if: steps.prerelease.outputs.released == 'true'
65+
uses: pypa/gh-action-pypi-publish@release/v1
66+
with:
67+
packages-dir: dist/
68+
print-hash: true

.github/workflows/release.yml

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
8+
permissions:
9+
contents: read
10+
11+
jobs:
12+
release:
13+
name: Release
14+
runs-on: ubuntu-latest
15+
environment: pypi-release
16+
concurrency:
17+
group: ${{ github.workflow }}-${{ github.ref_name }}
18+
cancel-in-progress: false
19+
permissions:
20+
contents: write
21+
id-token: write
22+
env:
23+
CI: "1"
24+
25+
steps:
26+
- name: Checkout code
27+
uses: actions/checkout@v6
28+
with:
29+
fetch-depth: 0
30+
fetch-tags: true
31+
32+
- name: Set up Python 3.9
33+
uses: actions/setup-python@v6
34+
with:
35+
python-version: "3.9"
36+
cache: pip
37+
cache-dependency-path: pyproject.toml
38+
39+
- name: Install dependencies
40+
run: |
41+
python -m pip install --upgrade pip
42+
43+
- name: Create version, tag, release and distributions
44+
id: release
45+
uses: python-semantic-release/python-semantic-release@v10.5.3
46+
with:
47+
github_token: ${{ secrets.GITHUB_TOKEN }}
48+
git_committer_name: github-actions[bot]
49+
git_committer_email: 41898282+github-actions[bot]@users.noreply.github.com
50+
changelog: "false"
51+
52+
- name: Publish package distributions to PyPI
53+
if: steps.release.outputs.released == 'true'
54+
uses: pypa/gh-action-pypi-publish@release/v1
55+
with:
56+
packages-dir: dist/
57+
print-hash: true
58+
59+
- name: Upload distributions to GitHub Release
60+
if: steps.release.outputs.released == 'true'
61+
uses: python-semantic-release/publish-action@v10.5.3
62+
with:
63+
github_token: ${{ secrets.GITHUB_TOKEN }}
64+
tag: ${{ steps.release.outputs.tag }}

.github/workflows/stale.yml

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

.github/workflows/test.yml

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
name: Test
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
python-version:
7+
required: true
8+
type: string
9+
runner:
10+
required: true
11+
type: string
12+
architecture:
13+
required: false
14+
type: string
15+
default: x64
16+
build-distribution:
17+
required: false
18+
type: boolean
19+
default: false
20+
21+
jobs:
22+
test:
23+
name: ${{ inputs.runner }} / Python ${{ inputs.python-version }}
24+
runs-on: ${{ inputs.runner }}
25+
steps:
26+
- uses: actions/checkout@v6
27+
28+
- name: Set up Python ${{ inputs.python-version }}
29+
uses: actions/setup-python@v6
30+
with:
31+
python-version: ${{ inputs.python-version }}
32+
architecture: ${{ inputs.architecture }}
33+
cache: pip
34+
cache-dependency-path: pyproject.toml
35+
36+
- name: Install latest pip
37+
run: |
38+
python -m pip install --upgrade pip
39+
40+
- name: Install
41+
run: |
42+
python -m pip install -e ".[dev]"
43+
44+
- name: Run tests
45+
env:
46+
PYTHONWARNINGS: ignore:DEPRECATION
47+
CI: "1"
48+
PYTHONIOENCODING: "utf-8"
49+
run: |
50+
python -m pytest
51+
52+
- name: Build distribution
53+
if: inputs.build-distribution
54+
run: |
55+
python -m build

0 commit comments

Comments
 (0)