Skip to content

Commit e41b9b5

Browse files
committed
Refactor GitHub Actions workflow for building and releasing: update job names, improve comments, and streamline release creation process.
1 parent f262f75 commit e41b9b5

File tree

1 file changed

+27
-27
lines changed

1 file changed

+27
-27
lines changed

.github/workflows/publish.yml

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,30 @@
1-
name: Build, Tag & Publish Pixelcore
1+
name: Build, Release & Publish Pixelcore
22

3-
# Only trigger on push to master
43
on:
54
push:
65
branches:
76
- master
87

98
jobs:
10-
tag-build-publish:
9+
release:
1110
runs-on: ubuntu-latest
1211
env:
1312
PYPI_API_TOKEN: ${{ secrets.PYPI_API_TOKEN }}
1413
steps:
15-
# 1. Checkout code
14+
# 1. Checkout full repo
1615
- name: Checkout repository
1716
uses: actions/checkout@v3
17+
with:
18+
fetch-depth: 0 # full history
1819

1920
# 2. Set up Python
2021
- name: Set up Python
2122
uses: actions/setup-python@v5
2223
with:
2324
python-version: "3.10"
2425

25-
# 3. Install dependencies for building
26-
- name: Install build dependencies
26+
# 3. Install build dependencies
27+
- name: Install build tools
2728
run: |
2829
python -m pip install --upgrade pip
2930
pip install toml build twine
@@ -34,35 +35,34 @@ jobs:
3435
run: |
3536
VERSION=$(python -c "import toml; print(toml.load('pyproject.toml')['project']['version'])")
3637
echo "VERSION=$VERSION" >> $GITHUB_ENV
37-
echo "Version read from pyproject.toml: $VERSION"
38+
echo "Version read: $VERSION"
3839
39-
# 5. Auto-tag if tag does not exist
40-
- name: Create tag if missing
41-
id: tag
40+
# 5. Optionally run tests
41+
- name: Run tests
4242
run: |
43-
# Configure Git user/email for tags
44-
git config --global user.name "github-actions"
45-
git config --global user.email "github-actions@github.com"
43+
python -m pip install -e .[dev]
44+
pytest tests
4645
47-
# Create tag only if it does not exist
48-
if ! git rev-parse "v$VERSION" >/dev/null 2>&1; then
49-
echo "Tag v$VERSION not found. Creating tag..."
50-
git tag -a "v$VERSION" -m "Release v$VERSION"
51-
git push origin "v$VERSION"
46+
# 6. Create release & tag via GH CLI
47+
- name: Create release (auto-tag)
48+
env:
49+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
50+
VERSION: ${{ env.VERSION }}
51+
run: |
52+
if gh release view "v$VERSION" >/dev/null 2>&1; then
53+
echo "Release v$VERSION already exists."
5254
else
53-
echo "Tag v$VERSION already exists."
55+
echo "Creating release v$VERSION..."
56+
gh release create "v$VERSION" \
57+
--title "v$VERSION" \
58+
--notes "Release v$VERSION" \
59+
--draft=false
5460
fi
5561
56-
# 6. Build distributions
57-
- name: Build package
62+
# 7. Build source + wheel distributions
63+
- name: Build distributions
5864
run: python -m build
5965

60-
# 7. Optionally, run tests before publishing
61-
# - name: Run tests
62-
# run: |
63-
# python -m pip install -e .[dev]
64-
# pytest tests
65-
6666
# 8. Publish to PyPI
6767
- name: Publish to PyPI
6868
uses: pypa/gh-action-pypi-publish@release/v1

0 commit comments

Comments
 (0)