Skip to content

Commit

Permalink
deploy: typora build and release
Browse files Browse the repository at this point in the history
Change-Id: I49f17aa25c76fd20f64e5b6ce9b41eff1281a0c9
  • Loading branch information
elonz committed Jun 22, 2021
1 parent a4d931a commit a003029
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 15 deletions.
7 changes: 6 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,19 @@ jobs:
run: |
npm install
npm run compile
npm run compile -- --platform typora --distDir dist/typora-themes
- name: Pack
run: |
cd dist/themes
zip -r mweb-themes.zip ./
cd ../typora-themes
zip -r typora-themes.zip ./
- name: Release
uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/') # 先执行 git tag -a {tag} 再执行 git push origin {tag} 以触发更新
with:
files: dist/themes/mweb-themes.zip
files: |
dist/themes/mweb-themes.zip
dist/typora-themes/typora-themes.zip
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
19 changes: 7 additions & 12 deletions scripts/compile.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,13 @@ const args = minimist(process.argv.slice(2), {

const platformConfig = {
mweb: {
filter: (filename) => /^mweb-/.test(filename),
namer: (filename) => `${path.parse(filename).name}.css`,
postcss: (css) => setContainerSelector({ css, selector: ".markdown-body" }),
},
juejin: {
namer: (filename) =>
`${path.parse(filename).name.replace(/^mweb/, "juejin")}.css`, // 替换 mweb- 前缀为 juejin-
},
typora: {
namer: (filename) =>
`${path.parse(filename).name.replace(/^mweb/, "typora")}.css`, // 替换 mweb- 前缀为 typora-
postcss: async (css) =>
wrapSelector({
css: await setContainerSelector({ css, selector: "#write" }),
prefix: "#write",
}),
filter: (filename) => /^typora-/.test(filename),
namer: (filename) => `${path.parse(filename).name}.css`,
postcss: async (css) => wrapSelector({ css, prefix: "#write" }),
},
};

Expand Down Expand Up @@ -65,11 +57,14 @@ const writeFile = ({ filePath, css }) => {

fs.removeSync(args.distDir);

const cfg = platformConfig[args.platform];

const files = args.file
? [args.file]
: fs
.readdirSync(args.themeDir)
.filter((filename) => filename.match(/\.scss/))
.filter(cfg.filter)
.map((file) => `${args.themeDir}/${file}`);

files.forEach(async (filePath) => {
Expand Down
8 changes: 6 additions & 2 deletions src/views/typora.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,17 @@
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title>Typora</title>
<link rel="stylesheet" href="typora/font-awesome.min.css">
<link rel="stylesheet" href="typora/bootstrap.css">
<link rel="stylesheet" href="typora/codemirror.css">
<link rel="stylesheet" href="typora/base.css">
<link rel="stylesheet" href="typora/base-control.css">

<link rel="stylesheet" href="typora.css">
<script src="/socket.io/socket.io.js"></script>
<script defer>
io('ws://localhost:3000').on('reload', () => {
window.location.reload();
});
</script>
</head>

<body>
Expand Down

0 comments on commit a003029

Please sign in to comment.