Skip to content

Commit

Permalink
Merge pull request #65 from DeveloperPaul123/feature/project-infastru…
Browse files Browse the repository at this point in the history
…cture-updates
  • Loading branch information
DeveloperPaul123 authored Sep 19, 2024
2 parents c3d1ecc + 73f0e7b commit 230b5e7
Show file tree
Hide file tree
Showing 17 changed files with 435 additions and 46 deletions.
23 changes: 0 additions & 23 deletions .github/workflows/build-documentation.yml

This file was deleted.

77 changes: 77 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
name: Package and push to registry repo
on:
push:
tags: [ '*' ]

env:
# the repository to which to push the release version
# usually a fork of typst/packages (https://github.com/typst/packages/)
# that you have push privileges to
REGISTRY_REPO: DeveloperPaul123/typst-packages
# the path within that repo where the "<name>/<version>" directory should be put
# for the Typst package registry, keep this as is
PATH_PREFIX: packages/preview

jobs:
release:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Probe runner package cache
uses: awalsh128/cache-apt-pkgs-action@v1
with:
packages: cargo
version: 1.0

- name: Install just from crates.io
uses: baptiste0928/cargo-install@v3
with:
crate: just

- name: Setup typst
uses: typst-community/setup-typst@v3
with:
typst-version: latest

- name: Determine and check package metadata
run: |
. scripts/setup
echo "PKG_NAME=${PKG_PREFIX}" >> "${GITHUB_ENV}"
echo "PKG_VERSION=${VERSION}" >> "${GITHUB_ENV}"
if [[ "${GITHUB_REF_NAME}" != "v${VERSION}" ]]; then
echo "package version ${VERSION} does not match release tag ${GITHUB_REF_NAME}" >&2
exit 1
fi
- name: Build package
run: |
just doc
just package out
- name: Checkout package registry
uses: actions/checkout@v4
with:
repository: ${{ env.REGISTRY_REPO }}
token: ${{ secrets.REGISTRY_TOKEN }}
path: typst-packages

- name: Release package
run: |
mkdir -p "typst-packages/${{ env.PATH_PREFIX }}/$PKG_NAME"
mv "out/${PKG_NAME}/${PKG_VERSION}" "typst-packages/${{ env.PATH_PREFIX }}/${PKG_NAME}"
rmdir "out/${PKG_NAME}"
rmdir out
GIT_USER_NAME="$(git log -1 --pretty=format:'%an')"
GIT_USER_EMAIL="$(git log -1 --pretty=format:'%ae')"
cd typst-packages
git config user.name "${GIT_USER_NAME}"
git config user.email "${GIT_USER_EMAIL}"
git checkout -b "${PKG_NAME}-${PKG_VERSION}"
git add .
git commit -m "${PKG_NAME}:${PKG_VERSION}"
git push --set-upstream origin "${PKG_NAME}-${PKG_VERSION}"
83 changes: 83 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
name: Tests
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]

jobs:
tests:
strategy:
matrix:
# add any other Typst versions that your package should support
typst-version: ["0.11"]
# the docs don't need to build with all versions supported by the package;
# the latest one is enough
include:
- typst-version: "0.11"
doc: 1
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Probe runner package cache
uses: awalsh128/cache-apt-pkgs-action@v1
with:
packages: imagemagick cargo
version: 1.0

- name: Install oxipng from crates.io
uses: baptiste0928/cargo-install@v3
with:
crate: oxipng

- name: Install just from crates.io
uses: baptiste0928/cargo-install@v3
with:
crate: just

- name: Install typst-test from github
uses: baptiste0928/cargo-install@v3
with:
crate: typst-test
git: https://github.com/tingerrr/typst-test.git
tag: ci-semi-stable

- name: Setup typst
uses: typst-community/setup-typst@v3
with:
typst-version: ${{ matrix.typst-version }}

- name: Install fonts
run: |
sudo apt update
sudo apt-get install fonts-font-awesome fonts-roboto
./scripts/install-fontawesome
- name: Install locally
run: just install

- name: Run test suite
run: just test

