Skip to content

Added EOS network

Added EOS network #14

name: handle icon additions
on:
push:
branches:
- main
paths:
- 'packages/core/src/raw-svgs/**'
pull_request:
paths:
- 'packages/core/src/raw-svgs/**'
jobs:
update-and-rebuild:
runs-on: ubuntu-latest
steps:
- name: Setup bun
uses: oven-sh/setup-bun@v1
- name: Checkout repository
uses: actions/checkout@v2
with:
fetch-depth: 10
- name: Set up Node.js
uses: actions/setup-node@v2
with:
node-version: '20'
- name: Install dependencies
run: bun install
- name: Update Metadata
id: update_metadata
run: |
newTokenIcons=$(git diff --name-only HEAD~1 HEAD | grep 'packages/core/src/raw-svgs/tokens/' | xargs basename -a | sed 's/.svg//' | sort -u | tr '\n' ', ' | sed 's/, $//')
newNetworkIcons=$(git diff --name-only HEAD~1 HEAD | grep 'packages/core/src/raw-svgs/networks/' | xargs basename -a | sed 's/.svg//' | sort -u | tr '\n' ', ' | sed 's/, $//')
echo "newTokenIcons=$newTokenIcons" >> $GITHUB_ENV
echo "newNetworkIcons=$newNetworkIcons" >> $GITHUB_ENV
bun run ./packages/utils/src/scripts/update-metadata.ts ${{ env.newTokenIcons }} ${{ env.newNetworkIcons }}
- name: Rebuild Core Package
run: bun run build:core
- name: Rebuild React Package
run: bun run build:react
- name: Create changeset
run: |
newTokens=$(echo $newIcons | tr ',' '\n' | grep -v 'networks-' | tr '\n' ',' | sed 's/,$//')
newNetworks=$(echo $newIcons | tr ',' '\n' | grep 'networks-' | sed 's/networks-//g' | tr '\n' ',' | sed 's/,$//')
if [ -n "$newTokens" ] || [ -n "$newNetworks" ]; then
changesetContent="
---
"@token-icons/core": minor
"@token-icons/react": minor
---"
[ -n "$newTokens" ] && changesetContent+="New Token icons: $newTokens\n"
[ -n "$newNetworks" ] && changesetContent+="New Network icons: $newNetworks\n"
echo "$changesetContent" > .changeset/$(date +%s).md
fi
- name: Bump versions
run: bun changeset version
- name: Commit changes
run: |
git config --global user.name 'github-actions[bot]'
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
git add packages/core packages/react .changeset/
commitMessage=""
description=""
if [ -n "$newTokenIcons" ] && [ -n "$newNetworkIcons" ]; then
commitMessage="core: add new token icons & network icons"
description+="token icons: $newTokenIcons\nnetwork icons: $newNetworkIcons"
elif [ -n "$newTokenIcons" ]; then
commitMessage="core: add new token icons"
description+="token icons: $newTokenIcons"
elif [ -n "$newNetworkIcons" ]; then
commitMessage="core: add new network icons"
description+="network icons: $newNetworkIcons"
fi
if [ -n "$description" ]; then
git commit -m "$commitMessage" -m "$description" || echo "No changes to commit"
else
echo "No new icons to commit"
fi
git push
publish:
needs: update-and-rebuild
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/main'
steps:
- name: Setup bun
uses: oven-sh/setup-bun@v1
- name: Checkout repository
uses: actions/checkout@v2
- name: Set up Node.js
uses: actions/setup-node@v2
with:
node-version: '20'
registry-url: 'https://registry.npmjs.org'
- name: Install dependencies
run: bun install
- name: Publish to npm
run: bun changeset publish
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}