Skip to content

Commit

Permalink
Merge branch 'ci-refactor-build-flow' into 'main'
Browse files Browse the repository at this point in the history
ci: fix github build.yml and add .gitlab/ci.yml

See merge request sysu-gitlab/thesis-template/better-thesis!2
  • Loading branch information
huangjj27 committed May 16, 2024
2 parents 364d854 + 7928bb2 commit 931b7b7
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 46 deletions.
42 changes: 2 additions & 40 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,7 @@ name: Publish preview PDF
on:
push:
branches:
- master
workflow_dispatch:
schedule:
- cron: '3 0,6,12,18 * * *'
- main

# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
permissions:
Expand All @@ -23,7 +20,7 @@ jobs:
name: Build preview PDF
runs-on: ubuntu-latest
steps:
- name: Checkout master
- name: Checkout main
uses: actions/checkout@v3
with:
fetch-depth: 0
Expand Down Expand Up @@ -51,38 +48,3 @@ jobs:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v1
deploy-gitee:
name: Deploy to Gitee Pages
needs: build
runs-on: ubuntu-latest
environment:
name: gitee-pages
url: https://howardlau.gitee.io/sysu-thesis-typst/thesis.pdf
steps:
- name: Download artifact
uses: actions/download-artifact@v3
with:
name: github-pages
- name: Extract artifact
run: |
mkdir -p $RUNNER_TEMP/gitee_pages
tar -C $RUNNER_TEMP/gitee_pages -xf artifact.tar
- name: Deploy to Gitee Pages
env:
GITEE_RSA_PRIVATE_KEY: ${{ secrets.GITEE_RSA_PRIVATE_KEY }}
run: |
mkdir -p ~/.ssh
echo "$GITEE_RSA_PRIVATE_KEY" > ~/.ssh/id_rsa
chmod 600 ~/.ssh/id_rsa
git config --global user.name "Howard Lau"
git config --global user.email "howardlau1999@hotmail.com"
cd $RUNNER_TEMP/gitee_pages
git init
git checkout -b gh-pages
echo "<html><head><meta http-equiv=\"refresh\" content=\"0; url=thesis.pdf\" /></head></html>" > index.html
git add .
git commit -m "Deploy to Gitee Pages"
export GIT_SSH_COMMAND="ssh -v -i ~/.ssh/id_rsa -o StrictHostKeyChecking=no"
git push --force --quiet git@gitee.com:howardlau/sysu-thesis-typst.git gh-pages
38 changes: 38 additions & 0 deletions .gitlab/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
image: rust
variables:
CARGO_HOME: $CI_PROJECT_DIR/cargo

cache:
paths:
- $CARGO_HOME

stages:
- check
- release

before_script:
- export PATH="$PATH:$CARGO_HOME/bin"
- cargo install typst-cli git-cliff

build:
stage: check
script:
- typst compile --root=$CI_PROJECT_DIR --font-path=$CI_PROJECT_DIR/fonts $CI_PROJECT_DIR/template/thesis.typ
rules:
- if: $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == $CI_DEFAULT_BRANCH
- if: $CI_PIPELINE_SOURCE == "web"

gitlab-release:
stage: release
image: registry.gitlab.com/gitlab-org/release-cli:latest
script:
- mkdir prview && typst compile --root=. --font-path=fonts template/thesis.typ prview/thesis.pdf
dependencies:
- build
rules:
- if: '$CI_COMMIT_TAG'
when: never
- if: $CI_COMMIT_REF_NAME == $CI_DEFAULT_BRANCH
release:
tag_name: '$CI_COMMIT_TAG'
description: '$CI_COMMIT_TAG'
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
# 基于 Typst 的中山大学学位论文模板
[![GitLab 仓库](https://img.shields.io/badge/gitlab-%23181717.svg?style=for-the-badge&logo=gitlab&logoColor=white)](https://gitlab.com/sysu-gitlab/thesis-template/better-thesis)
[![GitHub 仓库](https://img.shields.io/badge/gitlab-%23181717.svg?style=for-the-badge&logo=gitlab&logoColor=white)](https://github.com/sysu/better-thesis)
[![GitLab 仓库](https://gitlab.com/sysu-gitlab/thesis-template/better-thesis/-/badges/release.svg?style=flat-square)](https://gitlab.com/sysu-gitlab/thesis-template/better-thesis) [![GitHub stars](https://img.shields.io/github/stars/sysu/better-thesis.svg?style=social&label=Star&maxAge=2592000)](https://github.com/sysu/better-thesis)

当前还未完全符合学位论文格式要求,欢迎同学们贡献代码!模板交流 QQ 群:797942860([点此直接加入](https://jq.qq.com/?_wv=1027&k=m58va1kd)
当前还未完全符合学位论文格式要求,欢迎同学/校友们[贡献代码](https://gitlab.com/sysu-gitlab/thesis-template/better-thesis/-/merge_requests/new)/反馈问题([GitLab issue](https://gitlab.com/sysu-gitlab/thesis-template/better-thesis/-/issues/new)/[邮件](mailto:contact-project+sysu-gitlab-thesis-template-better-thesis-57823416-issue-@incoming.gitlab.com)!模板交流 QQ 群:[797942860](https://jq.qq.com/?_wv=1027&k=m58va1kd)

**Q:我不会 LaTeX,可以用这个模板写论文吗?**

Expand All @@ -13,17 +12,18 @@
**由于 Typst 还处于初期的快速开发阶段,本项目需要使用从源码编译的 Typst 版本才能正常生成 PDF。仓库提供了一键安装脚本,按照使用说明运行即可。**

<!-- TODO: 提供 typst.universe 版本 -->
<!-- TODO: 在 typst.universe 版本上线后分离模板项目 -->

### Windows 用户

1. [下载本仓库](https://github.com/howardlau1999/sysu-thesis-typst/archive/refs/heads/master.zip),或者使用 `git clone https://github.com/howardlau1999/sysu-thesis-typst` 命令克隆本仓库。
1. [下载本仓库](https://gitlab.com/sysu-gitlab/thesis-template/better-thesis/-/archive/main/better-thesis-main.zip),或者使用 `git clone https://gitlab.com/sysu-gitlab/thesis-template/better-thesis` 命令克隆本仓库。
2. 右键 `install_typst.ps1` 文件,选择“用 Powershell 运行”,等待 Typst 安装完成。
3. 根据 [Typst 文档](https://typst.app/docs/),参考 [项目结构](#项目结构) 中的说明,按照你的需要修改论文的各个部分。
4. 双击运行 `compile.bat`,即可生成 `thesis.pdf` 文件。

### Linux/macOS 用户

1. [下载本仓库](https://github.com/howardlau1999/sysu-thesis-typst/archive/refs/heads/master.zip),或者使用 `git clone https://github.com/howardlau1999/sysu-thesis-typst` 命令克隆本仓库。
1. [下载本仓库](https://gitlab.com/sysu-gitlab/thesis-template/better-thesis/-/archive/main/better-thesis-main.zip),或者使用 `git clone https://gitlab.com/sysu-gitlab/thesis-template/better-thesis` 命令克隆本仓库。
2. 使用命令行安装 Rust 工具链以及 Typst:

```bash
Expand All @@ -32,7 +32,7 @@ curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
source $HOME/.cargo/env

# 安装 Typst CLI
cargo install --git https://github.com/typst/typst.git typst-cli
cargo install typst-cli

# 访问缓慢的话,执行以下命令设置清华镜像源,并从镜像站安装
cat << EOF > $HOME/.cargo/config
Expand Down

0 comments on commit 931b7b7

Please sign in to comment.