Simplify the publishing process.

Renamed the tool script.
This commit is contained in:
Cotes Chung 2020-06-26 18:26:50 +08:00
parent 4491c82b02
commit cc4f18a5a2
5 changed files with 36 additions and 44 deletions

View File

@ -173,27 +173,24 @@ By deploying the site in this way, you're allowed to push the source code direct
|User or Organization | `<username>.github.io`| |User or Organization | `<username>.github.io`|
|Project| Any one except `<username>.github.io`, let's say `project`| |Project| Any one except `<username>.github.io`, let's say `project`|
**2**. Commit the changes of the repo first, then run the initialization script: **2**. Commit the changes of the repo first, then run the publish script:
```terminal ```console
$ bash tools/init.sh $ bash tools/publish.sh
``` ```
>**Note**: The *Recent Update* requires the posts' latest git-log date, so make sure the changes in `_posts` have been committed before running this command. > Please note that the *Recent Update* list requires the latest git-log date of posts, thus make sure the changes in `_posts` have been committed before running this command.
it will automatically generates the *Latest Modified Date* and *Categories / Tags* page for the posts and submit a commit. Its output is similar to the following log: it will automatically generates the *Latest Modified Date* and *Categories / Tags* page for the posts and submit a commit, and then push to `origin/master`. Its output is similar to the following log:
```terminal ```terminal
[INFO] Success to update lastmod for 4 post(s). [INFO] Success to update lastmod for 4 post(s).
[INFO] Succeed! 3 category-pages created. [INFO] Succeed! 3 category-pages created.
[INFO] Succeed! 4 tag-pages created. [INFO] Succeed! 4 tag-pages created.
[Automation] Updated the Categories, Tags, Lastmod for post(s). [INFO] Published successfully!
11 files changed, 46 insertions(+), 3 deletions(-)
...
Updated the Categories, Tags, Lastmod for post(s).
``` ```
**3**. Push the changes to `origin/master` then go to GitHub website and enable GitHub Pages service for the repo. **3**. Go to GitHub website and enable GitHub Pages service for the repo.
**4**. Check it out: **4**. Check it out:

View File

@ -73,7 +73,7 @@ tag: TAG_NAME # e.g. bee
--- ---
``` ```
With the increasing number of posts, the number of categories and tags will increase several times! If we still manually create these *category*/*tag* type files, it will obviously be a super time-consuming job, and it is very likely to miss some of them(i.e. when you click on the missing `category` or `tag` link from a post or somewhere, it will complain to you '404'). The good news is that we got a lovely script tool `_scripts/sh/create_pages.sh` to finish the boring task. Basically we will use it via `tools/init.sh` instead of running it separately. Check out its use case [here]({{ "/posts/getting-started/#option-1-built-by-github-pages" | relative_url }}). With the increasing number of posts, the number of categories and tags will increase several times! If we still manually create these *category*/*tag* type files, it will obviously be a super time-consuming job, and it is very likely to miss some of them(i.e. when you click on the missing `category` or `tag` link from a post or somewhere, it will complain to you '404'). The good news is that we got a lovely script tool `_scripts/sh/create_pages.sh` to finish the boring task. Basically we will use it via `tools/publish.sh` instead of running it separately. Check out its use case [here]({{ "/posts/getting-started/#option-1-built-by-github-pages" | relative_url }}).
## Last modified date ## Last modified date
@ -87,7 +87,7 @@ The last modified date of a post is obtained according to its latest git commit
... ...
``` ```
You can choose to create this file manually, but as you may notice, the better approach is to let it be automatically generated by a tool script. And `_scripts/sh/dump_lastmod.sh` was born for this! Similar to the another script `_scripts/sh/create_pages.sh` mentioned above, it is also be called from `tools/init.sh`, so it doesn't have to be used separately. You can choose to create this file manually, but as you may notice, the better approach is to let it be automatically generated by a tool script. And `_scripts/sh/dump_lastmod.sh` was born for this! Similar to the another script `_scripts/sh/create_pages.sh` mentioned above, it is also be called from `tools/publish.sh`, so it doesn't have to be used separately.
When some posts have been modified since their published date and also the file `_data/updates.yml` was created correctly, a list with the label **Recent Updates** will be displayed in the right panel of the desktop view, which records the five most recently modified articles. When some posts have been modified since their published date and also the file `_data/updates.yml` was created correctly, a list with the label **Recent Updates** will be displayed in the right panel of the desktop view, which records the five most recently modified articles.

View File

