@@ -51,63 +51,44 @@ jobs:
51
51
git push origin ${{ github.event.inputs.tag }}
52
52
53
53
build :
54
- name : Build with Hatch
54
+ name : Build
55
55
runs-on : ubuntu-latest
56
56
needs : tag
57
- outputs :
58
- built : ${{ steps.set_output.outputs.built }}
59
57
steps :
60
58
- name : Checkout Code
61
59
uses : actions/checkout@v4
62
60
with :
63
61
fetch-depth : 0
64
62
65
- - name : Check if pyproject.toml exists
66
- id : check_file
67
- run : |
68
- if [ -f "pyproject.toml" ]; then
69
- echo "exists=true" >> $GITHUB_OUTPUT
70
- else
71
- echo "exists=false" >> $GITHUB_OUTPUT
72
- fi
73
-
74
63
- name : Set up Python
75
- if : steps.check_file.outputs.exists == 'true'
76
64
uses : actions/setup-python@v5
77
65
with :
78
66
python-version : ' 3.13'
79
67
80
- - name : Install Hatch
81
- if : steps.check_file.outputs.exists == 'true '
68
+ - name : Build
69
+ if : hashFiles('pyproject.toml') != ' '
82
70
run : |
83
71
pip install --upgrade pip
84
72
pip install hatch
85
73
86
- - name : Set version from tag in pyproject.toml
87
- if : steps.check_file.outputs.exists == 'true'
88
- run : |
89
74
version=${{ github.event.inputs.tag }}
90
75
version=${version#v}
91
76
echo "Setting version to $version"
92
77
sed -i.bak "s/^version = .*/version = \"$version\"/" pyproject.toml
93
78
rm pyproject.toml.bak
94
79
95
- - name : Build Package
96
- if : steps.check_file.outputs.exists == 'true'
97
- run : hatch build
80
+ hatch build
81
+
82
+ echo "Uploading dist/"
83
+ tar -cf dist.tar dist
98
84
99
- - name : Upload dist/
100
- if : steps.check_file.outputs.exists == 'true'
85
+ - name : Upload dist artifact
86
+ # not tested at runtime!
87
+ if : hashFiles('pyproject.toml') != ''
101
88
uses : actions/upload-artifact@v4
102
89
with :
103
90
name : dist
104
- path : dist/
105
-
106
- - name : Set build output
107
- id : set_output
108
- run : |
109
- echo "built=${{ steps.check_file.outputs.exists }}" >> $GITHUB_OUTPUT
110
-
91
+ path : dist.tar
111
92
112
93
release :
113
94
name : Create GitHub Release
@@ -120,45 +101,65 @@ jobs:
120
101
with :
121
102
fetch-depth : 0
122
103
123
- - name : Download dist artifact (if any)
124
- if : needs.build.outputs.built == 'true '
104
+ - name : Download dist artifact
105
+ if : hashFiles('pyproject.toml') != ' '
125
106
uses : actions/download-artifact@v4
126
107
with :
127
108
name : dist
128
109
path : dist
129
110
130
- - name : Create GitHub Release with artifacts
131
- if : needs.build.outputs.built == 'true'
132
-
133
- with :
134
- tag_name : ${{ github.event.inputs.tag }}
135
- name : ${{ github.event.inputs.tag }}
136
- generate_release_notes : true
137
- files : dist/*
111
+ - name : Extract dist.tar
112
+ if : hashFiles('pyproject.toml') != ''
113
+ run : |
114
+ if [[ -f dist/dist.tar ]]; then
115
+ echo "Extracting dist.tar"
116
+ tar -xf dist/dist.tar -C dist
117
+ rm dist/dist.tar
118
+ else
119
+ echo "No dist.tar found; skipping extract"
120
+ fi
138
121
139
- - name : Create GitHub Release without artifacts
140
- if : needs.build.outputs.built == 'false'
122
+ # - name: Warn if no artifacts found
123
+ # run: |
124
+ # if [[ ! -d dist || -z "$(ls -A dist)" ]]; then
125
+ # echo "::warning::No files found in dist/. Release will be created without artifacts."
126
+ # fi
127
+
128
+ - name : Create GitHub Release with artifacts
141
129
142
130
with :
143
131
tag_name : ${{ github.event.inputs.tag }}
144
132
name : ${{ github.event.inputs.tag }}
145
133
generate_release_notes : true
134
+ files : " dist/**"
146
135
147
136
pypi :
148
137
name : Publish to PyPI
149
138
runs-on : ubuntu-latest
150
139
environment : release
151
140
needs : [build, tag]
152
- if : needs.build.outputs.built == 'true'
153
141
154
142
steps :
155
143
- name : Download dist artifact
156
144
uses : actions/download-artifact@v4
157
145
with :
158
146
name : dist
159
147
path : dist
148
+ continue-on-error : true
149
+
150
+ - name : Check if dist contains artifacts
151
+ id : check_dist
152
+ if : hashFiles('pyproject.toml') != ''
153
+ run : |
154
+ if [[ ! -d dist || -z "$(ls -A dist)" ]]; then
155
+ echo "::warning::No artifacts found in dist/. Skipping PyPI publish."
156
+ echo "should_publish=false" >> $GITHUB_OUTPUT
157
+ else
158
+ echo "should_publish=true" >> $GITHUB_OUTPUT
159
+ fi
160
160
161
161
- name : Publish to PyPI
162
+ if : steps.check_dist.outputs.should_publish == 'true'
162
163
uses : pypa/gh-action-pypi-publish@release/v1
163
164
with :
164
165
packages-dir : dist/
0 commit comments