icon library #74
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
# Build icon library, create zip file for release and commit to current branch | |
name: icon library | |
on: | |
workflow_dispatch: | |
push: | |
branches: | |
- release-* | |
jobs: | |
build-icon-library: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repo | |
uses: actions/checkout@v4 | |
- name: Setup Node.js environment | |
uses: actions/setup-node@v4 | |
with: | |
node-version: '20.3.1' | |
registry-url: 'https://registry.npmjs.org' | |
# Don't do anything if we're on development, main or master branches | |
- name: Check branch | |
run: | | |
if [[ $GITHUB_REF == refs/heads/development || $GITHUB_REF == refs/heads/master || $GITHUB_REF == refs/heads/main ]]; then | |
echo "Development, master pr main branch, skipping icon library build" | |
exit 1 | |
fi | |
# Don't do anything if we're on release-x.x.x AND the icon-kit has the same version number (already built for the release) | |
- name: Check if icon library has already been built for this release | |
run: | | |
PKG_VER=`node -pe "require('./packages/react/package.json').version"` | |
ICON_KIT_VER=`sed -n -E 's/.*version[[:space:]]+([0-9]+([.][0-9]+)*).*/\1/p' ./release/icon-kit-template-CHANGELOG.txt` | |
if [[ ${PKG_VER} == ${ICON_KIT_VER} ]]; then | |
echo "Icon library has already been built for this release, skipping" | |
exit 1 | |
fi | |
- name: Run Glypfig | |
run: | | |
npx glypfig \ | |
--apikey $API_KEY \ | |
--filekey $FILE_KEY \ | |
--nodeid $NODE_ID \ | |
--format png,svg,css,react \ | |
--optimize \ | |
--template tsx \ | |
--csspath './release/icon-kit-template-css.eta' \ | |
--jspath './release/icon-kit-template-react-tsx.eta' \ | |
--cssprefix '' \ | |
--license './release/LICENSE.txt' \ | |
--pngscale 2.66 \ | |
--filter 'Size=S' | |
env: | |
API_KEY: ${{ secrets.HDS_ICON_KIT }} | |
FILE_KEY: 'Kxwg3R0zNRHj55nQqFu6VS' | |
NODE_ID: '172:2478' | |
- name: Append React interface into index file | |
run: | | |
echo -e "export { IconProps } from './Icon.interface';\n" | \ | |
cat - ./icon-library/react/tsx/index.ts > temp && mv temp ./icon-library/react/tsx/index.ts | |
- name: Bump version in Changelog | |
run: | | |
PKG_VER=`node -pe "require('./packages/react/package.json').version"` | |
sed -i -E "s/version [0-9]{1,2}.[0-9]{1,2}.[0-9]{1,2}/version ${PKG_VER}/" ./release/icon-kit-template-CHANGELOG.txt | |
- name: Copy Changelog file to icon library | |
run: cp ./release/icon-kit-template-CHANGELOG.txt ./icon-library/CHANGELOG.txt | |
- name: Create release zip file | |
uses: TheDoctor0/zip-release@0.7.6 | |
with: | |
filename: 'release/hds-icon-kit.zip' | |
path: './icon-library' | |
- name: Copy svg files to repo folders | |
run: cp ./icon-library/svg/* ./packages/core/src/svg | |
- name: Copy css files to repo folders | |
run: cp ./icon-library/css/* ./packages/core/src/icons | |
- name: Copy react files to repo folders | |
run: cp ./icon-library/react/tsx/* ./packages/react/src/icons | |
- name: Install React package NPM dependencies | |
run: (cd ./packages/react && yarn) | |
- name: Lint React files | |
run: npx prettier --write './packages/react/src/icons/*.{ts,tsx}' | |
- name: Code analysis for React files | |
run: npx eslint --debug -c './packages/react/.eslintrc.json' --ignore-path './packages/react/.eslintignore' --fix './packages/react/src/icons/*.{ts,tsx}' | |
- name: Remove icon library build directory | |
run: rm -rf ./icon-library | |
- name: Commit changed files | |
run: | | |
git config --global user.email "hds@hel.fi" | |
git config --global user.name "Github Actions" | |
git add . | |
git commit -m 'Updated icon library' | |
git push |