|
1 |
| -#! /bin/sh |
| 1 | +#! /usr/bin/env bash |
| 2 | +# |
| 3 | +# Copyright (c) 2017 Nat! - Mulle kybernetiK |
| 4 | +# All rights reserved. |
| 5 | +# |
| 6 | +# Redistribution and use in source and binary forms, with or without |
| 7 | +# modification, are permitted provided that the following conditions are met: |
| 8 | +# |
| 9 | +# Redistributions of source code must retain the above copyright notice, this |
| 10 | +# list of conditions and the following disclaimer. |
| 11 | +# |
| 12 | +# Redistributions in binary form must reproduce the above copyright notice, |
| 13 | +# this list of conditions and the following disclaimer in the documentation |
| 14 | +# and/or other materials provided with the distribution. |
| 15 | +# |
| 16 | +# Neither the name of Mulle kybernetiK nor the names of its contributors |
| 17 | +# may be used to endorse or promote products derived from this software |
| 18 | +# without specific prior written permission. |
| 19 | +# |
| 20 | +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
| 21 | +# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| 22 | +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
| 23 | +# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE |
| 24 | +# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
| 25 | +# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
| 26 | +# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
| 27 | +# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
| 28 | +# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
| 29 | +# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
| 30 | +# POSSIBILITY OF SUCH DAMAGE. |
| 31 | +# |
| 32 | + |
| 33 | + |
| 34 | +# Define your project and the dependencies for homebrew |
| 35 | +# DEPENDENCIES and BUILD_DEPENDENCIES will be evaled later! |
| 36 | +# Then run this as |
| 37 | +# ./bin/release.sh --publisher mulle-nat --publisher-tap mulle-kybernetik/alpha/ |
| 38 | +# |
2 | 39 |
|
3 | 40 | PROJECT="MulleObjcRuntime" # requires camel-case
|
4 | 41 | DESC="An Objective-C runtime, written 100% in C"
|
5 |
| -DEPENDENCIES='${DEPENDENCY_TAP}mulle-concurrent |
6 |
| -${DEPENDENCY_TAP}mulle-vararg' # no camel case, will be evaled later! |
7 | 42 | LANGUAGE=c # c,cpp, objc
|
8 | 43 |
|
9 |
| -HEADER="src/mulle_objc_version.h" |
10 |
| -VERSIONNAME="MULLE_OBJC_RUNTIME_VERSION" |
11 | 44 | NAME="mulle-objc-runtime"
|
12 | 45 |
|
| 46 | + |
| 47 | +# |
| 48 | +# Keep these commented out, if the automatic detection works well |
| 49 | +# enough for you |
| 50 | +# |
| 51 | +VERSIONFILE="src/mulle_objc_version.h" |
| 52 | +VERSIONNAME="MULLE_OBJC_RUNTIME_VERSION" |
| 53 | + |
| 54 | +# |
| 55 | +# Specify needed homebrew packages by name as you would when saying |
| 56 | +# `brew install`. |
| 57 | +# |
| 58 | +# Use the ${DEPENDENCY_TAP} prefix for non-official dependencies. |
| 59 | +# |
| 60 | +DEPENDENCIES='${DEPENDENCY_TAP}mulle-concurrent |
| 61 | +${DEPENDENCY_TAP}mulle-vararg' |
| 62 | + |
| 63 | +BUILD_DEPENDENCIES='${BOOTSTRAP_TAP}mulle-bootstrap |
| 64 | +${BOOTSTRAP_TAP}mulle-build |
| 65 | +cmake' # cmake would be useful to, if you are cmake based! |
| 66 | + |
| 67 | + |
| 68 | +####### |
| 69 | +# If you are using mulle-build, you don't hafta change anything after this |
| 70 | +####### |
| 71 | + |
| 72 | +# |
| 73 | +# Generate your `def install` `test do` lines here to stdout. |
| 74 | +# |
| 75 | +generate_brew_formula_build() |
| 76 | +{ |
| 77 | + local project="$1" |
| 78 | + local name="$2" |
| 79 | + local version="$3" |
| 80 | + |
| 81 | + generate_brew_formula_mulle_build "${project}" "${name}" "${version}" |
| 82 | + generate_brew_formula_mulle_test "${project}" "${name}" "${version}" |
| 83 | +} |
| 84 | + |
| 85 | + |
13 | 86 | #
|
14 |
| -# Ideally you don't hafta change anything below this line |
| 87 | +# If you are unhappy with the formula in general, then change |
| 88 | +# this function. Print your formula to stdout. |
15 | 89 | #
|
16 |
| -# source mulle-homebrew.sh (clumsily) |
| 90 | +generate_brew_formula() |
| 91 | +{ |
| 92 | +# local project="$1" |
| 93 | +# local name="$2" |
| 94 | +# local version="$3" |
| 95 | +# local dependencies="$4" |
| 96 | +# local builddependencies="$5" |
| 97 | +# local homepage="$6" |
| 98 | +# local desc="$7" |
| 99 | +# local archiveurl="$8" |
| 100 | + |
| 101 | + _generate_brew_formula "$@" |
| 102 | +} |
17 | 103 |
|
18 |
| -PUBLISHER="mulle-nat" |
19 |
| -PUBLISHER_TAP="mulle-kybernetik/software/" |
20 |
| -DEPENDENCY_TAP="mulle-kybernetik/software/" |
21 |
| -BOOTSTRAP_TAP="mulle-kybernetik/alpha/" |
| 104 | +####### |
| 105 | +# Ideally changes to the following values are done with the command line |
| 106 | +# which makes it easier for forks. |
| 107 | +####### |
22 | 108 |
|
| 109 | +MULLE_BOOTSTRAP_FAIL_PREFIX="`basename -- $0`" |
| 110 | +MULLE_HOMEBREW_VERSION="3.4.3" |
23 | 111 |
|
24 |
| -MULLE_BOOTSTRAP_FAIL_PREFIX="release.sh" |
25 |
| -DIR="`dirname -- "$0"`" |
26 |
| -. ${DIR}/mulle-homebrew/mulle-homebrew.sh || exit 1 |
27 |
| -cd "${DIR}/.." |
| 112 | +INSTALLED_MULLE_HOMEBREW_VERSION="`mulle-homebrew-env version`" || exit 1 |
| 113 | +LIBEXEC_DIR="`mulle-homebrew-env libexec-path`" || exit 1 |
| 114 | + |
| 115 | +. "${LIBEXEC_DIR}/mulle-homebrew.sh" || exit 1 |
| 116 | +. "${LIBEXEC_DIR}/mulle-git.sh" || exit 1 |
| 117 | + |
| 118 | +if ! homebrew_is_compatible_version "${INSTALLED_MULLE_HOMEBREW_VERSION}" "${MULLE_HOMEBREW_VERSION}" |
| 119 | +then |
| 120 | + fail "Installed mulle-homebrew version ${INSTALLED_MULLE_HOMEBREW_VERSION} is \ |
| 121 | +not compatible with this script from version ${MULLE_HOMEBREW_VERSION}" |
| 122 | +fi |
28 | 123 |
|
29 | 124 | # parse options
|
30 | 125 | homebrew_parse_options "$@"
|
31 | 126 |
|
32 |
| -# dial past options |
| 127 | +# |
| 128 | +# dial past options now as they have been parsed |
| 129 | +# |
33 | 130 | while [ $# -ne 0 ]
|
34 | 131 | do
|
35 | 132 | case "$1" in
|
36 | 133 | -*)
|
37 |
| - shift # assume treated by homebrew options |
| 134 | + shift |
38 | 135 | ;;
|
39 | 136 |
|
40 | 137 | --*)
|
41 |
| - shift # assume treated by homebrew options |
42 |
| - shift # assume treated by homebrew options |
| 138 | + shift |
| 139 | + shift |
43 | 140 | ;;
|
44 | 141 |
|
45 | 142 | *)
|
|
48 | 145 | esac
|
49 | 146 | done
|
50 | 147 |
|
| 148 | +# --- FORMULA GENERATION --- |
51 | 149 |
|
| 150 | +BOOTSTRAP_TAP="${BOOTSTRAP_TAP:-mulle-kybernetik/software/}" |
| 151 | + |
| 152 | +DEPENDENCY_TAP="${DEPENDENCY_TAP:-${PUBLISHER_TAP}}" |
52 | 153 |
|
53 | 154 | #
|
54 |
| -# this can usually be deduced, if you follow the conventions |
| 155 | +# these can usually be deduced, if you follow the conventions |
55 | 156 | #
|
56 |
| -VERSION="`get_header_version "${HEADER}" "${VERSIONNAME}"`" |
| 157 | +if [ -z "${NAME}" ] |
| 158 | +then |
| 159 | + NAME="`get_name_from_project "${PROJECT}" "${LANGUAGE}"`" |
| 160 | +fi |
| 161 | + |
| 162 | +if [ -z "${VERSIONFILE}" ] |
| 163 | +then |
| 164 | + VERSIONFILE="`get_header_from_name "${NAME}"`" |
| 165 | +fi |
| 166 | + |
| 167 | +if [ -z "${VERSIONNAME}" ] |
| 168 | +then |
| 169 | + VERSIONNAME="`get_versionname_from_project "${PROJECT}"`" |
| 170 | +fi |
| 171 | + |
| 172 | +if [ -f VERSION ] |
| 173 | +then |
| 174 | + VERSION="`head -1 VERSION`" |
| 175 | +else |
| 176 | + VERSION="`get_project_version "${VERSIONFILE}" "${VERSIONNAME}"`" |
| 177 | + if [ -z "${VERSION}" ] |
| 178 | + then |
| 179 | + VERSION="`get_project_version "src/version.h" "${VERSIONNAME}"`" |
| 180 | + fi |
| 181 | +fi |
| 182 | + |
| 183 | +# where homebrew grabs the archive off |
| 184 | +ARCHIVE_URL="${ARCHIVE_URL:-https://github.com/${PUBLISHER}/${NAME}/archive/${VERSION}.tar.gz}" |
| 185 | + |
| 186 | +# written into formula for homebrew, will be evaled |
| 187 | +HOMEPAGE_URL="${HOMEPAGE_URL:-https://github.com/${PUBLISHER}/${NAME}}" |
| 188 | + |
| 189 | + |
| 190 | +# --- HOMEBREW TAP --- |
| 191 | +# Specify to where and under what name to publish via your brew tap |
| 192 | +# |
| 193 | +if [ -z "${PUBLISHER_TAP}" ] |
| 194 | +then |
| 195 | + fail "you need to specify a publisher tap with --publisher-tap (hint: <mulle-kybernetik/software/>)" |
| 196 | +fi |
| 197 | + |
| 198 | +TAPS_LOCATION="${TAPS_LOCATION:-..}" |
| 199 | + |
| 200 | +HOMEBREW_TAP="${HOMEBREW_TAP:-${TAPS_LOCATION}/homebrew-`basename -- ${PUBLISHER_TAP}`}" |
| 201 | + |
| 202 | +RBFILE="${RBFILE:-${NAME}.rb}" |
57 | 203 |
|
58 | 204 | # --- GIT ---
|
| 205 | + |
| 206 | +# |
| 207 | +# require PUBLISHER (and PUBLISHER_TAP) as command line parameter, so |
| 208 | +# that forks don't have to edit this constantly |
| 209 | +# |
| 210 | +if [ -z "${PUBLISHER}" ] |
| 211 | +then |
| 212 | + fail "you need to specify a publisher with --publisher (hint: https://github.com/<publisher>)" |
| 213 | +fi |
| 214 | + |
| 215 | + |
59 | 216 | # tag to tag your release
|
60 |
| -# and the origin where |
61 |
| -TAG="${TAG:-${TAGPREFIX}${VERSION}}" |
| 217 | +TAG="${TAG:-${TAG_PREFIX}${VERSION}}" |
62 | 218 |
|
| 219 | +# git remote to push to, usually origin |
| 220 | +ORIGIN="${ORIGIN:-origin}" |
63 | 221 |
|
64 |
| -# --- HOMEBREW TAP --- |
65 |
| -# Specify to where and under what bame to publish via your brew tap |
66 |
| -# |
67 |
| -RBFILE="${NAME}.rb" # ruby file for brew |
68 |
| -HOMEBREWTAP="../homebrew-`basename -- ${PUBLISHER_TAP}`" # your tap repository path |
| 222 | +# git remote to push to, usually github, can be empty |
| 223 | +GITHUB="${GITHUB:-github}" |
| 224 | + |
| 225 | +# git branch to release to, source is always current |
| 226 | +BRANCH="${BRANCH:-release}" |
69 | 227 |
|
70 | 228 |
|
71 | 229 | main()
|
72 | 230 | {
|
73 |
| - git_main "${ORIGIN}" "${TAG}" || exit 1 |
74 |
| - homebrew_main |
| 231 | + # do the release |
| 232 | + git_main "${BRANCH}" "${ORIGIN}" "${TAG}" "${GITHUB}" || exit 1 |
| 233 | + |
| 234 | + # generate the formula and push it |
| 235 | + homebrew_main "${PROJECT}" \ |
| 236 | + "${NAME}" \ |
| 237 | + "${VERSION}" \ |
| 238 | + "${DEPENDENCIES}" \ |
| 239 | + "${BUILD_DEPENDENCIES}" \ |
| 240 | + "${HOMEPAGE_URL}" \ |
| 241 | + "${DESC}" \ |
| 242 | + "${ARCHIVE_URL}" \ |
| 243 | + "${HOMEBREW_TAP}" \ |
| 244 | + "${RBFILE}" |
75 | 245 | }
|
76 | 246 |
|
77 | 247 | main "$@"
|
0 commit comments