Skip to content

Commit d08fff7

Browse files
Steve RamageSJrX
authored andcommitted
Resolves #160 - Auto generate changelog
1 parent 0eb1a0b commit d08fff7

File tree

7 files changed

+45
-131
lines changed

7 files changed

+45
-131
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ This plugin is avaliable to install at the [JetBrains Plugin Repository](https:/
4848

4949
Contributors
5050
-------------
51+
* [Steve Ramage](https://github.com/SJrX)
5152
* [Vlad Rassokhin](https://github.com/VladRassokhin)
5253

5354
Acknowledgements

build.gradle.kts

Lines changed: 15 additions & 111 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
1-
import org.gradle.internal.os.OperatingSystem
21
import org.jetbrains.grammarkit.tasks.GenerateLexerTask
32
import org.jetbrains.grammarkit.tasks.GenerateParserTask
4-
5-
import java.time.ZoneId
6-
import java.time.Instant
3+
import java.nio.file.Files
4+
import java.nio.file.Paths
75
import java.time.LocalDate
8-
import java.time.format.DateTimeFormatter.*
6+
import java.time.format.DateTimeFormatter.ofPattern
97

108
fun properties(key: String) = project.findProperty(key).toString()
119

@@ -70,6 +68,17 @@ intellij {
7068
version.set(properties("intellijVersion"))
7169
}
7270

71+
val relativePath = "CHANGELOG"
72+
val filePath = Paths.get(project.buildDir.path, relativePath)
73+
74+
// Check if the file exists and read its content or use a default string
75+
val changeLogContents: String = if (Files.exists(filePath)) {
76+
filePath.toFile().readText()
77+
} else {
78+
"Development Build"
79+
}
80+
81+
7382
tasks {
7483
compileKotlin {
7584
kotlinOptions {
@@ -80,112 +89,7 @@ tasks {
8089

8190
tasks {
8291
patchPluginXml {
83-
changeNotes.set("""
84-
<h3>v0.3.10</h3>
85-
<ul>
86-
<li>Add support for IntelliJ 2022.3 and Update systemd data for v252 <a href="https://github.com/SJrX/systemdUnitFilePlugin/issues/150">#150</a></li>
87-
</ul>
88-
<h3>v0.3.9</h3>
89-
<ul>
90-
<li>Add support for IntelliJ 2022.2 <a href="https://github.com/SJrX/systemdUnitFilePlugin/issues/143">#143</a></li>
91-
</ul>
92-
<h3>v0.3.8</h3>
93-
<ul>
94-
<li>Fix weak warning for absolute paths when using allowed prefix <a href="https://github.com/SJrX/systemdUnitFilePlugin/issues/141">#141</a></li>
95-
</ul>
96-
<h3>v0.3.7</h3>
97-
<ul>
98-
<li>Update build to be based off of systemd v251 <a href="https://github.com/SJrX/systemdUnitFilePlugin/issues/131">#131</a></li>
99-
<li>Fix NPE in some cases when getting doc link <a href="https://github.com/SJrX/systemdUnitFilePlugin/issues/114">#114</a></li>
100-
<li>Validation warning when shell meta-characters are in an Exec directive <a href="https://github.com/SJrX/systemdUnitFilePlugin/issues/60">#60</a></li>
101-
<li>Add support for auto-completion / validation of Unit options <a href="https://github.com/SJrX/systemdUnitFilePlugin/issues/102">#102</a></li>
102-
<li>Add weak warning when an absolute path isn"t used on an Exec directive<a href="https://github.com/SJrX/systemdUnitFilePlugin/issues/133">#133</a></li>
103-
<li>Fix missing documentation for Condition= and Assert directives <a href="https://github.com/SJrX/systemdUnitFilePlugin/issues/96">#96</a></li>
104-
</ul>
105-
<h3>v0.3.6</h3>
106-
<ul>
107-
<li>Add support for Go Land 2022.1<a href="https://github.com/SJrX/systemdUnitFilePlugin/issues/128">#128</a></li>
108-
</ul>
109-
<h3>v0.3.5</h3>
110-
<ul>
111-
<li>Add support for IntelliJ 2022.1 <a href="https://github.com/SJrX/systemdUnitFilePlugin/issues/126">#126</a></li>
112-
</ul>
113-
<h3>v0.3.4</h3>
114-
<ul>
115-
<li>Add support for IntelliJ 2021.3 <a href="https://github.com/SJrX/systemdUnitFilePlugin/issues/119">#119</a></li>
116-
<li>Remove support for IntelliJ 2021.1, due to plugin compatibility fixes</li>
117-
<li>Fix file type issue description <a href="https://github.com/SJrX/systemdUnitFilePlugin/issues/106"/>#106</a></li>
118-
<li>Fix deprecation warnings <a href="https://github.com/SJrX/systemdUnitFilePlugin/issues/123"/>#123</a></li>
119-
</ul>
120-
<h3>v0.3.3</h3>
121-
<ul>
122-
<li>Add support for IntelliJ 2021.2 <a href="https://github.com/SJrX/systemdUnitFilePlugin/issues/111">#111</a></li>
123-
</ul>
124-
<h3>v0.3.2</h3>
125-
<ul>
126-
<li>Add support for IntelliJ 2021.1 <a href="https://github.com/SJrX/systemdUnitFilePlugin/issues/107">#107</a></li>"
127-
</ul>
128-
<h3>v0.3.1</h3>
129-
<ul>
130-
<li>Add support for IntelliJ 2020.3 and systemd v247 <a href="https://github.com/SJrX/systemdUnitFilePlugin/issue-103">#103</a> (drops support for 2020.2 <a href="https://blog.jetbrains.com/platform/2020/09/intellij-project-migrates-to-java-11/">due to Java 11 Upgrade</a>) </li>
131-
</ul>
132-
<h3>v0.3.0</h3>
133-
<ul>
134-
<li>Add support for IntelliJ 2020.2 (and drops support for anything before IntelliJ 2020.1) <a href="https://github.com/SJrX/systemdUnitFilePlugin/pull/92">#92</a></li>
135-
<li>Add support for systemd v245 (and maybe a little bit of v246) <a href="https://github.com/SJrX/systemdUnitFilePlugin/issues/95">#95</a></li>
136-
</ul>
137-
<h3>v0.2.6</h3>
138-
<ul>
139-
<li>Improved Error Handling, Memory Management, Misc fixes <a href="https://github.com/SJrX/systemdUnitFilePlugin/pull/88">#88></a></li>
140-
<li>New plugin logo <a href="https://github.com/SJrX/systemdUnitFilePlugin/pull/92">#92</a></li>
141-
</ul>
142-
<h3>v0.2.5</h3>
143-
<ul>
144-
<li>Add support IntelliJ 2020.1 <a href="https://github.com/SJrX/systemdUnitFilePlugin/issues/86">#86</a>
145-
</ul>
146-
<h3>v0.2.5</h3>
147-
<ul>
148-
<li>Add support IntelliJ 2020.1 <a href="https://github.com/SJrX/systemdUnitFilePlugin/issues/86">#86</a>
149-
</ul>
150-
<h3>v0.2.4</h3>
151-
<ul>
152-
<li>Add support for systemd v244 <a href="https://github.com/SJrX/systemdUnitFilePlugin/issues/85">#85</a></li>
153-
<li>Change Logo<a href="https://github.com/SJrX/systemdUnitFilePlugin/issues/84">#84</a></li>
154-
<li>Add support IntelliJ 2019.3 <a href="https://github.com/SJrX/systemdUnitFilePlugin/issues/82">#82</a>
155-
</ul>
156-
<h3>v0.2.3</h3>
157-
<ul>
158-
<li>Add support for systemd v243 <a href="https://github.com/SJrX/systemdUnitFilePlugin/issues/79">#79</a></li>
159-
</ul>
160-
<h3>v0.2.2</h3>
161-
<ul>
162-
<li>Add support for IntelliJ 2019.2 <a href="https://github.com/SJrX/systemdUnitFilePlugin/issues/76">#76</a></li>
163-
</ul>
164-
<h3>v0.2.1</h3>
165-
<ul>
166-
<li>Add support for IntelliJ 2019.1 <a href="https://github.com/SJrX/systemdUnitFilePlugin/issues/73">#73</a></li>
167-
<li>Add support for <em>all</em> deprecated / undocumented options <a href="https://github.com/SJrX/systemdUnitFilePlugin/issues/67">#67</a>
168-
, <a href="https://github.com/SJrX/systemdUnitFilePlugin/issues/71">#71</a></li>
169-
</ul>
170-
<h3>v0.2.0</h3>
171-
<ul>
172-
<li>Updating syntax highlighting to properly handle comments with line continuations.</li>
173-
<li>Warning when line continuation character is followed by whitespace</li>
174-
<li>New inspection for deprecated options</li>
175-
<h3>v0.1.2</h3>
176-
<ul>
177-
<li>Added support for systemd v240 keywords.</li>
178-
<li>Fixed bug with tab character causing issues with syntax highlighting <a href="https://github.com/SJrX/systemdUnitFilePlugin/issues/51">#51</a>.</li>
179-
</ul>
180-
<h3>v0.1.1</h3>
181-
<ul>
182-
<li>Added support for IntelliJ 2018.3.</li>
183-
</ul>
184-
<h3>v0.1.0</h3>
185-
<ul>
186-
<li>Initial Release.</li>
187-
</ul>
188-
""")
92+
changeNotes.set(changeLogContents)
18993
sinceBuild.set(properties("sinceVersion"))
19094
untilBuild.set(properties("untilVersion"))
19195
}

ci/release.Jenkinsfile

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,7 @@ pipeline {
287287
sh("""
288288
mkdir -p ./systemd-build/build
289289
cp /opt/systemd-source/systemd/load-fragment-gperf.gperf ./systemd-build/build
290+
cp /opt/systemd-source/systemd/last_commit_date /opt/systemd-source/systemd/last_commit_hash ./systemd-build/build
290291
cp -R /opt/systemd-source/systemd/man ./systemd-build/build
291292
""")
292293
stash includes: 'systemd-build/build/**', name: 'systemd-build-build', allowEmpty: false
@@ -310,7 +311,9 @@ pipeline {
310311
unstash 'systemd-build-build'
311312
unstash 'ubuntu-units'
312313
sh("""
313-
./gradlew --no-daemon -I ./build-cache-init.gradle.kts --build-cache clean build buildPlugin --scan
314+
mkdir -p ./build
315+
./generate-changelog > build/CHANGELOG
316+
./gradlew --no-daemon -I ./build-cache-init.gradle.kts --build-cache build buildPlugin --scan
314317
""")
315318
script {
316319
if (env.BRANCH_NAME ==~ /^([0-9][0-9][0-9].x)$/) {

generate-changelog

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/bin/bash
2+
3+
SYSTEMD_DATE=$(<./systemd-build/build/last_commit_date tr -d '\n')
4+
SYSTEMD_COMMIT=$(<./systemd-build/build/last_commit_hash tr -d '\n')
5+
SYSTEMD_MESSAGE=$(echo "<li><b>[$SYSTEMD_DATE]</b> Update of systemd unit metadata (<a href='https://github.com/systemd/systemd/commit/$SYSTEMD_COMMIT'>$SYSTEMD_COMMIT</a>)</li></br>")
6+
7+
echo "<h3>Changes</h3>"
8+
echo "<ul>"
9+
{ git log --format="%H %aE" | grep -v dependabot | head -n 20 | cut -d ' ' -f 1 | xargs -d "\n" -n 1 git log -n 1 "--pretty=format:<li><b>[%ad]</b> %s</li></br>%n" --date=format:%Y-%m-%d | sed -E "s%#([0-9]+)%\<a href='https://github.com/SJrX/systemdUnitFilePlugin/issues/\1'>#\1</a>%g"; echo $SYSTEMD_MESSAGE; } | sort -r
10+
echo "</ul>"

src/main/resources/META-INF/plugin.xml

Lines changed: 10 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -5,24 +5,17 @@
55
<vendor email="[email protected]">Steve Ramage</vendor>
66

77
<description><![CDATA[
8-
Adds support for systemd unit files, including the following features:
8+
Adds support for <a href='https://systemd.io/'>systemd</a> <a href="https://www.freedesktop.org/software/systemd/man/latest/systemd.unit.html">unit files</a> which are used to configure (some/most) Linux distributions.
9+
<br/>
10+
<br/>
11+
This plugin adds the following features to the IDE:
912
<ul>
10-
<li>Syntax highlighting for unit files</li>
11-
<li>Auto-completion for:
12-
<ul>
13-
<li>Option names in a section</li>
14-
<li>Boolean options</li>
15-
<li>Octal options</li>
16-
<li>Some other common options (<var>KillMode=</var>, <var>Type=</var>, <var>Restart=</var>)
17-
</ul>
18-
</li>
19-
<li>Inspections:
20-
<ul>
21-
<li>Invalid values for boolean options</li>
22-
<li>Unknown option in section (ignoring those starting with <em>X-</em>)</li>
23-
<li>Deprecated options</li>
24-
</ul>
25-
</li>
13+
<li>Syntax highlighting for unit files</li>
14+
<li>Auto-completion for a number of options</li>
15+
<li>Inspections for some errors such as invalid or unknown or deprecated options</li>
16+
<li>Quick fixes</li>
17+
<li>Built-in documentation reference for options</li>
18+
</ul>
2619
]]></description>
2720

2821
<change-notes><!-- From gradle, this section must be 40 characters long, so here you go -->0123456789012345678901234567890123456789</change-notes>

systemd-build/Systemd-Builder.Dockerfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ FROM ubuntu:22.04
22

33
ENV DEBIAN_FRONTEND noninteractive
44

5-
RUN ln -fs /usr/share/zoneinfo/America/Vancouver /etc/localtime
5+
RUN ln -fs /usr/share/zoneinfo/Etc/UTC /etc/localtime
66

77
RUN apt-get update && apt-get -y install git build-essential tzdata meson pkg-config gperf python3-jinja2 libcap-dev util-linux libmount1 libmount-dev
88

@@ -22,3 +22,4 @@ ADD systemd-build.sh /
2222
CMD /systemd-build.sh
2323

2424
RUN /systemd-build.sh
25+

systemd-build/systemd-build.sh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ echo "Git Pull" && \
88
echo "Copy file(s)" && \
99
cp load-fragment-gperf.gperf /mount/load-fragment-gperf.gperf && \
1010
cp -R ./man /mount/ && \
11-
git log -1 --format="%at" | xargs -I{} date -d @{} +%Y-%m-%d > /mount/last_commit_date && \
11+
git log -1 --format="%at" | xargs -I{} date -d @{} +%Y-%m-%d > last_commit_date && \
12+
git rev-parse --short=10 HEAD > last_commit_hash && \
13+
cp last_commit_date last_commit_hash /mount/ && \
1214
echo "Reset Permissions" && \
1315
chmod 777 -R /mount

0 commit comments

Comments
 (0)