- name: Archive diffs
uses: actions/upload-artifact@v4
if: always()
with:
name: diffs
path: |
tests/**/diff/*.png
tests/**/out/*.png
tests/**/ref/*.png
retention-days: 5

- name: Build docs
if: ${{ matrix.doc }}
run: just doc

- name: Upload docs
uses: actions/upload-artifact@v4
with:
name: manual
path: docs/manual.pdf
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
*.pdf
*.pdf
tests/*/diff
tests/*/out
3 changes: 2 additions & 1 deletion .typstignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ scripts
template/*.pdf
.gitignore
.issuetracker
modern-cv-docs.*
tests/*
docs/*
45 changes: 45 additions & 0 deletions Justfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
root := justfile_directory()

export TYPST_ROOT := root

[private]
default:
@just --list --unsorted

# generate manual
doc:
typst compile docs/manual.typ docs/manual.pdf

# run test suite
test *args:
typst-test run {{ args }}

# update test cases
update *args:
typst-test update {{ args }}

# package the library into the specified destination folder
package target:
./scripts/package "{{target}}"

# install the library with the "@local" prefix
install: (package "@local")

# install the library with the "@preview" prefix (for pre-release testing)
install-preview: (package "@preview")

[private]
remove target:
./scripts/uninstall "{{target}}"

# uninstalls the library from the "@local" prefix
uninstall: (remove "@local")

# uninstalls the library from the "@preview" prefix (for pre-release testing)
uninstall-preview: (remove "@preview")

format:
./scripts/format

# run ci suite
ci: test doc
19 changes: 16 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,17 @@ A port of the [Awesome-CV](https://github.com/posquit0/Awesome-CV) Latex resume

## Requirements

### Tools

The following tools are used for the development of this template:

- [typst](https://github.com/typst/typst), obviously
- [typst-test](https://github.com/tingerrr/typst-test) for running tests
- [just](https://github.com/casey/just) for simplifying command running
- [oxipng](https://github.com/shssoichiro/oxipng) for compressing thumbnails used in the README

### Fonts

You will need the `Roboto` and `Source Sans Pro` fonts installed on your system or available somewhere. If you are using the `typst` web app, no further action is necessary. You can download them from the following links:

- [Roboto](https://fonts.google.com/specimen/Roboto)
Expand Down Expand Up @@ -83,17 +94,19 @@ Documentation for this template is published with each commit. See the attached

To build and test the project locally, you will need to install the `typst` CLI. You can find instructions on how to do this [here](https://typst.app/docs/getting-started).

With typst installed you can make changes to `lib.typ` and then `install_package_locally.ps1` to install the package locally. Change the import statements in the template files to point to the local package:
With typst installed you can make changes to `lib.typ` and then `just install` or `just install-preview` to install the package locally. Change the import statements in the template files to point to the local package (if needed):

```typst
#import "@local/modern-cv:0.3.0": *
#import "@local/modern-cv:0.6.0": *
````
If you use `just install-preview` you will only need to update the version number to match `typst.toml`.
Note that the script parses the `typst.toml` to determine the version number and the folder the local files are installed to.
### Formatting
This project uses [typstyle](https://github.com/Enter-tainer/typstyle) to format the code. The script `format_typst.ps1` will format all the `*.typ` files in the project. Be sure to install `typstyle` before running the script.
This project uses [typstyle](https://github.com/Enter-tainer/typstyle) to format the code. Run `just format` to format all the `*.typ` files in the project. Be sure to install `typstyle` before running the script.
## License
Expand Down
4 changes: 2 additions & 2 deletions modern-cv-docs.typ → docs/manual.typ
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#import "lib.typ"
#import "../lib.typ"
#import "@preview/tidy:0.3.0"

#let docs = tidy.parse-module(
read("lib.typ"),
read("../lib.typ"),
name: "Modern CV",
scope: (resume: lib),
)
Expand Down
2 changes: 1 addition & 1 deletion lib.typ
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#import "@preview/fontawesome:0.2.1": *
#import "@preview/fontawesome:0.4.0": *
#import "@preview/linguify:0.4.0": *

// const color
Expand Down
4 changes: 4 additions & 0 deletions scripts/format
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env bash
set -eu

find . -iname "*.typ" | xargs typstyle -i
5 changes: 0 additions & 5 deletions scripts/format_typst.ps1

This file was deleted.

11 changes: 11 additions & 0 deletions scripts/install-fontawesome
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/usr/bin/env bash
set -eu

wget -O ~/fontawesome.zip https://use.fontawesome.com/releases/v6.6.0/fontawesome-free-6.6.0-desktop.zip
mkdir -p ~/fontawesome-fonts
unzip ~/fontawesome.zip -d ~/fontawesome-fonts
mkdir -p ~/.fonts
find ~/fontawesome-fonts -type f -name "*.otf" -exec cp {} ~/.fonts \;
rm ~/fontawesome.zip
rm -rf ~/fontawesome-fonts
fc-cache -f -v
10 changes: 0 additions & 10 deletions scripts/install_package_locally.ps1

This file was deleted.

Binary file added tests/resume/ref/1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 230b5e7

Please sign in to comment.