Skip to content

Commit f48ed7f

Browse files
authored
Merge pull request #8 from generaltranslation/e/ci/fix-release3
fix: ci
2 parents c08af0f + d179ff0 commit f48ed7f

2 files changed

Lines changed: 59 additions & 12 deletions

File tree

.github/workflows/release.yml

Lines changed: 48 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,43 +16,79 @@ jobs:
1616
runs-on: ubuntu-latest
1717
environment:
1818
name: release
19-
outputs:
20-
released: ${{ steps.sampo.outputs.released }}
2119
steps:
2220
- uses: actions/checkout@v4
2321
with:
2422
fetch-depth: 0
2523
- uses: astral-sh/setup-uv@v6
2624
- run: uv sync --all-packages
27-
- name: Create Release Pull Request or Tag
28-
id: sampo
25+
- name: Create Release Pull Request
2926
uses: bruits/sampo/crates/sampo-github-action@main
3027
with:
3128
command: release
32-
create-github-release: true
3329
env:
3430
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
3531

3632
publish:
3733
name: Publish to PyPI
38-
needs: release
39-
if: needs.release.outputs.released == 'true'
4034
runs-on: ubuntu-latest
4135
environment:
4236
name: release
4337
steps:
4438
- uses: actions/checkout@v4
39+
with:
40+
fetch-depth: 2
4541
- uses: astral-sh/setup-uv@v6
46-
- name: Build all packages
42+
43+
- name: Check for version changes
44+
id: check
45+
run: |
46+
CHANGED=$(git diff HEAD~1 -- 'packages/*/pyproject.toml' | grep -c '^+version' || true)
47+
echo "changed=$CHANGED" >> "$GITHUB_OUTPUT"
48+
49+
- name: Create tags and GitHub releases
50+
id: tag
51+
if: steps.check.outputs.changed != '0'
52+
env:
53+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
4754
run: |
55+
NEW_PACKAGES=""
4856
for pkg in packages/*/; do
49-
pkg_name=$(basename "$pkg")
50-
if grep -q '\[build-system\]' "$pkg/pyproject.toml" 2>/dev/null; then
51-
echo "Building $pkg_name..."
52-
uv build --package "$pkg_name" --out-dir dist/
57+
name=$(grep '^name = ' "$pkg/pyproject.toml" | head -1 | sed 's/.*"\(.*\)".*/\1/')
58+
version=$(grep '^version = ' "$pkg/pyproject.toml" | head -1 | sed 's/.*"\(.*\)".*/\1/')
59+
tag="${name}@${version}"
60+
if ! git tag -l "$tag" | grep -q .; then
61+
git tag "$tag"
62+
echo "Tagged $tag"
63+
NEW_PACKAGES="$NEW_PACKAGES $name"
5364
fi
5465
done
66+
git push origin --tags
67+
68+
# Create GitHub releases for each new tag
69+
for pkg in packages/*/; do
70+
name=$(grep '^name = ' "$pkg/pyproject.toml" | head -1 | sed 's/.*"\(.*\)".*/\1/')
71+
version=$(grep '^version = ' "$pkg/pyproject.toml" | head -1 | sed 's/.*"\(.*\)".*/\1/')
72+
tag="${name}@${version}"
73+
# Only create releases for packages that were newly tagged
74+
if echo "$NEW_PACKAGES" | grep -qw "$name"; then
75+
gh release create "$tag" --title "$tag" --generate-notes
76+
echo "Created release $tag"
77+
fi
78+
done
79+
80+
echo "new_packages=$NEW_PACKAGES" >> "$GITHUB_OUTPUT"
81+
82+
- name: Build changed packages
83+
if: steps.check.outputs.changed != '0'
84+
run: |
85+
for pkg_name in ${{ steps.tag.outputs.new_packages }}; do
86+
echo "Building $pkg_name..."
87+
uv build --package "$pkg_name" --out-dir dist/
88+
done
89+
5590
- name: Publish to PyPI
91+
if: steps.check.outputs.changed != '0'
5692
run: uv publish dist/*
5793
env:
5894
UV_PUBLISH_TOKEN: ${{ secrets.PYPI_API_TOKEN }}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
---
2+
pypi/generaltranslation: patch
3+
pypi/generaltranslation-icu-messageformat-parser: patch
4+
pypi/generaltranslation-intl-messageformat: patch
5+
pypi/generaltranslation-supported-locales: patch
6+
pypi/gt-fastapi: patch
7+
pypi/gt-flask: patch
8+
pypi/gt-i18n: patch
9+
---
10+
11+
test: changeset

0 commit comments

Comments
 (0)