Skip to content

Commit

Permalink
Feat/docs (#45)
Browse files Browse the repository at this point in the history
  • Loading branch information
tsotimus authored Mar 21, 2024
1 parent 66219fe commit e51fbdc
Show file tree
Hide file tree
Showing 29 changed files with 21,179 additions and 6,406 deletions.
193 changes: 107 additions & 86 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,86 +1,107 @@
name: "Vite Plugin Release"
on:
push:
branches: [main]

jobs:
build_and_test:
name: "Build and Test"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20
- run: npm ci
- run: npm run build
- name: Archive production artifacts
if: always()
uses: actions/upload-artifact@v4
with:
name: package-dist
retention-days: 30
path: packages/vite-plugin-posthog/dist
- name: Create env file
run: |
cd apps/example-react
touch .env
echo VITE_POSTHOG_KEY=${{secrets.VITE_POSTHOG_KEY}} >> .env
echo VITE_CHECK_FOR_DEV=false >> .env
echo VITE_APP_TITLE=Example >> .env
cd ../..
- name: "Build Vite App"
run: npm run example:build
- name: Install Playwright Browsers
run: npx playwright install --with-deps chromium
- name: Run Playwright tests
run: npx playwright test
- uses: actions/upload-artifact@v4
if: always()
with:
name: playwright-report
path: playwright-report/
retention-days: 30


publish:
runs-on: ubuntu-latest
needs: build_and_test
name: "Publish"
permissions:
contents: write
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20
- run: npm ci
- name: Download production artifacts
uses: actions/download-artifact@v4
with:
name: package-dist
path: packages/vite-plugin-posthog/dist

- uses: JS-DevTools/npm-publish@v3
id: publish
with:
token: ${{ secrets.NPM_AUTH_TOKEN }}
package: packages/vite-plugin-posthog

- name: Bump version and push tag
if: ${{ steps.publish.outputs.type }}
id: tag_version
uses: mathieudutour/github-tag-action@v6.1
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
custom_tag: v${{steps.publish.outputs.version}}
tag_prefix: vite-plugin-posthog_

- name: Create a GitHub release
if: ${{ steps.publish.outputs.type }}
uses: ncipollo/release-action@v1
with:
tag: ${{ steps.tag_version.outputs.new_tag }}
name: ${{ steps.tag_version.outputs.new_tag }}
body: ${{ steps.tag_version.outputs.changelog }}
generateReleaseNotes: true
name: "Vite Plugin Release"
on:
push:
branches: [main]

jobs:
build_and_test:
name: "Build and Test"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20
- run: npm ci
- run: npm run build
- name: Archive production artifacts
if: always()
uses: actions/upload-artifact@v4
with:
name: package-dist
retention-days: 30
path: packages/vite-plugin-posthog/dist
- name: Create env file
run: |
cd apps/example-react
touch .env
echo VITE_POSTHOG_KEY=${{secrets.VITE_POSTHOG_KEY}} >> .env
echo VITE_CHECK_FOR_DEV=false >> .env
echo VITE_APP_TITLE=Example >> .env
cd ../..
- name: "Build Vite App"
run: npm run example:build
- name: Install Playwright Browsers
run: npx playwright install --with-deps chromium
- name: Run Playwright tests
run: npx playwright test
- uses: actions/upload-artifact@v4
if: always()
with:
name: playwright-report
path: playwright-report/
retention-days: 30
- name: Build Documentation Site
run: npm run docs:build
- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
path: ./apps/docs/out


publish:
runs-on: ubuntu-latest
needs: build_and_test
name: "Publish"
permissions:
contents: write
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20
- run: npm ci
- name: Download production artifacts
uses: actions/download-artifact@v4
with:
name: package-dist
path: packages/vite-plugin-posthog/dist

- uses: JS-DevTools/npm-publish@v3
id: publish
with:
token: ${{ secrets.NPM_AUTH_TOKEN }}
package: packages/vite-plugin-posthog

- name: Bump version and push tag
if: ${{ steps.publish.outputs.type }}
id: tag_version
uses: mathieudutour/github-tag-action@v6.1
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
custom_tag: v${{steps.publish.outputs.version}}
tag_prefix: vite-plugin-posthog_

- name: Create a GitHub release
if: ${{ steps.publish.outputs.type }}
uses: ncipollo/release-action@v1
with:
tag: ${{ steps.tag_version.outputs.new_tag }}
name: ${{ steps.tag_version.outputs.new_tag }}
body: ${{ steps.tag_version.outputs.changelog }}
generateReleaseNotes: true

deploy:
runs-on: ubuntu-latest
needs: build_and_test
permissions:
contents: read
pages: write
id-token: write
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
5 changes: 5 additions & 0 deletions apps/docs/next-env.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/// <reference types="next" />
/// <reference types="next/image-types/global" />

// NOTE: This file should not be edited
// see https://nextjs.org/docs/basic-features/typescript for more information.
26 changes: 26 additions & 0 deletions apps/docs/next-sitemap.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/** @type {import('next-sitemap').IConfig} */
module.exports = {
siteUrl: "https://vite-posthog.tsotne.co.uk",
generateRobotsTxt: true, // (optional)
generateIndexSitemap: false,
sitemapSize: 100,
output: "export",
additionalPaths: async () => [
{
loc: "/",
priority: "1.0",
},
{
loc: "/getting-started",
priority: 0.9,
},
{
loc: "/react/core",
priority: 0.6,
},
{
loc: "/react/feature-flags",
priority: 0.6,
},
],
};
17 changes: 17 additions & 0 deletions apps/docs/next.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/** @type {import('next').NextConfig} */

const withNextra = require("nextra")({
theme: "nextra-theme-docs",
themeConfig: "./theme.config.jsx",
});

module.exports = withNextra({
reactStrictMode: true,
output: "export",
images: {
unoptimized: true,
},
});

// If you have other Next.js configurations, you can pass them as the parameter:
// module.exports = withNextra({ /* other next.js config */ })
29 changes: 29 additions & 0 deletions apps/docs/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"name": "docs",
"version": "0.1.0",
"private": true,
"scripts": {
"dev": "next dev",
"build": "next build",
"postbuild": "next-sitemap",
"preview": "npx serve out -p 3000",
"lint": "next lint"
},
"dependencies": {
"copy-to-clipboard": "^3.3.3",
"framer-motion": "^11.0.5",
"next": "latest",
"next-sitemap": "^4.2.3",
"nextra": "^2.13.3",
"nextra-theme-docs": "^2.13.3",
"react": "latest",
"react-dom": "latest"
},
"devDependencies": {
"@types/node": "latest",
"@types/react": "latest",
"eslint": "latest",
"eslint-config-next": "latest",
"typescript": "latest"
}
}
17 changes: 17 additions & 0 deletions apps/docs/pages/_document.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { Html, Head, Main, NextScript } from "next/document";

export default function MyDocument() {
return (
<Html lang="en">
<Head>
{/* PWA primary color */}
<link rel="shortcut icon" href="/vite_logo.svg" />
<meta name="emotion-insertion-point" content="" />
</Head>
<body>
<Main />
<NextScript />
</body>
</Html>
);
}
19 changes: 19 additions & 0 deletions apps/docs/pages/_meta.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"index": {
"title": "Home",
"href": "/"
},
"getting-started": {
"title": "Getting Started",
"href": "/getting-started"

},
"-- SDK": {
"type": "separator",
"title": "SDKs"
},
"react": {
"title": "React",
"href": "/react"
}
}
Loading

0 comments on commit e51fbdc

Please sign in to comment.