Skip to content

Commit 70ea5d4

Browse files
authored
[minor] v0.2.0 feature (#6)
* 🚚 Remove commands and revise package structures Signed-off-by: Rintaro Okamura <[email protected]> * 🔥 Remove Makefile Signed-off-by: Rintaro Okamura <[email protected]> * ⬆️ upgrade dependencies Signed-off-by: Rintaro Okamura <[email protected]> * 🔧 Fix Signed-off-by: Rintaro Okamura <[email protected]> * 🔧 Fix Signed-off-by: Rintaro Okamura <[email protected]> * 💚 Fix Ci Signed-off-by: Rintaro Okamura <[email protected]> * 🐳 Fix Dockerfile Signed-off-by: Rintaro Okamura <[email protected]> * 📝 update docs Signed-off-by: Rintaro Okamura <[email protected]>
1 parent ab08f72 commit 70ea5d4

File tree

24 files changed

+319
-431
lines changed

24 files changed

+319
-431
lines changed

.github/workflows/build.yml

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ on:
1212
paths:
1313
- src/**
1414
- project.clj
15-
- reflection.json
15+
- native-config/**
1616

1717
jobs:
1818
build-linux:
@@ -21,7 +21,7 @@ jobs:
2121
- uses: actions/checkout@v1
2222
- uses: rinx/[email protected]
2323
with:
24-
graalvm-version: 19.3.0
24+
graalvm-version: 20.0.0
2525
java-version: java8
2626
- name: Install dependencies
2727
run: |
@@ -34,8 +34,9 @@ jobs:
3434
./lein uberjar
3535
- name: Build native image
3636
run: |
37-
make
37+
./lein native-image
3838
# upx --lzma --best gitwerk
39+
mv target/gitwerk gitwerk
3940
zip --junk-paths gitwerk-linux-amd64 gitwerk
4041
- name: Upload artifact
4142
uses: actions/upload-artifact@v1
@@ -59,7 +60,7 @@ jobs:
5960
echo "::set-env name=GRAALVM_HOME::$GRAALVM_HOME"
6061
echo "::set-env name=JAVA_HOME::$GRAALVM_HOME"
6162
env:
62-
GRAALVM_VERSION: 19.3.0
63+
GRAALVM_VERSION: 20.0.0
6364
JAVA_VERSION: java8
6465
- name: Install dependencies
6566
run: |
@@ -70,7 +71,8 @@ jobs:
7071
lein uberjar
7172
- name: Build native image
7273
run: |
73-
make
74+
lein native-image
75+
mv target/gitwerk gitwerk
7476
zip --junk-paths gitwerk-macos-amd64 gitwerk
7577
- name: Upload artifact
7678
uses: actions/upload-artifact@v1

.github/workflows/semver.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ on:
55
- master
66

77
jobs:
8-
semver-auto:
9-
name: Run semver-auto
8+
semver:
9+
name: Run semver
1010
runs-on: ubuntu-latest
1111
steps:
1212
- name: Check out code.
@@ -17,9 +17,9 @@ jobs:
1717
run: |
1818
wget "https://github.com/rinx/gitwerk/releases/latest/download/gitwerk-linux-amd64.zip"
1919
unzip gitwerk-linux-amd64.zip
20-
- name: Run gitwerk semver-auto
20+
- name: Run gitwerk semver
2121
run: |
22-
./gitwerk semver-auto
22+
./gitwerk contextual-semver
2323
git remote set-url origin "https://${GITHUB_USER}:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}.git"
2424
git push origin --tags
2525
env:

Dockerfile

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,7 @@ RUN lein uberjar
2121

2222
COPY native-config native-config
2323

24-
COPY Makefile Makefile
25-
26-
RUN make
24+
RUN lein native-image
2725

2826
RUN mkdir -p /out/lib \
2927
&& cp $JAVA_HOME/jre/lib/amd64/libsunec.so /out/lib/ \
@@ -36,6 +34,6 @@ LABEL maintainer "rinx <[email protected]>"
3634
RUN apt-get update && apt-get install -y git && rm -rf /var/lib/apt/lists/*
3735

3836
COPY --from=graalvm /out /gitwerk-libs
39-
COPY --from=graalvm /gitwerk/gitwerk /gitwerk
37+
COPY --from=graalvm /gitwerk/target/gitwerk /gitwerk
4038

4139
CMD ["/gitwerk", "-Djava.library.path=/gitwerk-libs/lib", "-Djavax.net.ssl.trustStore=/gitwerk-libs"]

Makefile

Lines changed: 0 additions & 75 deletions
This file was deleted.

README.md

Lines changed: 66 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,61 @@ It is available to download native binaries for Linux and macOS from the [latest
1515

1616
## Usage
1717

18-
gitwerk has several subcommands.
18+
gitwerk has several default functions.
1919

20-
### semver-auto
20+
- `clone`
21+
- `log`
22+
- `tag`
23+
- `contextual-semver`
24+
25+
The definitions of these functions can be printed by `prelude` function.
26+
27+
```bash
28+
$ gitwerk prelude
29+
(defn clone [repository]
30+
(git/clone repository))
31+
32+
(defn log
33+
([]
34+
(log "."))
35+
([repodir]
36+
(-> (git/repo repodir)
37+
(git/logs))))
38+
39+
(defn tag
40+
([]
41+
(tag "."))
42+
([repodir]
43+
(-> (git/repo repodir)
44+
(git/tags))))
45+
46+
(defn repl []
47+
(println "not implemented yet"))
48+
49+
(defn contextual-semver
50+
([]
51+
(contextual-semver "."))
52+
([repodir]
53+
(let [repo (git/repo repodir)
54+
message (-> repo
55+
(git/latest-log)
56+
:full-message)
57+
tag (or (-> repo
58+
(git/tags)
59+
(semver/latest-tag))
60+
(semver/default-version-str))
61+
new-tag (semver/contextual-semver message tag)]
62+
(if (not (= tag new-tag))
63+
(do
64+
(git/tag repo new-tag)
65+
{:status :updated
66+
:old-version tag
67+
:new-version new-tag})
68+
{:status :not-updated}))))
69+
```
70+
71+
72+
### contextual-semver
2173

2274
increments version by git log message contexts.
2375

@@ -28,7 +80,7 @@ increments version by git log message contexts.
2880
$ git commit -m "[patch] increment patch version"
2981
## the commit comment contains "[patch]"
3082

31-
$ gitwerk semver-auto
83+
$ gitwerk contextual-semver
3284
{:status :updated :old-version v0.0.1 :new-version v0.0.2}
3385
## increments tag to v0.0.2
3486

@@ -37,7 +89,7 @@ $ gitwerk semver-auto
3789
$ git commit -m "[tag.suffix=-alpha] [minor] increment minor version and add suffix"
3890
## the commit comment contains "[minor]" and "[tag.suffix=-alpha]"
3991

40-
$ gitwerk semver-auto
92+
$ gitwerk contextual-semver
4193
{:status :updated :old-version v0.0.2 :new-version v0.1.0-alpha}
4294
## increments tag to v0.1.0-alpha
4395

@@ -46,7 +98,7 @@ $ gitwerk semver-auto
4698
$ git commit -m "[tag.prefix=] [tag.suffix=] [major] increment major version and remove prefix and suffix"
4799
## the commit comment contains "[major]", "[tag.prefix=]" and "[tag.suffix=]"
48100

49-
$ gitwerk semver-auto
101+
$ gitwerk contextual-semver
50102
{:status :updated :old-version v0.1.0-alpha :new-version 1.0.0}
51103
## increments tag to 1.0.0
52104

@@ -55,69 +107,28 @@ $ gitwerk semver-auto
55107
$ git commit -m "[tag.prefix=v] just adding prefix"
56108
## the commit comment contains "[tag.prefix=v]"
57109

58-
$ gitwerk semver-auto
110+
$ gitwerk contextual-semver
59111
{:status :updated :old-version 1.0.0 :new-version v1.0.0}
60112
## increments tag to v1.0.0
61113
```
62114

63-
### semver
64-
65-
prints incremented version.
66115

67-
```bash
68-
## when the latest tag is v0.0.1
116+
### Define your own functions
69117

70-
$ gitwerk semver patch
71-
v0.0.2
118+
You can define your own functions and load them by using `--file` option or `--stdin` option.
72119

73-
$ gitwerk semver minor
74-
v0.1.0
75-
76-
$ gitwerk semver major
77-
v1.0.0
120+
```bash
121+
gitwerk --stdin myfunc
122+
(defn myfunc []
123+
(print "this is my first func"))
78124
```
79125

80-
### sci
126+
Available functions are non-side-effecting functions enabled in [sci](https://github.com/borkdude/sci) and the exported functions in gitwerk.internal and gitwerk.prelude namespaces.
81127

82-
gitwerk supports to run user-defined scripts written in clojure (powered by [borkdude/sci](https://github.com/borkdude/sci)).
83-
84-
```bash
85-
## can read stdin
86-
$ echo '(semver ctx ["patch"])' | gitwerk sci
87-
v0.0.2
88-
89-
## also read a file as a script
90-
$ cat examples/example1.clj
91-
(semver ctx ["patch"])
92-
$ gitwerk sci examples/example1.clj
93-
v0.0.3
94-
95-
## fetch executed command result and modify returned message
96-
$ cat examples/example2.clj
97-
(let [res (semver-auto ctx nil)
98-
status (get-in res [:console-out :status])
99-
oldv (get-in res [:console-out :old-version])
100-
newv (get-in res [:console-out :new-version])]
101-
(if (= status :updated)
102-
(str "Version updated: " oldv " -> " newv)
103-
"Version not updated"))
104-
$ gitwerk sci examples/example2.clj
105-
Version not updated
106-
107-
$ git commit --allow-empty -m "[patch] version updated"
108-
$ gitwerk sci examples/example2.clj
109-
Version updated: v0.0.3 -> v0.0.4
110-
111-
## http get/post using clj-http-lite.client
112-
$ echo '(-> (http/get "https://api.github.com/repos/rinx/gitwerk/issues") pprint)' | gitwerk sci
113-
114-
## parse json and convert to clj map
115-
$ echo '(-> (http/get "https://api.github.com/repos/rinx/gitwerk/issues") :body (json/read-value) pprint)' | gitwerk sci
116-
```
117128

118129
## License
119130

120-
Copyright © 2019 rinx
131+
Copyright © 2019-2020 rinx
121132

122133
This program and the accompanying materials are made available under the
123134
terms of the Eclipse Public License 2.0 which is available at

native-config/reflect-config.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,10 @@
4949
"name":"org.eclipse.jgit.lib.CoreConfig$SymLinks",
5050
"methods":[{"name":"values","parameterTypes":[] }]
5151
},
52+
{
53+
"name":"org.eclipse.jgit.lib.CoreConfig$LogRefUpdates",
54+
"methods":[{"name":"values","parameterTypes":[] }]
55+
},
5256
{
5357
"name":"org.eclipse.jgit.lib.ObjectIdRef$PeeledNonTag",
5458
"allPublicMethods":true

project.clj

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,35 @@
33
:url "https://github.com/rinx/gitwerk"
44
:license {:name "Eclipse Public License"
55
:url "http://www.eclipse.org/legal/epl-v10.html"}
6-
:dependencies [[org.clojure/clojure "1.9.0"]
7-
#_[org.clojure/spec.alpha "0.2.176"]
6+
:dependencies [[org.clojure/clojure "1.10.2-alpha1"]
87
[org.clojure/tools.cli "0.4.2"]
9-
[metosin/jsonista "0.2.2"]
8+
[metosin/jsonista "0.2.5"]
109
[camel-snake-kebab "0.4.0"]
11-
[io.quarkus/quarkus-jgit "1.1.0.CR1"]
12-
[borkdude/sci "0.0.12-alpha.7"]
10+
[io.quarkus/quarkus-jgit "1.4.1.Final"]
11+
[borkdude/sci "0.0.13-alpha.17"]
1312
[org.martinklepsch/clj-http-lite "0.4.3"]]
13+
:plugins [[io.taylorwood/lein-native-image "0.3.1"]]
14+
:native-image {:name "gitwerk"
15+
:opts ["-H:+ReportExceptionStackTraces"
16+
"-H:Log=registerResource:"
17+
"-H:ConfigurationFileDirectories=native-config"
18+
"--enable-url-protocols=http,https"
19+
"--enable-all-security-services"
20+
"-H:+JNI"
21+
"--verbose"
22+
"--no-fallback"
23+
"--no-server"
24+
"--report-unsupported-elements-at-runtime"
25+
"--initialize-at-run-time=org.eclipse.jgit.transport.HttpAuthMethod$Digest"
26+
"--initialize-at-run-time=org.eclipse.jgit.lib.GpgSigner"
27+
"--initialize-at-run-time=io.quarkus.jsch.runtime.PortWatcherRunTime"
28+
"--initialize-at-build-time"
29+
"-H:IncludeResourceBundles=org.eclipse.jgit.internal.JGitText"
30+
"--allow-incomplete-classpath"
31+
"-J-Xms2g"
32+
"-J-Xmx7g"]
33+
:jvm-opts ["-Dclojure.spec.skip-macros=true"
34+
"-Dclojure.compiler.direct-linking=true"]}
1435
:profiles {:dev {:dependencies [[org.clojure/tools.namespace "0.2.11"]
1536
[orchestra "2019.02.06-1"]]
1637
:source-paths ["dev"]}

0 commit comments

Comments
 (0)