Skip to content

Commit 8bc1bd5

Browse files
committed
updated
1 parent f59f748 commit 8bc1bd5

File tree

1 file changed

+39
-73
lines changed

1 file changed

+39
-73
lines changed

.github/workflows/release.yaml

Lines changed: 39 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ jobs:
2020
suffix: ${{ steps.release.outputs.suffix }}
2121
tag_name: ${{ steps.release.outputs.tag_name }}
2222
steps:
23-
- uses: actions/checkout@v2
23+
- uses: actions/checkout@v4
2424

2525
- name: Extract tag and Details
2626
id: release
@@ -32,9 +32,6 @@ jobs:
3232
echo "new_version=$NEW_VERSION" >> "$GITHUB_OUTPUT"
3333
echo "suffix=$SUFFIX" >> "$GITHUB_OUTPUT"
3434
echo "tag_name=$TAG_NAME" >> "$GITHUB_OUTPUT"
35-
echo "Version is $NEW_VERSION"
36-
echo "Suffix is $SUFFIX"
37-
echo "Tag name is $TAG_NAME"
3835
else
3936
echo "No tag found"
4037
exit 1
@@ -44,124 +41,93 @@ jobs:
4441
needs: details
4542
runs-on: ubuntu-latest
4643
steps:
47-
- name: Fetch information from PyPI
44+
- name: Fetch PyPI version
4845
run: |
4946
response=$(curl -s https://pypi.org/pypi/${{ env.PACKAGE_NAME }}/json || echo "{}")
50-
latest_previous_version=$(echo $response | jq --raw-output "select(.releases != null) | .releases | keys_unsorted | last")
51-
if [ -z "$latest_previous_version" ]; then
52-
echo "Package not found on PyPI."
53-
latest_previous_version="0.0.0"
54-
fi
55-
echo "Latest version on PyPI: $latest_previous_version"
56-
echo "latest_previous_version=$latest_previous_version" >> $GITHUB_ENV
47+
latest_version=$(echo $response | jq -r '.info.version // "0.0.0"')
48+
echo "latest_version=$latest_version" >> $GITHUB_ENV
5749
58-
- name: Compare versions and exit if not newer
50+
- name: Compare versions
5951
run: |
60-
NEW_VERSION=${{ needs.details.outputs.new_version }}
61-
LATEST_VERSION=$latest_previous_version
62-
if [ "$(printf '%s\n' "$LATEST_VERSION" "$NEW_VERSION" | sort -rV | head -n 1)" != "$NEW_VERSION" ] || [ "$NEW_VERSION" == "$LATEST_VERSION" ]; then
63-
echo "The new version $NEW_VERSION is not greater than the latest version $LATEST_VERSION on PyPI."
52+
if [ "$(printf '%s\n' "$latest_version" "${{ needs.details.outputs.new_version }}" | sort -rV | head -n1)" != "${{ needs.details.outputs.new_version }}" ]; then
53+
echo "Version ${{ needs.details.outputs.new_version }} is not newer than PyPI version $latest_version"
6454
exit 1
65-
else
66-
echo "The new version $NEW_VERSION is greater than the latest version $LATEST_VERSION on PyPI."
6755
fi
6856
6957
setup_and_build:
7058
needs: [details, check_pypi]
7159
runs-on: ubuntu-latest
7260
steps:
73-
- uses: actions/checkout@v2
61+
- uses: actions/checkout@v4
7462

7563
- name: Set up Python
76-
uses: actions/setup-python@v4
64+
uses: actions/setup-python@v5
7765
with:
78-
python-version: "3.13"
66+
python-version: "3.10" # Changed from 3.13 to stable version
7967

8068
- name: Install Poetry
81-
run: |
82-
curl -sSL https://install.python-poetry.org | python3 -
83-
echo "$HOME/.local/bin" >> $GITHUB_PATH
69+
uses: snok/install-poetry@v1
70+
with:
71+
virtualenvs-create: true
72+
virtualenvs-in-project: true
8473

85-
- name: Set project version with Poetry
74+
- name: Configure Poetry
8675
run: |
87-
poetry version ${{ needs.details.outputs.new_version }}
76+
poetry config virtualenvs.in-project true
77+
poetry config virtualenvs.create true
78+
79+
- name: Set version
80+
run: poetry version ${{ needs.details.outputs.new_version }}
8881

8982
- name: Install dependencies
90-
run: poetry install --sync --no-interaction
83+
run: poetry install --sync --no-interaction --no-root
9184

92-
- name: Build source and wheel distribution
93-
run: |
94-
poetry build
85+
- name: Build package
86+
run: poetry build
9587

9688
- name: Upload artifacts
9789
uses: actions/upload-artifact@v4
9890
with:
9991
name: dist
100-
path: dist/
92+
path: dist/*
10193

10294
pypi_publish:
103-
name: Upload release to PyPI
104-
needs: [setup_and_build, details]
95+
needs: setup_and_build
10596
runs-on: ubuntu-latest
10697
environment:
10798
name: release
10899
permissions:
109-
id-token: write
100+
id-token: write # Essential for trusted publishing
110101
steps:
111-
- name: Download artifacts
112-
uses: actions/download-artifact@v4
102+
- uses: actions/download-artifact@v4
113103
with:
114104
name: dist
115105
path: dist/
116106

117-
- name: Publish distribution to PyPI
107+
- name: Publish to PyPI
118108
uses: pypa/gh-action-pypi-publish@release/v1
109+
with:
110+
verbose: true # For better debugging
119111

120112
github_release:
121-
name: Create GitHub Release
122-
needs: [setup_and_build, details]
113+
needs: [setup_and_build, pypi_publish]
123114
runs-on: ubuntu-latest
124115
permissions:
125116
contents: write
126117
steps:
127-
- name: Checkout Code
128-
uses: actions/checkout@v3
118+
- uses: actions/checkout@v4
129119
with:
130120
fetch-depth: 0
131121

132-
- name: Download artifacts
133-
uses: actions/download-artifact@v3
122+
- uses: actions/download-artifact@v4
134123
with:
135124
name: dist
136125
path: dist/
137126

138-
- name: Create GitHub Release
139-
id: create_release
140-
env:
141-
GH_TOKEN: ${{ github.token }}
142-
run: |
143-
gh release create ${{ needs.details.outputs.tag_name }} dist/* --title ${{ needs.details.outputs.tag_name }} --generate-notes
144-
145-
bump_homebrew_formula:
146-
name: Dispatch event to Repo B
147-
needs: [details, github_release, pypi_publish]
148-
runs-on: ubuntu-latest
149-
environment:
150-
name: release
151-
steps:
152-
- name: Dispatch Repository Dispatch event
153-
uses: peter-evans/repository-dispatch@v2
127+
- name: Create Release
128+
uses: softprops/action-gh-release@v1
154129
with:
155-
token: ${{ secrets.PYPI_API_TOKEN }}
156-
repository: ${{ env.OWNER }}/{{ env.TAP_NAME }}
157-
event-type: "update-formula"
158-
client-payload: |-
159-
{
160-
"formula_version": "${{env.FORMULA_VERSION}}",
161-
"formula_url": "${{ env.FORMULA_URL }}",
162-
"formula_name": "${{ env.FORMULA_NAME }}"
163-
}
164-
env:
165-
FORMULA_VERSION: ${{ needs.details.outputs.new_version }}
166-
FORMULA_NAME: ${{ env.PACKAGE_NAME }}
167-
FORMULA_URL: https://github.com/${{env.OWNER}}/${{env.PACKAGE_NAME}}/releases/download/${{ needs.details.outputs.new_version }}/${{env.PACKAGE_NAME}}-${{ needs.details.outputs.new_version }}.tar.gz
130+
tag_name: ${{ needs.details.outputs.tag_name }}
131+
files: |
132+
dist/*
133+
generate_release_notes: true

0 commit comments

Comments
 (0)