Skip to content

Auto Release Icons

Auto Release Icons #16

Workflow file for this run

name: Auto Release Icons
on:
workflow_dispatch:
jobs:
build-release:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout Repository
uses: actions/checkout@v4
with:
fetch-depth: 0 # Fetches all history
fetch-tags: true # Explicitly tell checkout to fetch tags
- name: Force Tag Sync
run: |
git fetch --tags --force --prune
# Ensure local tracking of remote tags
git pull --tags || true
- name: Generate Unique Version Tag
id: vars
run: |
YEAR_MONTH=$(date +'%Y.%m')
PATCH=0
# Use ls-remote to check tags directly on the server (most reliable way)
# this avoids issues with the local runner cache
while git ls-remote --tags origin | grep -q "refs/tags/$YEAR_MONTH.$PATCH"; do
echo "Tag $YEAR_MONTH.$PATCH exists on remote, skipping..."
PATCH=$((PATCH + 1))
done
VERSION="$YEAR_MONTH.$PATCH"
echo "tag=$VERSION" >> $GITHUB_OUTPUT
echo "Final Version to be created: $VERSION"
# Get previous tag for icon comparison
PREV_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "")
echo "prev_tag=$PREV_TAG" >> $GITHUB_OUTPUT
- name: Identify New Icons
id: new_icons
run: |
touch table_rows.txt
if [ -z "${{ steps.vars.outputs.prev_tag }}" ]; then
FILES=$(ls icon-svg/*.svg 2>/dev/null || true)
else
FILES=$(git diff --name-only --diff-filter=A ${{ steps.vars.outputs.prev_tag }} HEAD | grep 'icon-svg/.*\.svg$' || true)
fi
if [ -n "$FILES" ]; then
for file in $FILES; do
filename=$(basename "$file")
name="${filename%.*}"
echo "|![Preview](https://raw.githubusercontent.com/${{ github.repository }}/main/icon-svg/$filename) |$name|" >> table_rows.txt
done
echo "has_new_icons=true" >> $GITHUB_OUTPUT
else
echo "has_new_icons=false" >> $GITHUB_OUTPUT
fi
- name: Create Release Notes Body
id: body
run: |
{
echo 'BODY<<EOF'
echo "> [!TIP]"
echo "> View all icons in the - [icon finder](https://elax46.github.io/custom-brand-icons/)"
echo ""
if [ "${{ steps.new_icons.outputs.has_new_icons }}" = "true" ]; then
echo "### New Icons Added"
echo '<div align="center">'
echo ""
echo "| Icon | Name |"
echo "|------|:--------------:|"
cat table_rows.txt
echo ""
echo "</div>"
echo ""
fi
echo 'EOF'
} >> $GITHUB_OUTPUT
- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ steps.vars.outputs.tag }}
name: ${{ steps.vars.outputs.tag }}
body: ${{ steps.body.outputs.BODY }}
generate_release_notes: true
make_latest: true