forked from hwittenborn/celeste
-
Notifications
You must be signed in to change notification settings - Fork 0
/
justfile
129 lines (104 loc) · 5.52 KB
/
justfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
set positional-arguments
build:
cargo build --release
install:
install -Dm 755 target/release/celeste "{{ env_var('DESTDIR') }}/usr/bin/celeste"
install -Dm 644 assets/com.hunterwittenborn.Celeste.desktop "{{ env_var('DESTDIR') }}/usr/share/applications/com.hunterwittenborn.Celeste.desktop"
install -Dm 644 assets/com.hunterwittenborn.Celeste-regular.svg "{{ env_var('DESTDIR') }}/usr/share/icons/hicolor/scalable/apps/com.hunterwittenborn.Celeste.svg"
install -Dm 644 assets/context/com.hunterwittenborn.Celeste.CelesteTrayLoading-symbolic.svg "{{ env_var('DESTDIR') }}/usr/share/icons/hicolor/symbolic/apps/com.hunterwittenborn.Celeste.CelesteTrayLoading-symbolic.svg"
install -Dm 644 assets/context/com.hunterwittenborn.Celeste.CelesteTraySyncing-symbolic.svg "{{ env_var('DESTDIR') }}/usr/share/icons/hicolor/symbolic/apps/com.hunterwittenborn.Celeste.CelesteTraySyncing-symbolic.svg"
install -Dm 644 assets/context/com.hunterwittenborn.Celeste.CelesteTrayWarning-symbolic.svg "{{ env_var('DESTDIR') }}/usr/share/icons/hicolor/symbolic/apps/com.hunterwittenborn.Celeste.CelesteTrayWarning-symbolic.svg"
install -Dm 644 assets/context/com.hunterwittenborn.Celeste.CelesteTrayDone-symbolic.svg "{{ env_var('DESTDIR') }}/usr/share/icons/hicolor/symbolic/apps/com.hunterwittenborn.Celeste.CelesteTrayDone-symbolic.svg"
install -Dm 644 assets/com.hunterwittenborn.Celeste.metainfo.xml "{{ env_var('DESTDIR') }}/usr/share/metainfo/com.hunterwittenborn.Celeste.metainfo.xml"
clippy:
cargo clippy -- -D warnings
get-version:
#!/usr/bin/env bash
source makedeb/PKGBUILD
echo "${pkgver}"
update-versions:
#!/usr/bin/env bash
set -euo pipefail
version="$(just get-version)"
sed -i "s|^version = .*|version = \"${version}\"|" Cargo.toml
date="$(cat CHANGELOG.md | grep "^## \[${version}\]" | grep -o '[^ ]*$')"
notes="$(parse-changelog CHANGELOG.md "${version}")"
just update-metainfo
update-metainfo:
#!/usr/bin/env python3
import sys
import markdown
import bs4
import re
from bs4 import BeautifulSoup, NavigableString
from bs4.formatter import HTMLFormatter
# Parse the metainfo and Changelog into BeautifulSoup objects.
metainfo_path = "assets/com.hunterwittenborn.Celeste.metainfo.xml"
changelog_path = "CHANGELOG.md"
text = open(metainfo_path).read()
changelog_md = open(changelog_path).read()
changelog_html = markdown.markdown(changelog_md)
soup = BeautifulSoup(text, features="xml")
changelog_soup = BeautifulSoup(changelog_html, "html.parser")
releases = []
# The changelog is in a flat list of HTML tags. Group them into dicts of
# `version: [html-elements]` for easier usage.
versions = {}
current_version = None
for tag in changelog_soup:
# We don't need empty lines, so ignore them.
if tag.text == "\n":
continue
# Version tags are '##' in markdown (i.e. an '<h2>').
elif tag.name == "h2" and tag.text != "[Unreleased]":
version = re.search("[^[][0-9.]*", tag.text).group(0)
date = re.search("[^ ]*$", tag.text).group(0)
release_soup = BeautifulSoup("<release><description></description></release>", "html.parser").release
release_soup["date"] = date
release_soup["version"] = version
versions[version] = release_soup
current_version = version
# If we aren't on a version tag and haven't gotten any version yet,
# we're dealing with content before the first version tag and we
# should ignore it.
elif len(versions) == 0:
continue
# Appstream doesn't support headers in descriptions, so format them as `<p>` tags.
elif tag.name == "h3":
match tag.text:
case "Added":
header = "New features in this release:"
case "Changed":
header = "Changes in this release:"
case "Fixed":
header = "Fixes in this release:"
case _:
raise Exception(f"Unknown change type: `{tag.text}`")
versions[version].description.append(BeautifulSoup(f"<p>{header}</p>", "html.parser"))
# Otherwise we're adding to the existing version.
else:
versions[version].description.append(tag)
# Clear out the existing versions and write the new ones.
soup.component.releases.clear()
for release in versions.values():
soup.component.releases.append(release)
output = soup.prettify(formatter=HTMLFormatter(indent=4))
open(metainfo_path, "w").write(output)
update-translations:
xtr src/main.rs --copyright-holder 'Hunter Wittenborn <[email protected]>' -o /dev/stdout --package-name 'Celeste' --package-version "$(just get-version)" > po/com.hunterwittenborn.Celeste.pot
# Create the Snap using an already build copy of Celeste. This currently requires you to be running on Ubuntu 22.10 or newer.
create-host-snap:
#!/usr/bin/env bash
set -euo pipefail
cd "$(git rev-parse --show-toplevel)"
host_snapcraft_yml="$(cat snap/snapcraft.yaml | grep -Ev 'source-type: |override-build: |just build')"
tmpdir="$(mktemp -d)"
find ./ -mindepth 1 -maxdepth 1 -not -path './target' -exec cp '{}' "${tmpdir}/{}" -R \;
mkdir -p "${tmpdir}/target/release"
cp target/debug/celeste "${tmpdir}/target/release"
cd "${tmpdir}"
echo "${host_snapcraft_yml}" > snap/snapcraft.yaml
snapcraft -v
cd -
cp "${tmpdir}/"*.snap ./
rm "${tmpdir}" -rf