Skip to content

new network icons: aurora,base,beam,blast,boba,chiliz,cosmos,cosmos-h… #12

new network icons: aurora,base,beam,blast,boba,chiliz,cosmos,cosmos-h…

new network icons: aurora,base,beam,blast,boba,chiliz,cosmos,cosmos-h… #12

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
- 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="core: add new icons - "
if [ -n "$newTokenIcons" ]; then
commitMessage+="tokens: $newTokenIcons"
fi
if [ -n "$newNetworkIcons" ]; then
commitMessage+=", networks: $newNetworkIcons"
fi
git commit -m "$commitMessage" || echo "No changes to commit"
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 }}