Skip to content

Commit

Permalink
feat: setup sbb-icons
Browse files Browse the repository at this point in the history
  • Loading branch information
kyubisation committed Jul 12, 2022
1 parent aed64a3 commit a782481
Show file tree
Hide file tree
Showing 13 changed files with 2,855 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# These owners will be the default owners for everything in
# the repo. Unless a later match takes precedence,
# global owners will be requested for
# review when someone opens a pull request.
* @kyubisation @jeripeierSBB @mcilurzo
48 changes: 48 additions & 0 deletions .github/actions/release/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: 'Create release'
description: 'Creates a release, publishes the package and pushes icons to S3'

runs:
using: 'composite'
steps:
- name: 'Release: Create release with standard-version'
run: |
if [ -f CHANGELOG.md ]; then
yarn standard-version
else
yarn standard-version --first-release
fi
shell: bash
- name: 'Release: Push release to repository'
run: git push --follow-tags origin master
shell: bash
- name: 'Release: Determine npm tag'
id: npm_tag
run: |
if [[ "$REF" == *"-"* ]]
then
echo "::set-output name=npm_tag::next"
else
echo "::set-output name=npm_tag::latest"
fi
env:
REF: ${{ github.ref }}
shell: bash
- name: 'Release: Publish @sbb-esta/icons'
run: yarn publish --tag ${{ steps.npm_tag.outputs.npm_tag }}
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
shell: bash

- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.ICON_CDN_AWS_ACCESS_ID }}
aws-secret-access-key: ${{ secrets.ICON_CDN_AWS_ACCESS_KEY }}
aws-region: ${{ env.AWS_REGION }}
env:
AWS_REGION: eu-central-1
- name: Upload icons and indexes to s3
run: aws s3 cp . s3://${{ env.S3BUCKET }} --recursive --exclude "node_modules/*" --include "*.svg" --include index.json
env:
S3BUCKET: cloudfront-icon-cdn-backend-esta-web-prod
shell: bash
22 changes: 22 additions & 0 deletions .github/actions/yarn-install/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: 'Installing Yarn dependencies'
description: 'Installs the dependencies using Yarn'

runs:
using: 'composite'
steps:
- name: 'Yarn: Get cache directory path'
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn cache dir)"
shell: bash
- name: 'Yarn: Restore dependencies from cache'
uses: actions/cache@v3
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
# Cache key. Whenever the something of significance changes (e.g. postinstall), the cache needs to be invalidated.
# If just the `yarn.lock` file changes, the most recent cache can be restored though.
# See: https://docs.github.com/en/actions/guides/caching-dependencies-to-speed-up-workflows#example-using-the-cache-action.
key: ${{ runner.os }}-yarn-v1-${{hashFiles('yarn.lock')}}
restore-keys: ${{ runner.os }}-yarn-v1-
- name: 'Yarn: Install dependencies'
run: yarn install --frozen-lockfile --non-interactive
shell: bash
40 changes: 40 additions & 0 deletions .github/workflows/figma-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: Release

on:
repository_dispatch:
types: [LIBRARY_PUBLISH]

jobs:
release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 18
registry-url: 'https://registry.npmjs.org'
scope: sbb-esta
- name: Yarn Install
uses: ./.github/actions/yarn-install

- name: 'Release: Set git user'
run: |
git config --global user.name 'github-actions'
git config --global user.email '[email protected]'
- name: Extract icons
run: yarn extract
env:
FIGMA_FILE_ID: ${{ secrets.FIGMA_FILE_ID }}
FIGMA_TOKEN: ${{ secrets.FIGMA_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Commit changes
run: |
git add --all
git commit -m "$MESSAGE"
env:
MESSAGE: ${{ github.event.client_payload.description }}

- name: Release
uses: ./.github/actions/release
31 changes: 31 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Release
on:
push:
branches: [master]

jobs:
release:
runs-on: ubuntu-latest
if: >
github.event.workflow_run.event == 'push' &&
github.event.workflow_run.conclusion == 'success' &&
(
startsWith(github.event.workflow_run.head_commit.message, 'feat') ||
startsWith(github.event.workflow_run.head_commit.message, 'fix') ||
startsWith(github.event.workflow_run.head_commit.message, 'refactor')
)
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 18
registry-url: 'https://registry.npmjs.org'
scope: sbb-esta
- name: Yarn Install
uses: ./.github/actions/yarn-install
- name: 'Release: Set git user'
run: |
git config --global user.name 'github-actions'
git config --global user.email '[email protected]'
- name: Release
uses: ./.github/actions/release
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ yarn-debug.log*
yarn-error.log*
lerna-debug.log*

# IDE
.vscode/

# Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json

Expand Down
1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
18.4.0
1 change: 1 addition & 0 deletions icons/add-stop.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
28 changes: 28 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"name": "@sbb-esta/icons",
"version": "0.1.0",
"description": "Icon package for the SBB organization",
"repository": "https://github.com/sbb-design-systems/sbb-icons.git",
"author": "ESTA",
"license": "Apache-2.0",
"keywords": ["icons", "svg", "sbb"],
"scripts": {
"extract": "tsx scripts/extract-icons.ts"
},
"devDependencies": {
"@types/node": "18.0.3",
"@types/svgo": "2.6.3",
"figma-js": "1.15.0",
"node-fetch": "3.2.6",
"octokit": "2.0.3",
"standard-version": "9.5.0",
"svgo": "2.8.0",
"tsx": "3.7.1",
"typescript": "4.7.4"
},
"files": ["icons"],
"publishConfig": {
"access": "public"
},
"type": "module"
}
27 changes: 27 additions & 0 deletions renovate.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
"extends": ["config:base"],
"nodenv": {
"enabled": false
},
"lockFileMaintenance": {
"schedule": ["before 7am on monday"],
"enabled": true
},
"packageRules": [
{
"matchUpdateTypes": ["minor", "patch", "pin", "digest", "lockFileMaintenance", "bump"],
"automerge": true,
"automergeType": "branch",
"automergeStrategy": "squash"
},
{
"groupName": "eslint",
"matchPackagePrefixes": ["@typescript-eslint/", "eslint", "vue-eslint"]
},
{
"groupName": "commitlint",
"matchPackagePrefixes": ["@commitlint/", "standard-version"]
}
]
}
Loading

0 comments on commit a782481

Please sign in to comment.