Просмотр исходного кода

Tooling for publishing Hex package

Viktor Söderqvist 5 лет назад
Родитель
Сommit
8d0cf21aff
5 измененных файлов с 82 добавлено и 11 удалено
  1. 1 0
      .gitignore
  2. 10 2
      Makefile
  3. 2 9
      README.md
  4. 0 0
      priv/bin/changelog.sh
  5. 69 0
      priv/bin/mk_mix_file.escript

+ 1 - 0
.gitignore

@@ -13,6 +13,7 @@ ebin
 rel/example_project
 .concrete/DEV_MODE
 .rebar
+mix.exs
 cover
 *.coverdata
 tests.output

+ 10 - 2
Makefile

@@ -9,7 +9,8 @@
 #  - gh-pages:       Generates docs and eunit reports and commits these in the
 #                    gh-pages which Github publishes automatically when pushed.
 #  - CHANGELOG.md:   Generates a changelog from the git commits and tags.
-.PHONY: gh-pages tests-report tests-prep CHANGELOG.md
+#  - publish-hex:    Publishes package and docs to Hex. Requires Mix.
+.PHONY: gh-pages tests-report tests-prep CHANGELOG.md publish-hex
 
 PROJECT = mysql
 EDOC_OPTS = {stylesheet_file,"priv/edoc-style.css"},{todo,true}
@@ -29,7 +30,7 @@ distclean::
 	$(MAKE) -C test/ssl clean
 
 CHANGELOG.md:
-	./changelog.sh > $@
+	priv/bin/changelog.sh > $@
 
 # Update the local 'gh-pages' branch with pregenerated output files
 # (trick from https://groups.google.com/forum/#!topic/github/XYxkdzxpgCo)
@@ -63,3 +64,10 @@ tests-report:
 	 echo '</pre>' ; \
 	 echo '</body></html>') > doc/eunit.html
 	@cp cover/*.COVER.html doc/
+
+# For publishing to Hex using Mix
+publish-hex: docs mix.exs
+	mix hex.publish
+
+mix.exs: priv/bin/mk_mix_file.escript
+	priv/bin/mk_mix_file.escript > $@

+ 2 - 9
README.md

@@ -176,12 +176,9 @@ Tagging a new version:
   * Update the online documentation and coverage reports using `make gh-pages`.
     Then push the gh-pages branch using `git push origin gh-pages`.
 
-Updating the Hex package using rebar3:
+Updating the Hex package (requires Mix):
 
-1. Setup the rebar3 hex plugin and authentication;
-    see [rebar3_hex](https://github.com/tsloughter/rebar3_hex).
-2. `rebar3 hex publish`
-3. `rebar3 hex docs`
+    make publish-hex
 
 License
 -------
@@ -190,7 +187,3 @@ GNU Lesser General Public License (LGPL) version 3 or any later version.
 Since the LGPL is a set of additional permissions on top of the GPL, both
 license texts are included in the files [COPYING](COPYING) and
 [COPYING.LESSER](COPYING.LESSER) respectively.
-
-We hope this license should be permissive enough while remaining copyleft. If
-you're having issues with this license, please create an issue in the issue
-tracker!

+ 0 - 0
changelog.sh → priv/bin/changelog.sh


+ 69 - 0
priv/bin/mk_mix_file.escript

@@ -0,0 +1,69 @@
+#!/usr/bin/env escript
+
+%% Generates mix.exs from ebin/mysql.app.
+%% The mix file is used for publishing the package to Hex.
+
+-mode(compile).
+
+-define(MIX_TPL,
+<<"defmodule Mysql.Mixfile do
+  use Mix.Project
+
+  def project() do
+    [app: :mysql,
+     version: \"~s\",
+     elixir: \"~~> 1.0\",
+     description: description(),
+     package: package(),
+     build_embedded: Mix.env == :prod,
+     start_permanent: Mix.env == :prod,
+     deps: deps(),
+     aliases: aliases()]
+  end
+
+  defp description() do
+     \"\"\"
+     ~s
+     \"\"\"
+  end
+
+  defp package() do
+    [contributors: [\"Viktor Söderqvist\", \"Jan Uhlig\", \"et.al.\"],
+     maintainers: [\"Viktor Söderqvist\", \"TJ\"],
+     licenses: [\"LGPL-3.0-or-later\"],
+     links: %{\"GitHub\" => \"https://github.com/mysql-otp/mysql-otp\"},
+     build_tools: [\"make\", \"rebar3\", \"mix\"],
+     files: ~~w(mix.exs README.md CHANGELOG.md) ++
+            ~~w(doc erlang.mk include Makefile priv src test)
+    ]
+  end
+
+  # Configuration for the OTP application
+  #
+  # Type `mix help compile.app` for more information
+  def application() do
+    [applications: [:ssl]]
+  end
+
+  # Dependencies
+  defp deps() do
+    []
+  end
+
+  # Alias docs to nothing, just to be able to publish docs to Hex
+  # using already generated docs
+  defp aliases() do
+    [
+      docs: []
+    ]
+  end
+end
+">>).
+
+main(_) ->
+    {ok, [{application, mysql, Props}]} =
+        file:consult("ebin/mysql.app"),
+    Vsn = proplists:get_value(vsn, Props),
+    Desc = proplists:get_value(description, Props),
+    io:setopts([{encoding, unicode}]),
+    io:format(?MIX_TPL, [Vsn, Desc]).