Merge pull request #2 from DominicF96/icon/base-bnb-cosmos #10
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: | | |
newIcons=$(git diff --name-only HEAD~1 HEAD | grep 'packages/core/src/raw-svgs/' | xargs basename -a | sed 's/.svg//' | tr '\n' ', ' | sed 's/, $//') | |
echo "newIcons=$newIcons" >> $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: | | |
if [ -n "$newIcons" ]; then | |
echo " | |
--- | |
'@token-icons/core': minor | |
'@token-icons/react': minor | |
--- | |
Added icons: $newIcons" > .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/ | |
if [ -n "$newIcons" ]; then | |
git commit -m "core: add ${{ env.newIcons }}" || 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 }} |