@ -138,28 +138,24 @@ By deploying the site in this way, you're allowed to push the source code direct
|User or Organization | `<username>.github.io`| |User or Organization | `<username>.github.io`|
|Project| Any one except `<username>.github.io`, let's say `project`| |Project| Any one except `<username>.github.io`, let's say `project`|
**2**. Commit the changes of the repo first, then run the initialization script: **2**. Commit the changes of the repo first, then run the publish script:
```console ```console
$ bash tools/init.sh $ bash tools/publish.sh
``` ```
> Please note that the *Recent Update* list requires the latest git-log date of posts, thus make sure the changes in `_posts` have been committed before running this command. > Please note that the *Recent Update* list requires the latest git-log date of posts, thus make sure the changes in `_posts` have been committed before running this command.
it will automatically generates the *Latest Modified Date* and *Categories / Tags* page for the posts and submit a commit. Its output is similar to the following log: it will automatically generates the *Latest Modified Date* and *Categories / Tags* page for the posts and submit a commit, and then push to `origin/master`. Its output is similar to the following log:
```terminal ```terminal
[INFO] Success to update lastmod for 4 post(s). [INFO] Success to update lastmod for 4 post(s).
[INFO] Succeed! 3 category-pages created. [INFO] Succeed! 3 category-pages created.
[INFO] Succeed! 4 tag-pages created. [INFO] Succeed! 4 tag-pages created.
[Automation] Updated the Categories, Tags, Lastmod for post(s). [INFO] Published successfully!
11 files changed, 46 insertions(+), 3 deletions(-)
...
Updated the Categories, Tags, Lastmod for post(s).
``` ```
**3**. Go to GitHub website and enable GitHub Pages service for the repo.
**3**. Push the changes to `origin/master` then go to GitHub website and enable GitHub Pages service for the repo.
**4**. Check it out: **4**. Check it out:

View File

@ -177,25 +177,21 @@ $ bash tools/run.sh
**2**. 提交本地更改,然后运行: **2**. 提交本地更改,然后运行:
```console ```console
$ bash tools/init.sh $ bash tools/publish.sh
``` ```
>**注**: *最后更新* 列表根据文章的 git 修改记录生成,所以运行前先把 `_posts` 目录的修改提交。 >**注**: *最后更新* 列表根据文章的 git 修改记录生成,所以运行前先把 `_posts` 目录的修改提交。
它会自动生成文章的 *最后修改日期**分类 / 标签* 页面,并自动提交一个 commit。输出日志类似如下 它会自动生成文章的 *最后修改日期**分类 / 标签* 页面,并自动提交一个 commit 并推送到 `origin/master` 。输出日志类似如下:
```terminal ```terminal
[INFO] Success to update lastmod for 4 post(s). [INFO] Success to update lastmod for 4 post(s).
[INFO] Succeed! 3 category-pages created. [INFO] Succeed! 3 category-pages created.
[INFO] Succeed! 4 tag-pages created. [INFO] Succeed! 4 tag-pages created.
[Automation] Updated the Categories, Tags, Lastmod for post(s). [INFO] Published successfully!
11 files changed, 46 insertions(+), 3 deletions(-)
...
Updated the Categories, Tags, Lastmod for post(s).
``` ```
**3**. 到 GitHub 网页为该项目开启 Pages 服务。
**3**. 推送到 `origin/master` 然后到 GitHub 网页为该项目开启 Pages 服务。
**4**. 网站将运行在: **4**. 网站将运行在:

View File

@ -1,6 +1,7 @@
#!/bin/bash #!/bin/bash
# #
# Initial the Categories/Tags pages and Lastmod for posts. # Initial the Categories/Tags pages and Lastmod for posts and then push to remote
#
# v2.0 # v2.0
# https://github.com/cotes2020/jekyll-theme-chirpy # https://github.com/cotes2020/jekyll-theme-chirpy
# © 2019 Cotes Chung # © 2019 Cotes Chung
@ -15,19 +16,13 @@ LASTMOD=false
WORK_DIR=$(dirname $(dirname $(realpath "$0"))) WORK_DIR=$(dirname $(dirname $(realpath "$0")))
check_status() { check_status() {
local _watching_dirs=( local _change=$(git status . -s)
"_post"
"_data")
for i in "${!_watching_dirs[@]}" if [[ ! -z ${_change} ]]; then
do echo "Warning: Commit the changes of the changes first:"
local _dir=${_watching_dirs[${i}]} echo "$_change"
if [[ ! -z $(git status $_dir -s) ]]; then exit 1
echo "Warning: Commit the changes of the directory '$_dir' first." fi
git status -s | grep $_dir
exit 1
fi
done
} }
@ -72,12 +67,17 @@ commit() {
if [[ $CATEGORIES = true || $TAGS = true || $LASTMOD = true ]]; then if [[ $CATEGORIES = true || $TAGS = true || $LASTMOD = true ]]; then
msg+=" for post(s)." msg+=" for post(s)."
git commit -m "[Automation] $msg" git commit -m "[Automation] $msg" -q
else else
msg="Nothing changed." msg="Nothing changed."
fi fi
echo $msg }
push() {
git push origin master -q
echo "[INFO] Published successfully!"
} }
@ -90,6 +90,9 @@ main() {
update_files update_files
commit commit
push
} }
main main