diff --git a/.github/renovate.json5 b/.github/renovate.json5 index de116a4..20a193c 100644 --- a/.github/renovate.json5 +++ b/.github/renovate.json5 @@ -22,6 +22,19 @@ "packageNameTemplate": "rust-lang/rust", "datasourceTemplate": "github-releases" }, + { + "customType": "regex", + "fileMatch": ["^Justfile$"], + "matchStrings": [ + // https://regex101.com/r/vOmY6R/1 + // Matching on word boundaries (\b) around start and end ensures we + // match variations like "towncrier==1.2.3" as well as "pipx run + // towncrier==1.2.3", adding some future proofness. + "\".*\\btowncrier==(?.+?)\\b\"" + ], + "depNameTemplate": "towncrier", + "datasourceTemplate": "pypi" + }, ], packageRules: [ { diff --git a/.github/workflows/publish-crate.yml b/.github/workflows/publish-crate.yml index fa2fb25..daeba47 100644 --- a/.github/workflows/publish-crate.yml +++ b/.github/workflows/publish-crate.yml @@ -15,5 +15,5 @@ jobs: CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }} steps: - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4 - - uses: dtolnay/rust-toolchain@stable + - uses: ./.github/actions/setup-ci - run: cargo publish diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 6b63919..9064c15 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -30,8 +30,3 @@ repos: language: system files: \.rs$ pass_filenames: false - - id: README - name: Render README.md - entry: docs/generate.sh - language: script - files: ^(README\.md)|(docs/.*) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0ab9871..0338810 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,7 @@ # Changelog + + ## v23.12.0 (2023-12-03) ### New diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 3c68cd0..55ccb32 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -74,4 +74,9 @@ If you don't feel comfortable writing user documentation, I will be happy to gui > **⚠ Warning** > -> If you update the README file, take note that you must edit the fragments in the [docs](docs/) directory as opposed to the README in the root of the repository, which is auto-generated. +> If you update the README file, take note that you must edit the fragments in the [docs](docs/) directory as opposed to the README in the root of the repository, which is auto-generated with every release. + +## Release notes + +[Towncrier](https://towncrier.readthedocs.io/en/stable/index.html) is used to generate release notes. +If you add a changelog fragment to the `changelog.d` directory with `just add-changelog` (requires [just](https://github.com/casey/just#installation)) it will automatically be picked up when a new release is made. diff --git a/Justfile b/Justfile new file mode 100644 index 0000000..14d11ee --- /dev/null +++ b/Justfile @@ -0,0 +1,67 @@ +towncrier_cmd := "pipx run towncrier==24.7.0" + +_default: + @{{just_executable()}} --choose + +# Add a new changelog entry using towncrier +add-changelog: + {{towncrier_cmd}} create --edit + git add changelog.d + +# Create a new release +make-new-release: + #!/usr/bin/env bash + set -euo pipefail + + get_next_version_number() { + DATEPART=$(date +%y.%-m) + ITERATION=0 + + while true; do + VERSION_STRING="${DATEPART}.${ITERATION}" + if git rev-list "v$VERSION_STRING" > /dev/null 2>&1; then + ((ITERATION++)) + else + echo "$VERSION_STRING" + return + fi + done + } + + git add . + if ! git diff-index --quiet HEAD; then + printf "Working directory is not clean. Please commit or stash your changes.\n" + exit 1 + fi + + VERSION=$(get_next_version_number) + COMMITMSG=$(mktemp --tmpdir commitmsg.XXXXXXXXXX) + trap 'rm "$COMMITMSG"' EXIT + set -x + + cargo set-version "${VERSION}" + + # Construct a git commit message. + # This must be done before the next step so we can leverage the --draft + # flag here to get a list of changes being introduced by this release. + printf "Release v${VERSION}\n\n" > "$COMMITMSG" + {{towncrier_cmd}} build --draft --version "${VERSION}" >> "$COMMITMSG" + + # Generate changelog and docs + {{towncrier_cmd}} build --version "${VERSION}" + docs/generate.sh + + # Stage all the changes we've prepared + git add . + # There are likely trailing whitespace changes in the changelog, but a single + # run of pre-commit will fix these automatically. + pre-commit run || git add . + + git commit --file "$COMMITMSG" + git tag "v${VERSION}" + + set +x + printf "\n\nSuccessfully created release %s\n" "v${VERSION}" + printf "\nYou'll probably want to continue with:\n" + printf "\tgit push origin main\n" + printf "\tgit push origin %s\n" "v${VERSION}" diff --git a/changelog.d/+52650337.change.md b/changelog.d/+52650337.change.md new file mode 100644 index 0000000..2d0947d --- /dev/null +++ b/changelog.d/+52650337.change.md @@ -0,0 +1,4 @@ +Bump to the minimum supported Rust version to 1.80.0 + +Obsidian-export now uses [std::sync::LazyLock](https://doc.rust-lang.org/std/sync/struct.LazyLock.html) instead of [lazy_static](https://crates.io/crates/lazy_static), which was only stabilized in Rust 1.80.0. +This change made it possible to drop the external dependency on lazy_static, though as a result of this, compiling with older versions will no longer be possible. diff --git a/changelog.d/.gitignore b/changelog.d/.gitignore new file mode 100644 index 0000000..e69de29 diff --git a/changelog.d/154.new.md b/changelog.d/154.new.md new file mode 120000 index 0000000..2c8e796 --- /dev/null +++ b/changelog.d/154.new.md @@ -0,0 +1 @@ +204.new.md \ No newline at end of file diff --git a/changelog.d/204.new.md b/changelog.d/204.new.md new file mode 100644 index 0000000..1babc43 --- /dev/null +++ b/changelog.d/204.new.md @@ -0,0 +1,5 @@ +Optionally preserve modified time of exported files + +Add a new argument `--preserve-mtime` to keep the original modified time attribute of notes being exported, instead of setting them to the current time. + +Contribution made by [Davis Davalos-DeLosh](https://github.com/Programmerino). diff --git a/changelog.d/template.md b/changelog.d/template.md new file mode 100644 index 0000000..b0ae807 --- /dev/null +++ b/changelog.d/template.md @@ -0,0 +1,50 @@ +{% if render_title %} +## v{{ versiondata.version }} ({{ versiondata.date }}) +{% endif %} +{% for section, _ in sections.items() %} +{% if section %} + +## {{section}} +{% endif %} + +{% if sections[section] %} +{% for category, val in definitions.items() if category in sections[section] %} +### {{ definitions[category]['name'] }} + +{% for text, values in sections[section][category].items() %} +- {{ text }} +{%- if values %} +{% if "\n - " in text or '\n * ' in text %} + + + ( +{%- else %} +{% if text %} ({% endif %} +{%- endif -%} +{%- for issue in values %} +{{ issue.split(": ", 1)[0] }}{% if not loop.last %}, {% endif %} +{%- endfor %} +{% if text %}){% endif %} + +{% else %} + +{% endif %} +{% endfor %} + +{% if issues_by_category[section][category] and "]: " in issues_by_category[section][category][0] %} +{% for issue in issues_by_category[section][category] %} +{{ issue }} +{% endfor %} + +{% endif %} +{% if sections[section][category]|length == 0 %} +No significant changes. + +{% else %} +{% endif %} +{% endfor %} +{% else %} +No significant changes. + +{% endif %} +{% endfor +%} diff --git a/docs/Release-checklist.md b/docs/Release-checklist.md index c82f362..4f7f51c 100644 --- a/docs/Release-checklist.md +++ b/docs/Release-checklist.md @@ -1,5 +1,5 @@ # Release process -- [ ] Run `./make-new-release.sh` +- [ ] Run `just make-new-release` - [ ] Push the created release commit/tag to GitHub - [ ] Wait for builds to turn green () and confirm everything looks OK. diff --git a/make-new-release.sh b/make-new-release.sh deleted file mode 100755 index 103c926..0000000 --- a/make-new-release.sh +++ /dev/null @@ -1,47 +0,0 @@ -#!/usr/bin/env bash - -set -euo pipefail - -get_next_version_number() { - DATEPART=$(date +%y.%-m) - ITERATION=0 - - while true; do - VERSION_STRING="${DATEPART}.${ITERATION}" - if git rev-list "v$VERSION_STRING" > /dev/null 2>&1; then - ((ITERATION++)) - else - echo "$VERSION_STRING" - return - fi - done -} - -git add . -if ! git diff-index --quiet HEAD; then - printf "Working directory is not clean. Please commit or stash your changes.\n" - exit 1 -fi - -VERSION=$(get_next_version_number) -git tag "v${VERSION}" - -git cliff --latest --prepend CHANGELOG.md > /dev/null -${EDITOR:-vim} CHANGELOG.md -docs/generate.sh - -sed -i -E "s/^version = \".+\"$/version = \"${VERSION}\"/" Cargo.toml -cargo check - -git add . -# There are likely trailing whitespace changes in the changelog, but a single -# run of pre-commit will fix these automatically. -pre-commit run || git add . - -git commit --message "Release v${VERSION}" -git tag "v${VERSION}" --force - -printf "\n\nSuccessfully created release %s\n" "v${VERSION}" -printf "\nYou'll probably want to continue with:\n" -printf "\tgit push origin main\n" -printf "\tgit push origin %s\n" "v${VERSION}" diff --git a/towncrier.toml b/towncrier.toml new file mode 100644 index 0000000..e136960 --- /dev/null +++ b/towncrier.toml @@ -0,0 +1,34 @@ +[tool.towncrier] +name = "obsidian-export" +directory = "changelog.d" +template = "changelog.d/template.md" +filename = "CHANGELOG.md" +start_string = "\n" +underlines = ["", "", ""] +title_format = "" +issue_format = "[#{issue}](https://github.com/zoni/obsidian-export/issues/{issue})" + +[[tool.towncrier.type]] +directory = "new" +name = "New Features" +showcontent = true + +[[tool.towncrier.type]] +directory = "change" +name = "Changes" +showcontent = true + +[[tool.towncrier.type]] +directory = "fix" +name = "Fixes" +showcontent = true + +[[tool.towncrier.type]] +directory = "breaking" +name = "Backwards-incompatible Changes" +showcontent = true + +[[tool.towncrier.type]] +directory = "deprecation" +name = "Deprecations" +showcontent = true