Skip to content

Commit 9bf94e7

Browse files
committed
【修复】优化 HTML 文件生成和部署流程
- 修改包名为 markdown-html-generator - 更新 target-dir 输入描述和默认值 - 重构生成和部署流程,使用预生成的 markdown.html 文件 - 添加版本获取步骤 - 使用 release-downloader action 下载指定版本文件
1 parent 1437713 commit 9bf94e7

3 files changed

Lines changed: 31 additions & 34 deletions

File tree

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[package]
2-
name = "markdown-html"
2+
name = "markdown-html-generator"
33
version = "1.8.0"
44
edition = "2021"
55

action.yml

Lines changed: 29 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ author: 'PJ568'
44

55
inputs:
66
target-dir:
7-
description: Directory to deploy the minimized HTML file
8-
default: "."
7+
description: Relative path under $GITHUB_WORKSPACE to deploy the minimized HTML file
8+
default: ""
99
file-name:
1010
description: Name of the minimized HTML file
1111
default: "index.html"
@@ -19,45 +19,42 @@ inputs:
1919
runs:
2020
using: "composite"
2121
steps:
22-
- name: Setup Rust
23-
uses: MatteoH2O1999/setup-rust@v1
24-
if: ${{ inputs.use-minified == 'true' || inputs.use-all-in-one == 'true' }}
25-
working-directory: ${{ github.action_path }}
2622

27-
- name: Cache Rust dependencies
28-
if: ${{ inputs.use-minified == 'true' || inputs.use-all-in-one == 'true' }}
29-
uses: Swatinem/rust-cache@v2
30-
working-directory:
31-
with:
32-
workspaces: "${{ github.action_path }} -> target"
33-
cache-on-failure: "true"
34-
35-
- name: Build project
36-
if: ${{ inputs.use-minified == 'true' || inputs.use-all-in-one == 'true' }}
37-
run: cargo build --release
38-
shell: bash
39-
working-directory: ${{ github.action_path }}
40-
41-
- name: Generate minimized HTML
42-
if: ${{ inputs.use-minified == 'true' || inputs.use-all-in-one == 'true' }}
43-
run: cargo run --release -- index.html
23+
- name: Get version
24+
id: version-get
25+
run: |
26+
chmod +x ./scripts/get-version.bash
27+
VERSION=$(./scripts/get-version.bash)
28+
echo "version=${VERSION}" >> $GITHUB_OUTPUT
29+
if [ "$VERSION" != "0" ]; then
30+
echo "Version detected: $VERSION"
31+
else
32+
echo "No version detacted"
33+
fi
4434
shell: bash
45-
working-directory: ${{ github.action_path }}
4635

47-
- name: Deploy file
36+
- name: Generate file name
4837
run: |
49-
mkdir -p "${{ inputs.target-dir }}"
50-
USE_MINIFIED=""
5138
USE_ALL_IN_ONE=""
52-
if [ "${{ inputs.use-minified }}" = "true" ]; then
53-
USE_MINIFIED=".min"
54-
fi
39+
USE_MINIFIED=""
5540
if [ "${{ inputs.use-all-in-one }}" = "true" ]; then
5641
USE_ALL_IN_ONE=".allinone"
5742
fi
58-
cp -uv index${USE_ALL_IN_ONE}${USE_MINIFIED}.html "${{ inputs.target-dir }}/${{ inputs.file-name }}"
43+
if [ "${{ inputs.use-minified }}" = "true" ]; then
44+
USE_MINIFIED=".min"
45+
fi
46+
echo "file_name=index${USE_ALL_IN_ONE}${USE_MINIFIED}.html" >> $GITHUB_OUTPUT
5947
shell: bash
60-
working-directory: ${{ github.action_path }}
48+
49+
- name: Deploy pre-generated markdown.html file
50+
uses: robinraju/release-downloader@v1
51+
with:
52+
repository: 'PJ-568/MAKRDOWN.HTML'
53+
tag: ${{ steps.version-get.outputs.version }}
54+
fileName: ${{ steps.file-name.outputs.file_name }}
55+
tarBall: false
56+
zipBall: false
57+
out-file-path: ${{ inputs.target-dir }}
6158

6259
branding:
6360
icon: 'book-open'

index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<!doctype html>
22

33
<html>
4-
<markdown-html version="1.17.3" author="PJ568" repo="https://github.com/PJ-568/markdown.html"
4+
<markdown-html version="1.17.4" author="PJ568" repo="https://github.com/PJ-568/markdown.html"
55
license="CC BY-SA 4.0 International"></markdown-html>
66

77
<head>

0 commit comments

Comments
 (0)