Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
190 changes: 190 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,190 @@
on: workflow_dispatch

jobs:
restore-tools:
if: github.ref_name == github.event.repository.default_branch
runs-on: ubuntu-latest
steps:
- id: toolchain
uses: dtolnay/rust-toolchain@stable

# Check if there are caches before. If there is some, the typst-cli
# should be installed.
- id: restore
uses: actions/cache/restore@v4
with:
key: cargo
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/

- name: Install git-cliff
run: cargo install git-cliff || true

- name: Install sd
run: cargo install sd || true

- name: Cache Cargo
uses: actions/cache/save@v4
with:
key: cargo
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/

bump-version:
needs:
- restore-tools
if: github.ref_name == github.event.repository.default_branch
runs-on: ubuntu-latest
outputs:
SEMVER: ${{ steps.semver-tag.outputs.SEMVER }}
steps:
- name: Restore Tools
uses: actions/cache/restore@v4
with:
key: cargo
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/

- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
fetch-tags: true
token: ${{ secrets.THESIS_CI_TOKEN }}
persist-credentials: true

- name: Configure triger user for git
run: |
git config user.name "${{ github.actor }}"
git config user.email "${{ github.actor }}@users.noreply.github.com"

- name: Set bumped version enviornment
id: semver-tag
run: |
BUMPED_VERSION=$(git cliff --bumped-version --unreleased)
echo "BUMPED_VERSION=$BUMPED_VERSION" >> $GITHUB_ENV
SEMVER=$(echo $BUMPED_VERSION | sd 'v(.*)' '$1')
echo "SEMVER=$SEMVER" >> $GITHUB_ENV
echo "SEMVER=$SEMVER" >> $GITHUB_OUTPUT

- name: Generate release note for tagging
run: |
git cliff --bump --unreleased > release-note.md

- name: Bump typst.toml
run: |
sd 'version = ".*"' "version = \"$SEMVER\"" ./typst.toml
git add ./typst.toml

- name: Bump template/thesis.typ
run: |
sd '"@preview/modern-sysu-thesis:.*"' "\"@preview/modern-sysu-thesis:$SEMVER\"" ./template/thesis.typ
git add ./template/thesis.typ

- name: Update & stage CHANGELOG.md
run: |
git cliff --unreleased --tag $BUMPED_VERSION --prepend CHANGELOG.md
git add ./CHANGELOG.md

- run: git status

- name: Tag commit
run: |
git commit -m "chore(release):prepare for $BUMPED_VERSION"
git tag $BUMPED_VERSION --file=release-note.md

- name: push to upstream
run: git push origin

publish2universe:
runs-on: ubuntu-latest
needs:
- bump-version
steps:
- name: Restore Tools
uses: actions/cache/restore@v4
with:
key: cargo
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/

- name: Restore semver-tag
run: |
SEMVER=${{ needs.bump-version.outputs.SEMVER }}
echo "SEMVER=$SEMVER" >> $GITHUB_ENV

- name: Checkout Repository with tagged commit
uses: actions/checkout@v4
with:
fetch-depth: 0
fetch-tags: true
path: better-thesis

- name: Store CI_PROJECT_DIR
run: |
CI_PROJECT_DIR="~/better-thesis"
echo "CI_PROJECT_DIR=$CI_PROJECT_DIR" >> $GITHUB_ENV

- name: Checkout Packages fork
uses: actions/checkout@v4
with:
repository: sysu/packages
fetch-depth: 0
fetch-tags: true
token: ${{ secrets.TYPST_PACKAGES_FORK_TOKEN }}
persist-credentials: true
path: sysu-packages

- name: Configure triger user for git
run: |
git config user.name "${{ github.actor }}"
git config user.email "${{ github.actor }}@users.noreply.github.com"

- name: switch new branch for Packages
run: |
cd ~/sysu-packages/preview/modern-sysu-thesis
git switch main
git switch -c $SEMVER

- name: create new version directory
run: |
mkdir $SEMVER
cd $SEMVER

- name: Copy project files
run: |
cp $CI_PROJECT_DIR/LICENSE .
cp $CI_PROJECT_DIR/README.md .
cp $CI_PROJECT_DIR/typst.toml .
cp $CI_PROJECT_DIR/thumbnail.png .
cp $CI_PROJECT_DIR/lib.typ .
cp -r $CI_PROJECT_DIR/assets .
cp -r $CI_PROJECT_DIR/layouts .
cp -r $CI_PROJECT_DIR/utils .
cp -r $CI_PROJECT_DIR/pages .
cp -r $CI_PROJECT_DIR/specifications .
cp -r $CI_PROJECT_DIR/template .

- name: Switch to preview import
run: |
sd '// #import "@preview/modern-sysu-thesis:' '#import "@preview/modern-sysu-thesis:' ./template/thesis.typ
sd '#import "/lib.typ":' '// #import "lib.typ":' ./template/thesis.typ

- name: Commit to Packages
run: |
git status
git add .
git commit -m "chore(release):prepare for modern-sysu-thesis:$SEMVER"
git push --set-upstream origin $SEMVER
96 changes: 0 additions & 96 deletions .github/workflows/staging.yml

This file was deleted.