Skip to content

Commit f2147d7

Browse files
committed
ci(workflows): update artifact handling in workflow
1 parent ec03fb2 commit f2147d7

File tree

1 file changed

+23
-11
lines changed

1 file changed

+23
-11
lines changed

.github/workflows/test-and-build-wheel.yml

Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818
POETRY_VERSION: "1.8.2"
1919
PYTHON_VERSION: "3.11"
2020
outputs:
21-
wheel_file: ${{ steps.build.outputs.wheel_file }}
21+
artifact_name: ${{ steps.set-artifact-name.outputs.artifact_name }}
2222
steps:
2323
- uses: actions/checkout@v4
2424

@@ -30,7 +30,7 @@ jobs:
3030
- name: Get full Python version
3131
id: full-python-version
3232
run: |
33-
echo "version=$(python -c 'import sys; print("-".join(str(v) for v in sys.version_info[:3]))')" >> $GITHUB_OUTPUT
33+
echo "version=$(python -c 'import sys; print(\"-\".join(str(v) for v in sys.version_info[:3]))')" >> $GITHUB_OUTPUT
3434
3535
- name: Bootstrap poetry
3636
run: |
@@ -56,18 +56,30 @@ jobs:
5656
- name: Make build script executable
5757
run: chmod +x ./.github/scripts/build.sh
5858

59-
- name: Build Wheel
59+
- name: Build Distributions
6060
id: build
6161
run: |
6262
./.github/scripts/build.sh
63-
WHEEL_FILE=$(ls dist/*.whl | xargs -n 1 basename)
64-
echo "wheel_file=${WHEEL_FILE}" >> $GITHUB_OUTPUT
6563
66-
- name: Upload Artifact
64+
- name: Determine Tag Name
65+
id: get-tag-name
66+
if: startsWith(github.ref, 'refs/tags/')
67+
run: echo "tag_name=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT
68+
69+
- name: Set Artifact Name
70+
id: set-artifact-name
71+
run: |
72+
if [ -n "${{ steps.get-tag-name.outputs.tag_name }}" ]; then
73+
echo "artifact_name=${{ steps.get-tag-name.outputs.tag_name }}-build" >> $GITHUB_OUTPUT
74+
else
75+
echo "artifact_name=pr-build" >> $GITHUB_OUTPUT
76+
fi
77+
78+
- name: Upload Build Artifacts
6779
uses: actions/upload-artifact@v4
6880
with:
69-
name: built-wheel
70-
path: dist/*.whl
81+
name: ${{ steps.set-artifact-name.outputs.artifact_name }}
82+
path: dist/*
7183

7284
test-wheel:
7385
needs: build-wheel
@@ -81,10 +93,10 @@ jobs:
8193
with:
8294
python-version: ${{ matrix.python-version }}
8395

84-
- name: Download Artifact
96+
- name: Download Build Artifacts
8597
uses: actions/download-artifact@v4
8698
with:
87-
name: built-wheel
99+
name: ${{ needs.build-wheel.outputs.artifact_name }}
88100

89101
- name: List Files
90102
run: ls -l
@@ -93,7 +105,7 @@ jobs:
93105
run: |
94106
pip install --upgrade pip
95107
pip install poetry==1.8.2
96-
pip install ${{ needs.build-wheel.outputs.wheel_file }}
108+
pip install ./*.whl
97109
98110
- name: Start server in the background
99111
run: |

0 commit comments

Comments
 (0)