Skip to content

Commit bbbb7ac

Browse files
committed
CI: Pretty-format tag names when creating releases
1 parent 8bc2991 commit bbbb7ac

File tree

1 file changed

+33
-2
lines changed

1 file changed

+33
-2
lines changed

.github/workflows/build.yml

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ jobs:
1010
steps:
1111
- name: Checkout
1212
uses: actions/checkout@v3
13+
1314
- name: Typst
1415
uses: lvignoli/typst-action@main
1516
with:
@@ -21,9 +22,39 @@ jobs:
2122
name: PDF
2223
path: src/main.pdf
2324

24-
- name: Release
25+
- name: Get current date for release
26+
id: date
27+
if: github.ref_type == 'tag'
28+
run: echo "::set-output name=date::$(date +'%Y-%m-%d')"
29+
30+
- name: Format tag for release
31+
id: format_tag
32+
if: github.ref_type == 'tag'
33+
env:
34+
TAG_NAME: ${{ github.ref_name }}
35+
run: |
36+
TAG="$TAG_NAME"
37+
# normalize separators to spaces
38+
TAG="${TAG//_/ }"
39+
TAG="${TAG//-/ }"
40+
# split and capitalize each word
41+
read -ra parts <<< "$TAG"
42+
pretty=""
43+
for w in "${parts[@]}"; do
44+
if [[ -z "$w" ]]; then continue; fi
45+
first="${w:0:1}"
46+
rest="${w:1}"
47+
pretty+="${first^^}${rest} "
48+
done
49+
pretty="${pretty% }"
50+
echo "formatted tag: '$pretty'"
51+
echo "::set-output name=pretty::$pretty"
52+
53+
- name: Create release
2554
uses: softprops/action-gh-release@v1
2655
if: github.ref_type == 'tag'
2756
with:
28-
name: "${{ github.ref_name }} — ${{ env.DATE }}"
57+
name: "${{ steps.format_tag.outputs.pretty }} — ${{ steps.date.outputs.date }}"
2958
files: src/main.pdf
59+
60+

0 commit comments

Comments
 (0)