[ICON REQUEST] Added XAI and Zora network icons. #17
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: icon-add | |
on: | |
push: | |
branches: | |
- main | |
paths: | |
- 'packages/core/src/raw-svgs/**' | |
pull_request: | |
branches: | |
- main | |
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: Identify New SVG Files | |
id: files | |
run: | | |
SVG_FILES=$(git diff --name-only HEAD^ HEAD | grep 'packages/core/src/raw-svgs/' | tr '\n' ',') | |
echo "SVG_FILES=${SVG_FILES%,}" >> $GITHUB_ENV | |
echo "New SVG Files: $SVG_FILES" | |
echo "New Token Icons: $newTokenIcons" | |
echo "New Network Icons: $newNetworkIcons" | |
- name: Validate New SVG Files | |
if: env.SVG_FILES | |
run: bun run ./packages/utils/src/scripts/validate-svgs.ts ${{ env.SVG_FILES }} | |
- name: Update Metadata | |
if: env.SVG_FILES | |
run: | | |
newTokenIcons=$(git diff --name-only HEAD^ 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^ 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.SVG_FILES }} | |
- name: Create Changeset | |
run: | | |
if [ -n "$newTokenIcons" ] || [ -n "$newNetworkIcons" ]; then | |
changesetContent="--- | |
\"@token-icons/core\": minor | |
\"@token-icons/react\": minor | |
--- | |
" | |
[ -n "$newTokenIcons" ] && changesetContent+="New Token icons: $newTokenIcons\n" | |
[ -n "$newNetworkIcons" ] && changesetContent+="New Network icons: $newNetworkIcons\n" | |
echo "$changesetContent" > .changeset/$(date +%s).md | |
fi | |
bun changeset version | |
- name: Build Packages | |
run: | | |
bun run build --filter=@token-icons/core --filter=@token-icons/react | |
- 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 . | |
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 origin ${GITHUB_HEAD_REF:-${GITHUB_REF}} | |
publish: | |
needs: update-and-rebuild | |
if: github.ref == 'refs/heads/main' | |
runs-on: ubuntu-latest | |
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 }} |