Skip to content

Commit b1451d7

Browse files
committed
Update GitHub Actions workflows to support Python 3.12 and 3.13, and add check for Python file changes before release
1 parent 6d7fdb4 commit b1451d7

4 files changed

Lines changed: 29 additions & 4 deletions

File tree

.devcontainer/devcontainer.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,12 @@
99
"vscode": {
1010
"extensions": [
1111
"elagil.pre-commit-helper",
12-
"ms-python.python"
12+
"ms-python.python",
13+
"github.vscode-github-actions",
14+
"vscode-icons-team.vscode-icons",
15+
"yzhang.markdown-all-in-one",
16+
"bierner.markdown-checkbox",
17+
"bierner.markdown-preview-github-styles"
1318
]
1419
}
1520
}

.github/workflows/python-package.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616
strategy:
1717
fail-fast: false
1818
matrix:
19-
python-version: ["3.9", "3.10", "3.11"]
19+
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]
2020

2121
steps:
2222
- uses: actions/checkout@v4

.github/workflows/release.yml

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ permissions:
1212
jobs:
1313
create-release:
1414
runs-on: ubuntu-latest
15+
outputs:
16+
python_changed: ${{ steps.check-python-changes.outputs.python_changed }}
1517

1618
steps:
1719
- name: Checkout repository
@@ -35,6 +37,21 @@ jobs:
3537
command: query
3638
version: unreleased
3739

40+
- name: Check for Python file changes
41+
id: check-python-changes
42+
run: |
43+
git fetch origin main
44+
# Compare current commit to previous one on this branch
45+
CHANGED_FILES=$(git diff --name-only HEAD^ HEAD)
46+
echo "Changed files: $CHANGED_FILES"
47+
48+
# Check if any Python file was changed
49+
if echo "$CHANGED_FILES" | grep -E '\.py$'; then
50+
echo "python_changed=true" >> $GITHUB_ENV
51+
else
52+
echo "python_changed=false" >> $GITHUB_ENV
53+
fi
54+
3855
- name: Set Version Bump Type from GitVersion
3956
id: version-bump
4057
if: github.ref == 'refs/heads/main'
@@ -117,6 +134,7 @@ jobs:
117134
git push origin ${{ steps.gitversion.outputs.semVer }}
118135
119136
- name: Create GitHub Release
137+
if: env.python_changed == 'true'
120138
uses: softprops/action-gh-release@v1
121139
with:
122140
tag_name: v${{ steps.gitversion.outputs.semVer }}
@@ -128,6 +146,7 @@ jobs:
128146
dist/*.whl
129147
dist/*.tar.gz
130148
- name: Upload distributions
149+
if: env.python_changed == 'true'
131150
uses: actions/upload-artifact@v4
132151
with:
133152
name: release-dists
@@ -136,7 +155,7 @@ jobs:
136155
runs-on: ubuntu-latest
137156
needs:
138157
- create-release
139-
if: github.ref == 'refs/heads/main' # Ensures it only runs for the main branch
158+
if: github.ref == 'refs/heads/main' && needs.create-release.outputs.python_changed == 'true' # Ensures it only runs for the main branch and if Python files were changed
140159
permissions:
141160
# IMPORTANT: this permission is mandatory for trusted publishing
142161
id-token: write

.vscode/extensions.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{
22
"recommendations": [
33
"elagil.pre-commit-helper",
4-
"ms-python.python"
4+
"ms-python.python",
5+
"github.vscode-github-actions"
56
]
67
}

0 commit comments

Comments
 (0)