Skip to content

Commit

Permalink
Merge pull request #227 from api3dao/main
Browse files Browse the repository at this point in the history
`main` to `production` sync
  • Loading branch information
hiletmis authored Feb 5, 2024
2 parents 20bb550 + a14cd9a commit b3f5b2b
Show file tree
Hide file tree
Showing 10 changed files with 162 additions and 58 deletions.
8 changes: 0 additions & 8 deletions .changeset/README.md

This file was deleted.

63 changes: 63 additions & 0 deletions .github/workflows/auto-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
# https://github.com/changesets/action
name: Auto-release

on:
push:
branches:
- main

env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}

jobs:
release:
name: Release
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
# This makes Actions fetch all Git history so that Changesets can generate changelogs with the correct commits
fetch-depth: 0

- name: Setup pnpm
uses: pnpm/action-setup@v2
with:
version: 8.12.1
- uses: actions/setup-node@v4
with:
node-version: "18.x"
cache: 'pnpm'
- name: Install dependencies
run: pnpm install --frozen-lockfile

- name: Build package
run: pnpm run build

- name: Check file existence
id: check_files
uses: andstor/file-existence-action@v3
with:
files: "./.changeset/changeset.md"

- name: Changeset version
if: steps.check_files.outputs.files_exists == 'true'
run: pnpm changeset version

- name: Commit changes
uses: stefanzweifel/git-auto-commit-action@v5
id: auto-commit-action
if: steps.check_files.outputs.files_exists == 'true'
with:
commit_message: Update version
commit_options: '--no-verify --signoff'

- name: Create Release
if: steps.check_files.outputs.files_exists == 'true'
id: changesets
uses: changesets/action@v1
with:
publish: pnpm run release
commit: "ci: release logos package"
title: "ci: release logos package"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
14 changes: 13 additions & 1 deletion .github/workflows/deployfe.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,25 @@ jobs:
- name: Fetch Logos
if : github.ref == 'refs/heads/main' || contains(github.event.pull_request.labels.*.name, 'fetch')
run: pnpm run fetch
- uses: stefanzweifel/git-auto-commit-action@v5
- name: Commit changes
uses: stefanzweifel/git-auto-commit-action@v5
id: auto-commit-action
if : github.ref == 'refs/heads/main' || contains(github.event.pull_request.labels.*.name, 'fetch')
with:
commit_message: Fetch Logos from Dropbox
commit_options: '--no-verify --signoff'
- name: Build Package
run: pnpm run package
- name: "Run if changes have been detected"
id: add-changeset
if: steps.auto-commit-action.outputs.changes_detected == 'true'
run: pnpm run auto-release
- name: Add changeset
uses: stefanzweifel/git-auto-commit-action@v5
if : steps.auto-commit-action.outputs.changes_detected == 'true'
with:
commit_message: Added changeset
commit_options: '--no-verify --signoff'
- name: Install Frontend Packages
if : github.ref == 'refs/heads/main' || contains(github.event.pull_request.labels.*.name, 'deploy')
run: pnpm install
Expand Down
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# @api3/logos

## 2.8.3

### Patch Changes

- e781776: # What's Changed
Release created by the release script.
Logos updated.

## 2.8.2

### Patch Changes
Expand Down
8 changes: 4 additions & 4 deletions helpers/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ module.exports = {
renameFiles
};

function getErrorImage(mode) {
return camelcase(mode, { pascalCase: true }) + 'Error';
function getPlaceholderImage(mode) {
return camelcase(mode, { pascalCase: true }) + 'Placeholder';
}

function sanitizeName(name, suffix = '', prefix = '') {
Expand Down Expand Up @@ -69,13 +69,13 @@ function generateFunction(batchName, switchCase, mode) {
function ${batchName}(id, light = false) {
if (!id) {
return ${getErrorImage(mode)}
return ${getPlaceholderImage(mode)}
}
switch (sanitizeName(\`\${id}\${light ? "l" : ""}\`).toLowerCase()) {
${switchCase}
default:
return light ? ${batchName}(id) : ${getErrorImage(mode)}
return light ? ${batchName}(id) : ${getPlaceholderImage(mode)}
}
}
Expand Down
9 changes: 5 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@phase21/logos",
"version": "2.8.2",
"version": "2.8.3",
"license": "MIT",
"sideEffects": false,
"scripts": {
Expand All @@ -11,7 +11,8 @@
"fetch": "node scripts/fetch-missing.js",
"package": "pnpm run build",
"prettier": "prettier --write \"**/*.{js,jsx,json,md}\"",
"release": "pnpm changeset publish"
"release": "pnpm changeset publish",
"auto-release": "node scripts/release.js"
},
"dependencies": {
"camelcase": "^6.3.0"
Expand All @@ -22,7 +23,7 @@
"@changesets/changelog-github": "^0.5.0",
"@changesets/cli": "^2.27.1",
"@phase21/api-integrations": "^1.1.0",
"@phase21/chains": "^0.5.0",
"@phase21/chains": "^4.5.1",
"dropbox": "^10.34.0",
"node-fetch": "^2.7.0",
"dotenv": "^16.4.1",
Expand All @@ -35,4 +36,4 @@
"files": [
"dist"
]
}
}
61 changes: 27 additions & 34 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion scripts/build-svg.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ function buildSwitchCase(mode) {

function buildLogoImports(files, mode, format) {
let options = getLogoList(mode);
options.push('error');
options.push('placeholder');
const prefix = mode === 'chain' ? 'Chain' : '';
return utils.generateImports(files, options, camelcase(mode, { pascalCase: true }), prefix, mode, format);
}
Expand Down
35 changes: 35 additions & 0 deletions scripts/release.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
const fs = require('fs/promises');

async function getChangeset() {
return await fs.readdir('./.changeset');
}

async function createChangeset() {
const changeset = `---
"@phase21/logos": patch
---
# What's Changed
Release created by the release script.
Logos updated.
`;
await fs.writeFile('./.changeset/changeset.md', changeset);
console.log('✨ Created changeset file.');
}


async function checkChangeset() {
const changeset = await getChangeset();
if (changeset.some(file => file.endsWith('.md'))) {
console.log('There is already a .md file in the .changeset directory.');
} else {
await createChangeset();
}
}

async function main() {
console.log('🏗 Checking changeset files...');
Promise.all([checkChangeset()]).then(() => console.log('✅ Finished checking changeset files.'));
}

main();
12 changes: 6 additions & 6 deletions viewer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,21 @@
"homepage": "https://api3dao.github.io/logos/",
"private": true,
"devDependencies": {
"@phase21/chains": "^0.5.0",
"@phase21/chains": "^4.5.1",
"@chakra-ui/icons": "^2.1.1",
"@chakra-ui/react": "^2.8.2",
"@emotion/react": "^11.11.3",
"@emotion/styled": "^11.11.0",
"@testing-library/jest-dom": "^6.3.0",
"@testing-library/react": "^14.1.2",
"@testing-library/jest-dom": "^6.4.1",
"@testing-library/react": "^14.2.1",
"@testing-library/user-event": "^14.5.2",
"@phase21/logos": "file:../",
"@phase21/logos": "workspace:*",
"framer-motion": "^11.0.3",
"gh-pages": "^6.1.1",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-markdown": "^9.0.1",
"react-router-dom": "^6.21.3",
"react-router-dom": "^6.22.0",
"react-scripts": "5.0.1",
"react-syntax-highlighter": "^15.5.0",
"web-vitals": "^3.5.2",
Expand Down Expand Up @@ -50,4 +50,4 @@
"last 1 safari version"
]
}
}
}

0 comments on commit b3f5b2b

Please sign in to comment.