Skip to content

.github/workflows/release.yml #15

.github/workflows/release.yml

.github/workflows/release.yml #15

Workflow file for this run

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:
# if: github.ref_name == github.event.repository.default_branch
runs-on: ubuntu-latest
needs:
- restore-tools
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:
# if: github.ref_name == github.event.repository.default_branch
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
- name: Store CI_PROJECT_DIR
run: |
CI_PROJECT_DIR="${pwd}"
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-fork
- name: Store MODERN_SYSU_THESIS
run: |
MODERN_SYSU_THESIS="${pwd}/sysu-fork/packages/preview/modern-sysu-thesis"
echo "MODERN_SYSU_THESIS=$MODERN_SYSU_THESIS" >> $GITHUB_ENV
- name: switch new branch for Packages
working-directory: ${{ env.MODERN_SYSU_THESIS }}
run: |
git switch main
git switch -c $SEMVER
- name: create new version directory
working-directory: ${{ env.MODERN_SYSU_THESIS }}
run: |
mkdir $SEMVER
- name: Copy project files
working-directory: ${{ env.MODERN_SYSU_THESIS }}/${{ env.SEMVER }}
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
working-directory: ${{ env.MODERN_SYSU_THESIS }}/${{ env.SEMVER }}
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: Configure triger user for git
working-directory: ${{ env.MODERN_SYSU_THESIS }}
run: |
git config user.name "${{ github.actor }}"
git config user.email "${{ github.actor }}@users.noreply.github.com"
- name: Commit to Packages
working-directory: ${{ env.MODERN_SYSU_THESIS }}
run: |
git status
git add .
git commit -m "chore(release):prepare for modern-sysu-thesis:$SEMVER"
git push --set-upstream origin $SEMVER