add network icons #11
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: 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: | | |
changesetContent="---\n'@token-icons/core': minor\n'@token-icons/react': minor\n---\n" | |
if [ -n "$newTokenIcons" ]; then | |
changesetContent+="new token icons: $newTokenIcons\n" | |
fi | |
if [ -n "$newNetworkIcons" ]; then | |
changesetContent+="new network icons: $newNetworkIcons\n" | |
fi | |
echo "$changesetContent" > .changeset/$(date +%s).md | |
- 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 }} |