Skip to content

Commit c520fd0

Browse files
authored
feat(cicd): Configure build, deployment and add documentation (#14)
* build(config): add license, types and files to package.json * refactor(vite): use ts for index.ts * fix(releaserc): typo in css * fix(vite): fix entrypoint * fix(build): try to fix build by not specifying "module" in package.json vitejs/vite#12446 (comment) * fix(build): try to fix build by following wuruoyun/vue-component-lib-starter * fix(build): fix typos in package.json * fix(build): switch to vitepress for demo and developement setup * feat(build) split up deployment and add gh-pages deployment * fix(build): add npm ci to deploy-npm job * fix(build): add vitepress build to job * fix(build): add path to download-artifact step
1 parent 6e53382 commit c520fd0

32 files changed

+1565
-258
lines changed

.github/workflows/build.yaml

Lines changed: 56 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,38 @@ on: [push]
55
jobs:
66
build:
77
runs-on: ubuntu-latest
8+
permissions:
9+
contents: read # to be able to publish a GitHub release
10+
steps:
11+
- uses: actions/checkout@v4
12+
- uses: actions/setup-node@v4
13+
with:
14+
node-version: "20"
15+
cache: "npm"
16+
registry-url: "https://registry.npmjs.org"
17+
- run: npm ci # install dependencies
18+
- run: npm run build # build library
19+
- run: npm run docs:build # build docs
20+
- name: upload library artifacts
21+
uses: actions/upload-artifact@v4
22+
with:
23+
name: library_dist
24+
path: ./dist
25+
- name: upload vitepress artifacts
26+
uses: actions/upload-artifact@v4
27+
with:
28+
name: vitepress_dist
29+
path: ./docs/.vitepress/dist
30+
31+
deploy-npm:
32+
runs-on: ubuntu-latest
33+
needs: build
834
permissions:
935
contents: write # to be able to publish a GitHub release
1036
issues: write # to be able to comment on released issues
1137
pull-requests: write # to be able to comment on released pull requests
1238
id-token: write # to enable use of OIDC for npm provenance
39+
if: github.ref == 'refs/heads/main' || github.ref == 'refs/heads/beta'
1340
steps:
1441
- uses: actions/checkout@v4
1542
- uses: actions/setup-node@v4
@@ -18,10 +45,38 @@ jobs:
1845
cache: "npm"
1946
registry-url: "https://registry.npmjs.org"
2047
- run: npm ci # install dependencies
21-
- run: npm run build # or any other step to build your package
48+
- name: Download build-results
49+
uses: actions/download-artifact@v4
50+
with:
51+
name: library_dist
52+
path: ./dist
2253
- name: run semantic-release
2354
env:
2455
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
2556
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
2657
run: npm run semantic-release
2758

59+
deploy-gh-pages:
60+
runs-on: ubuntu-latest
61+
needs: build
62+
# Grant GITHUB_TOKEN the permissions required to make a Pages deployment
63+
permissions:
64+
pages: write # to deploy to Pages
65+
id-token: write # to verify the deployment originates from an appropriate source
66+
# Deploy to the github-pages environment
67+
environment:
68+
name: github-pages
69+
url: ${{ steps.deployment.outputs.page_url }}
70+
if: github.ref == 'refs/heads/main'
71+
steps:
72+
- name: Download build-results
73+
uses: actions/download-artifact@v4
74+
with:
75+
name: vitepress_dist
76+
path: ./docs/.vitepress/dist
77+
- name: Deploy to GitHub Pages
78+
uses: peaceiris/actions-gh-pages@v4
79+
id: deployment
80+
with:
81+
github_token: ${{ secrets.GITHUB_TOKEN }}
82+
publish_dir: ./docs/.vitepress/dist

.releaserc.json

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,19 +22,15 @@
2222
{
2323
"assets": [
2424
{
25-
"path": "dist/mde5-patternlab-vue.js",
25+
"path": "dist/muc-patternlab-vue.es.js",
2626
"label": "JS distribution"
2727
},
28-
{
29-
"path": "dist/mde5-patternlab-vue.umd.cjs",
30-
"label": "UMD/CJS distribution"
31-
},
3228
{
3329
"path": "dist/assets/temporary/muenchende-style.css",
3430
"label": "CSS distribution"
3531
},
3632
{
37-
"path": "dist/assets/temporary/muenchende-fontface.css",
33+
"path": "dist/assets/temporary/muenchende-fontfaces.css",
3834
"label": "CSS fontface distribution"
3935
},
4036
{

README.md

Lines changed: 9 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -20,45 +20,19 @@ See the [open issues](#) for a full list of proposed features (and known issues)
2020

2121
## Usage
2222

23-
### Installation
24-
25-
```shell
26-
npm i @muenchen/muc-patternlab-vue
27-
```
28-
29-
Required Peer Dependencies:
30-
31-
```
32-
"vue": "^3.4.0"
33-
```
34-
35-
### Use
36-
37-
e.G. Using the MucBanner-Component:
38-
39-
```vue
40-
<script setup>
41-
import { MucBanner } from "@muenchen/muc-patternlab-vue";
42-
</script>
43-
44-
<template>
45-
<muc-banner title="Hello Muc">
46-
<div>How are you?</div>
47-
</muc-banner>
48-
</template>
49-
```
23+
Please refer to the [documentation](docs/guide/index.md).
5024

5125
## Develop
5226

27+
### Setup
28+
5329
```shell
5430
git clone https://github.com/it-at-m/muc-patternlab-vue.git
5531
cd muc-patternlab-vue
5632
npm install
57-
npm run dev
33+
npm run docs:dev
5834
```
5935

60-
## Documentation
61-
6236
### Release and Publish
6337

6438
This project uses [semantic-release](https://github.com/semantic-release/semantic-release)!
@@ -76,8 +50,12 @@ It follows [Angulars Commit Message Conventions](https://github.com/angular/angu
7650
1. Create a new Folder under `./src/components`-Directory
7751
2. Create Vue-Component (with composition api) and index.ts-File which exports your component
7852
3. Add your new Component to `./src/components/index.ts`
53+
4. Create documentation for your component
54+
1. Create at least one "Basic" demo at `./docs/components/demo/<your-component>`
55+
2. Create a doc-File for your component at `./docs/components/<your-component>.md`
56+
3. Add your component doc to the sidebar at `./docs/.vitepress/config.ts`
7957

80-
### Using MDE Patternlab-Icons
58+
### Using MDE5 Patternlab-Icons
8159

8260
Patternlab-Icons are provided by a svg-Sprite which is automatically injected in this repos App.vue-File for local testing. You can expect the users of this library to do the same thing.
8361

docs/.gitkeep

Whitespace-only changes.
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<script setup>
2+
import sprites from "../../../public/assets/temporary/muc-icons.svg?raw"
3+
</script>
4+
5+
<template>
6+
<div>
7+
<svg
8+
style="display: none;"
9+
v-html="sprites">
10+
</svg>
11+
12+
<div class="demo-container">
13+
<slot></slot>
14+
</div>
15+
</div>
16+
</template>

docs/.vitepress/config.ts

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
const path = require('path')
2+
3+
module.exports = {
4+
title: 'My Lib',
5+
description: 'Just playing around.',
6+
themeConfig: {
7+
repo: 'https://github.com/wuruoyun/vue-component-lib-starter',
8+
sidebar: [
9+
{
10+
text: 'Introduction',
11+
children: [
12+
{ text: 'What is My Lib?', link: '/' },
13+
{ text: 'Getting Started', link: '/guide/' },
14+
],
15+
}, {
16+
text: 'Components',
17+
children: [
18+
{ text: 'MucBanner', link: '/components/muc-banner' },
19+
{ text: 'MucButton', link: '/components/muc-button' },
20+
{ text: 'MucIntro', link: '/components/muc-intro' },
21+
],
22+
}
23+
],
24+
},
25+
vite: {
26+
resolve: {
27+
alias: {
28+
'muc-patternlab-vue': path.resolve(__dirname, '../../src'),
29+
},
30+
dedupe: ['vue'], // avoid error when using dependencies that also use Vue
31+
}
32+
}
33+
}

docs/.vitepress/theme/custom.css

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
.demo-container {
2+
border: 1px solid lightgrey;
3+
border-radius: 5px;
4+
padding: 10px 20px;
5+
}

docs/.vitepress/theme/index.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import DefaultTheme from 'vitepress/theme'
2+
import DemoContainer from '../components/DemoContainer.vue'
3+
import MucPatternlabVue from 'muc-patternlab-vue'
4+
5+
import './custom.css'
6+
7+
export default {
8+
...DefaultTheme,
9+
enhanceApp({ app }) {
10+
app.use(MucPatternlabVue)
11+
app.component('DemoContainer', DemoContainer)
12+
}
13+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<template>
2+
<div>
3+
<muc-banner type="warning">
4+
Lorem ipsum dolor sit amet, consetetur sadipscing elitr.
5+
</muc-banner>
6+
7+
<muc-banner type="emergency">
8+
Lorem ipsum dolor sit amet, consetetur sadipscing elitr.
9+
</muc-banner>
10+
11+
<muc-banner type="info">
12+
Lorem ipsum dolor sit amet, consetetur sadipscing elitr.
13+
</muc-banner>
14+
</div>
15+
</template>
16+
<style scoped>
17+
div * {
18+
margin-bottom: 16px;
19+
}
20+
</style>
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<template>
2+
<muc-button>Click me</muc-button>
3+
</template>

0 commit comments

Comments
 (0)