diff --git a/.github/dependabot.yaml b/.github/dependabot.yaml index 195df17..0766c0f 100644 --- a/.github/dependabot.yaml +++ b/.github/dependabot.yaml @@ -3,6 +3,10 @@ version: 2 updates: + - package-ecosystem: cargo + directory: / + schedule: + interval: weekly - package-ecosystem: gitsubmodule directory: / schedule: diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index ae697bd..3ab77f1 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -43,12 +43,11 @@ steps: - name: Checkout uses: actions/checkout@v4 - - name: Install GNU Make - if: runner.os == 'macOS' - # https://formulae.brew.sh/formula/make - run: |- - brew install make - echo "$(brew --prefix)/opt/make/libexec/gnubin" >> ${GITHUB_PATH} + - name: Install GNU Softwares + uses: liblaf/install-action@main + with: + brew: coreutils gnu-sed make + choco: gnuwin32-coreutils.install make sed - name: Install Poetry run: pipx install poetry - id: python @@ -72,7 +71,6 @@ - macos-latest - ubuntu-latest - windows-latest - continue-on-error: true release: name: Create GitHub Release @@ -101,7 +99,7 @@ with: path: artifacts - name: Upload Release Assets - uses: softprops/action-gh-release@v0.1.15 + uses: softprops/action-gh-release@master with: tag_name: ${{ needs.release.outputs.tag-name }} files: artifacts/**/* @@ -125,4 +123,6 @@ - name: Install Dependencies run: poetry install - name: Publish to PyPI - run: poetry publish --username="${{ secrets.PYPI_USERNAME }}" --password="${{ secrets.PYPI_PASSWORD }}" --build + run: poetry publish --build + env: + POETRY_PYPI_TOKEN_PYPI: ${{ secrets.PYPI_TOKEN }} diff --git a/.github/workflows/license.yaml b/.github/workflows/license.yaml index 5c86e4b..bc8f6ed 100644 --- a/.github/workflows/license.yaml +++ b/.github/workflows/license.yaml @@ -9,7 +9,7 @@ jobs: license: - name: Update LICENSE Year + name: LICENSE runs-on: ubuntu-latest steps: - name: Checkout diff --git a/.gitmodules b/.gitmodules deleted file mode 100644 index 9142b79..0000000 --- a/.gitmodules +++ /dev/null @@ -1,3 +0,0 @@ -[submodule "template"] -path = template -url = https://github.com/liblaf/template.git diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index c0871ec..1ae1a95 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,7 +1,8 @@ ci: skip: - - latexindent - - poetry-lock + - cargo-check + - clippy + - fmt - go-build-mod - go-build-repo-mod - go-mod-tidy @@ -10,6 +11,8 @@ - go-test-repo-mod - go-vet-mod - go-vet-repo-mod + - latexindent + - poetry-lock repos: - repo: https://github.com/cheshirekow/cmake-format-precommit @@ -18,11 +21,17 @@ - id: cmake-format - id: cmake-lint - repo: https://github.com/commitizen-tools/commitizen - rev: 3.10.1 + rev: 3.12.0 hooks: - id: commitizen + - repo: https://github.com/doublify/pre-commit-rust + rev: v1.0 + hooks: + - id: cargo-check + - id: clippy + - id: fmt - repo: https://github.com/pre-commit/mirrors-clang-format - rev: v17.0.2 + rev: v17.0.3 hooks: - id: clang-format types_or: @@ -32,6 +41,8 @@ rev: v3.0.3 hooks: - id: prettier + stages: + - pre-commit - repo: https://github.com/pre-commit/pre-commit-hooks rev: v4.5.0 hooks: @@ -58,7 +69,7 @@ - id: name-tests-test - id: trailing-whitespace - repo: https://github.com/psf/black - rev: 23.9.1 + rev: 23.10.0 hooks: - id: black - id: black-jupyter @@ -85,18 +96,18 @@ rev: 1.6.0 hooks: - id: poetry-check - - id: poetry-lock - files: pyproject.toml - id: poetry-export args: - --output=requirements.txt - --without-hashes - --without-urls + - id: poetry-lock + files: pyproject.toml - repo: https://github.com/scop/pre-commit-shfmt rev: v3.7.0-1 hooks: - id: shfmt - files: (.sh|.zsh|.zsh-theme|envrc|zshrc)(.tmpl)?$ + files: (\.sh|\.zsh|\.zsh-theme|envrc|zshrc)(\.tmpl)?$ types: - text args: @@ -106,10 +117,10 @@ - --case-indent - --space-redirects - repo: https://github.com/sirosen/texthooks - rev: 0.5.0 + rev: 0.6.2 hooks: - - id: fix-smartquotes - id: fix-ligatures + - id: fix-smartquotes - id: fix-spaces - id: forbid-bidi-controls - id: macro-expand @@ -118,14 +129,14 @@ hooks: - id: go-build-mod - id: go-build-repo-mod + - id: go-fmt + - id: go-fmt-repo - id: go-mod-tidy - id: go-mod-tidy-repo - id: go-test-mod - id: go-test-repo-mod - id: go-vet-mod - id: go-vet-repo-mod - - id: go-fmt - - id: go-fmt-repo - repo: local hooks: - id: latexindent diff --git a/LICENSE b/LICENSE index af6e552..406e54d 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2022-2023 Qin Li +Copyright (c) 2022-2023 liblaf Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/Makefile b/Makefile index c951ea4..fa06def 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,8 @@ NAME := tld -BUILD := build -DIST := dist +ASSETS := assets +BUILD := build +DIST := dist SYSTEM != python -c 'import platform; print(platform.system().lower())' MACHINE != python -c 'import platform; print(platform.machine().lower())' @@ -16,14 +17,19 @@ all: -include make/*.mk - -clean: demo-clean +clean: + @ $(RM) --recursive --verbose $(ASSETS) @ $(RM) --recursive --verbose $(BUILD) @ $(RM) --recursive --verbose $(DIST) + @ $(RM) --verbose out.gif @ find . -type d -name '__pycache__' -exec $(RM) --recursive --verbose '{}' + @ find . -type f -name '*.spec' -exec $(RM) --verbose '{}' + +demo: $(ASSETS)/demo.png + +demo-deploy: $(ASSETS)/demo.png scripts/deploy-gh-pages.sh + bash scripts/deploy-gh-pages.sh $(ASSETS) assets + dist: $(DIST_TARGET) setup: @@ -34,8 +40,12 @@ # Auxiliary Targets # ##################### +$(ASSETS)/demo.png: demo.tape + @ mkdir --parents --verbose $(@D) + vhs $< + $(DIST_TARGET): main.py - @ mkdir -p -v $(@D) + @ mkdir --parents --verbose $(@D) ifneq ($(SYSTEM), windows) python -m nuitka --standalone --onefile --output-filename=$(@F) --output-dir=$(@D) --remove-output $< else diff --git a/README.md b/README.md index 1a2b20d..ae9938c 100644 --- a/README.md +++ b/README.md @@ -2,9 +2,9 @@ Download everything from Web Learning of Tsinghua University -[![Build Status](https://img.shields.io/github/actions/workflow/status/liblaf/thu-learn-downloader/ci.yaml)](https://github.com/liblaf/thu-learn-downloader/actions/workflows/ci.yaml) -[![Python Version](https://img.shields.io/pypi/pyversions/thu-learn-downloader)](https://pypi.org/project/thu-learn-downloader/) -[![PyPI](https://img.shields.io/pypi/v/thu-learn-downloader)](https://pypi.org/project/thu-learn-downloader/) +[![GitHub Workflow Status (with event)](https://img.shields.io/github/actions/workflow/status/liblaf/thu-learn-downloader/ci.yaml)](https://github.com/liblaf/thu-learn-downloader/actions/workflows/ci.yaml) +[![PyPI - Python Version](https://img.shields.io/pypi/pyversions/thu-learn-downloader)](https://pypi.org/project/thu-learn-downloader/) +[![PyPI - Version](https://img.shields.io/pypi/v/thu-learn-downloader)](https://pypi.org/project/thu-learn-downloader/) ## Demo diff --git a/demo.tape b/demo.tape index a93f51b..8b57be5 100644 --- a/demo.tape +++ b/demo.tape @@ -1,9 +1,10 @@ Set Width 3840 -Set Height 2440 +Set Height 2160 Set FontSize 32 Require tld Type "OPENSSL_CONF=openssl.cnf tld" Enter -Sleep 5s +Sleep 3s +Screenshot assets/demo.png diff --git a/make/demo.mk b/make/demo.mk deleted file mode 100644 index c6d2e4d..0000000 --- a/make/demo.mk +++ /dev/null @@ -1,24 +0,0 @@ -ASSETS := assets -FRAMES := frames -TEMPLATE := template - -demo: $(ASSETS)/demo.png $(TEMPLATE)/scripts/deploy-gh-pages.sh - bash $(TEMPLATE)/scripts/deploy-gh-pages.sh $(= "3.11" and python_version < "3.13" typer==0.9.0 ; python_version >= "3.11" and python_version < "3.13" typing-extensions==4.8.0 ; python_version >= "3.11" and python_version < "3.13" -urllib3==2.0.6 ; python_version >= "3.11" and python_version < "3.13" +urllib3==2.0.7 ; python_version >= "3.11" and python_version < "3.13" diff --git a/scripts/deploy-gh-pages.sh b/scripts/deploy-gh-pages.sh new file mode 100644 index 0000000..e990631 --- /dev/null +++ b/scripts/deploy-gh-pages.sh @@ -0,0 +1,21 @@ +#!/bin/bash +set -o errexit +set -o nounset +set -o pipefail + +local_dir=${1:-$PWD} +branch=${2:-"gh-pages"} +origin=$(git remote get-url origin) + +temp_dir=$(mktemp --directory) +trap "rm --force --recursive $temp_dir" EXIT +cp --archive --no-target-directory $local_dir $temp_dir + +cd $temp_dir +rm --force --recursive "$temp_dir/.git" +git init +git remote add origin $origin +git checkout --orphan $branch +git add --all +git commit --message="ci: deploy to $branch" +git push --force origin $branch diff --git a/template b/template deleted file mode 160000 index ff754f7..0000000 --- a/template +++ /dev/null @@ -1 +0,0 @@ -Subproject commit ff754f708f4edc56b2bd744e3de1208e2fe02db5