Skip to content

Commit 2f1f0af

Browse files
committed
add Git tag to release asset file names
1 parent 6512790 commit 2f1f0af

File tree

1 file changed

+20
-5
lines changed

1 file changed

+20
-5
lines changed

.github/workflows/build.yml

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -233,18 +233,33 @@ jobs:
233233
with:
234234
path: artifacts/
235235

236-
- name: Move all files to the same location
236+
- name: Move artifacts to the expected location
237237
run: |
238-
ls -R
239-
cd artifacts
240-
for i in */; do cp ${i}opendtu-onbattery-*.bin ./; done
238+
ls -lR artifacts/
239+
mkdir -p release-artifacts
240+
for i in artifacts/*/; do
241+
for file in ${i}opendtu-onbattery-*.bin; do
242+
# only process if the file actually exists
243+
# (is not just a pattern that failed expansion)
244+
if [ -f "$file" ]; then
245+
filename=$(basename "${file}")
246+
tag_name=${GITHUB_REF#refs/tags/}
247+
# remove prefix "opendtu-onbattery-" from the filename
248+
new_filename="${filename#opendtu-onbattery-}"
249+
# insert the Git tag name after the common prefix
250+
new_filename="opendtu-onbattery-${tag_name}-${new_filename}"
251+
cp -v "${file}" "release-artifacts/${new_filename}"
252+
fi
253+
done
254+
done
255+
ls -lR release-artifacts/
241256
242257
- name: Create release
243258
uses: softprops/action-gh-release@v2
244259
with:
245260
body: ${{steps.github_release.outputs.changelog}}
246261
draft: False
247262
files: |
248-
artifacts/*.zip, artifacts/*.bin
263+
release-artifacts/*.bin
249264
env:
250265
GITHUB_TOKEN: ${{ secrets.RELEASE_TOKEN }}

0 commit comments

Comments
 (0)