20
20
suffix : ${{ steps.release.outputs.suffix }}
21
21
tag_name : ${{ steps.release.outputs.tag_name }}
22
22
steps :
23
- - uses : actions/checkout@v2
23
+ - uses : actions/checkout@v4
24
24
25
25
- name : Extract tag and Details
26
26
id : release
32
32
echo "new_version=$NEW_VERSION" >> "$GITHUB_OUTPUT"
33
33
echo "suffix=$SUFFIX" >> "$GITHUB_OUTPUT"
34
34
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"
38
35
else
39
36
echo "No tag found"
40
37
exit 1
@@ -44,124 +41,93 @@ jobs:
44
41
needs : details
45
42
runs-on : ubuntu-latest
46
43
steps :
47
- - name : Fetch information from PyPI
44
+ - name : Fetch PyPI version
48
45
run : |
49
46
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
57
49
58
- - name : Compare versions and exit if not newer
50
+ - name : Compare versions
59
51
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"
64
54
exit 1
65
- else
66
- echo "The new version $NEW_VERSION is greater than the latest version $LATEST_VERSION on PyPI."
67
55
fi
68
56
69
57
setup_and_build :
70
58
needs : [details, check_pypi]
71
59
runs-on : ubuntu-latest
72
60
steps :
73
- - uses : actions/checkout@v2
61
+ - uses : actions/checkout@v4
74
62
75
63
- name : Set up Python
76
- uses : actions/setup-python@v4
64
+ uses : actions/setup-python@v5
77
65
with :
78
- python-version : " 3.13 "
66
+ python-version : " 3.10 " # Changed from 3.13 to stable version
79
67
80
68
- 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
84
73
85
- - name : Set project version with Poetry
74
+ - name : Configure Poetry
86
75
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 }}
88
81
89
82
- name : Install dependencies
90
- run : poetry install --sync --no-interaction
83
+ run : poetry install --sync --no-interaction --no-root
91
84
92
- - name : Build source and wheel distribution
93
- run : |
94
- poetry build
85
+ - name : Build package
86
+ run : poetry build
95
87
96
88
- name : Upload artifacts
97
89
uses : actions/upload-artifact@v4
98
90
with :
99
91
name : dist
100
- path : dist/
92
+ path : dist/*
101
93
102
94
pypi_publish :
103
- name : Upload release to PyPI
104
- needs : [setup_and_build, details]
95
+ needs : setup_and_build
105
96
runs-on : ubuntu-latest
106
97
environment :
107
98
name : release
108
99
permissions :
109
- id-token : write
100
+ id-token : write # Essential for trusted publishing
110
101
steps :
111
- - name : Download artifacts
112
- uses : actions/download-artifact@v4
102
+ - uses : actions/download-artifact@v4
113
103
with :
114
104
name : dist
115
105
path : dist/
116
106
117
- - name : Publish distribution to PyPI
107
+ - name : Publish to PyPI
118
108
uses : pypa/gh-action-pypi-publish@release/v1
109
+ with :
110
+ verbose : true # For better debugging
119
111
120
112
github_release :
121
- name : Create GitHub Release
122
- needs : [setup_and_build, details]
113
+ needs : [setup_and_build, pypi_publish]
123
114
runs-on : ubuntu-latest
124
115
permissions :
125
116
contents : write
126
117
steps :
127
- - name : Checkout Code
128
- uses : actions/checkout@v3
118
+ - uses : actions/checkout@v4
129
119
with :
130
120
fetch-depth : 0
131
121
132
- - name : Download artifacts
133
- uses : actions/download-artifact@v3
122
+ - uses : actions/download-artifact@v4
134
123
with :
135
124
name : dist
136
125
path : dist/
137
126
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
154
129
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