Skip to content

Commit d223791

Browse files
author
Your Name
committed
Merge branch 'feature/initial' of github.com:mathworks-ref-arch/matlab-aws-support-v2 into feature/initial
2 parents 72ee254 + bc03c0a commit d223791

1 file changed

Lines changed: 90 additions & 0 deletions

File tree

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
name: Release Badge
2+
3+
on:
4+
release:
5+
types: [published, edited, prereleased]
6+
push:
7+
tags:
8+
- 'v*'
9+
workflow_dispatch:
10+
11+
permissions:
12+
contents: write
13+
14+
jobs:
15+
make-badge:
16+
runs-on: ubuntu-latest
17+
18+
steps:
19+
- name: Check out default branch
20+
uses: actions/checkout@v4
21+
with:
22+
ref: ${{ github.event.repository.default_branch }}
23+
fetch-depth: 0
24+
25+
- name: Determine version and label
26+
id: meta
27+
shell: bash
28+
run: |
29+
# Prefer the tag from a Release event
30+
if [ "${{ github.event_name }}" = "release" ]; then
31+
VERSION="${{ github.event.release.tag_name }}"
32+
if [ "${{ github.event.release.prerelease }}" = "true" ]; then
33+
LABEL="prerelease"
34+
else
35+
LABEL="release"
36+
fi
37+
else
38+
# Fallback for tag pushes / manual runs
39+
git fetch --tags --force --prune
40+
VERSION="$(git describe --tags --abbrev=0 2>/dev/null || echo 'v0.0.0')"
41+
LABEL="release"
42+
fi
43+
44+
echo "version=$VERSION" >> $GITHUB_OUTPUT
45+
echo "label=$LABEL" >> $GITHUB_OUTPUT
46+
47+
- name: Build SVG badge
48+
shell: bash
49+
run: |
50+
set -e
51+
mkdir -p Documentation/Images
52+
53+
LABEL='${{ steps.meta.outputs.label }}'
54+
VERSION='${{ steps.meta.outputs.version }}'
55+
56+
# Simple width calculation (keeps everything repo-local)
57+
label_chars=${#LABEL}
58+
vers_chars=${#VERSION}
59+
label_w=$(( label_chars * 6 + 20 )) # ~6px per char + padding
60+
right_w=$(( vers_chars * 8 + 20 )) # ~8px per char + padding
61+
[ $label_w -lt 60 ] && label_w=60
62+
[ $right_w -lt 80 ] && right_w=80
63+
total_w=$(( label_w + right_w ))
64+
lx=$(( label_w / 2 ))
65+
rx=$(( label_w + right_w / 2 ))
66+
67+
cat > Documentation/Images/release.svg <<EOF
68+
<svg xmlns="http://www.w3.org/2000/svg" width="${total_w}" height="20" role="img" aria-label="${LABEL}: ${VERSION}">
69+
<linearGradient id="s" x2="0" y2="100%">
70+
<stop offset="0" stop-color="#bbb" stop-opacity=".1"/>
71+
<stop offset="1" stop-opacity=".1"/>
72+
</linearGradient>
73+
<mask id="m"><rect width="${total_w}" height="20" rx="3" fill="#fff"/></mask>
74+
<g mask="url(#m)">
75+
<rect width="${label_w}" height="20" fill="#555"/>
76+
<rect x="${label_w}" width="${right_w}" height="20" fill="#2ea44f"/>
77+
<rect width="${total_w}" height="20" fill="url(#s)"/>
78+
</g>
79+
<g fill="#fff" text-anchor="middle" font-family="Verdana,Geneva,DejaVu Sans,sans-serif" font-size="11">
80+
<text x="${lx}" y="14">${LABEL}</text>
81+
<text x="${rx}" y="14">${VERSION}</text>
82+
</g>
83+
</svg>
84+
EOF
85+
86+
- name: Commit badge
87+
uses: stefanzweifel/git-auto-commit-action@v5
88+
with:
89+
commit_message: "chore: update release badge -> ${{ steps.meta.outputs.version }}"
90+
file_pattern: Documentation/Images/release.svg

0 commit comments

Comments
 (0)