aboutsummaryrefslogtreecommitdiffstats
path: root/dist/release.sh
blob: d80f371b34d6f86213be4fdd83d75785ab475ef0 (plain)
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
130
131
132
133
#!/bin/sh
set -e

TAG="${1:-scm}"
REVISION="${2:-1}"
ROCK_OPTS=""
WHERE=""

list_modules() {
  for FILE in $(git ls-files "$1" | grep '\.moon$'); do
    MODULE=$(echo "$FILE" | sed -e "s/\.moon$//" -e "s/\//./g")
    echo "      [\"$MODULE\"] = \"$FILE\","
  done
}

if [ "$TAG" = "scm" ]; then
  TAG=""
  VERSION="scm"
elif [ "$TAG" = "test" ]; then
  VERSION="test"
  REVISION=999

  list_modules() {
    for FILE in $(find alv alv-lib -type f | grep '\.moon$'); do
      MODULE=$(echo "$FILE" | sed -e "s/\.moon$//" -e "s/\//./g")
      echo "      [\"$MODULE\"] = \"$FILE\","
    done
  }

else
  VERSION="${TAG#v}"
  VERSION=$(echo "$VERSION" | tr -d -)

  if [ ! -z "$(git status --porcelain -uno)" ]; then
    echo "working directory not clean!"
    exit 2
  fi

  cat <<EOF >"alv/version.moon"
----
-- \`alive\` source code version information.
--
-- @module version

--- exports
-- @table exports
-- @tfield string tag the last versions git tag
-- @tfield string repo the repo web URL
-- @tfield string git the git repo URL
-- @tfield string web the project web URL
-- @tfield string release the web URL of this release
{
  tag: "${TAG}"
  repo: "https://github.com/s-ol/alive"
  git: "https://github.com/s-ol/alive.git"
  web: "https://alv.s-ol.nu"
  release: "https://github.com/s-ol/alive/releases/tag/${TAG}"
}
EOF

  WHERE="
  tag = \"$TAG\","

  ROCK_OPTS="--sign"
fi

cat <<STOP >"dist/rocks/alive-$VERSION-$REVISION.rockspec"
package = "alive"
version = "$VERSION-$REVISION"

source = {
  url = "git://github.com/s-ol/alive.git",$WHERE
}

description = {
  summary = "Experimental livecoding environment with persistent expressions",
  detailed = [[
This is an experimental livecoding language and environment, in which
expressions persist and update until they are removed from the source code, and
the interpreter keeps no state that you cannot manipulate directly in the
source. This yields a direct-manipulation like experience with a purely
text-based language and works without special editor support.]],
  homepage = "https://alv.s-ol.nu",
  license = "GPL-3",
}

dependencies = {
  "lua",
  "moonscript >= 0.5.0",
  "lpeg",
  "luafilesystem",
  "luasystem",
  "luasocket",
  "losc",
}

build = {
  type = "builtin",
  modules = {},
  copy_directories = { "docs" },
  install = {
    lua = {
$(list_modules alv)
      ["alv.copilot.love.main"] = "alv/copilot/love/main.lua",

$(list_modules alv-lib)
    },
    bin = {
      "bin/alv",
      "bin/alv-wx",
      "bin/alv-fltk",
      "bin/alv-love",
    },
  },
}
STOP

if [ -n "$TAG" ] && [ "$TAG" != "test" ]; then
  git add "alv/version.moon" "dist/rocks/alive-$VERSION-$REVISION.rockspec"
  git commit -m "release $TAG"
  git tag -am "version $TAG" "$TAG"

  luarocks pack "dist/rocks/alive-$VERSION-$REVISION.rockspec" $ROCK_OPTS
  mv "alive-$VERSION-$REVISION.src.rock"* dist/rocks
fi

if [ -n "$TAG" ]; then
  luarocks make "dist/rocks/alive-$VERSION-$REVISION.rockspec" $ROCK_OPTS \
    --deps-mode none --pack-binary-rock
  mv "alive-$VERSION-$REVISION.all.rock"* dist/rocks
  echo "now run this in a windows dev cmd.exe:"
  echo dist\win\release.bat "$TAG" "dist/rocks/alive-$VERSION-$REVISION.all.rock"
fi