| 1 |
#!/bin/sh |
| 2 |
|
| 3 |
ORIGIN_URL=$(git config --get remote.origin.url) |
| 4 |
CURRENT_BRANCH=$(git rev-parse --abbrev-ref HEAD) |
| 5 |
PACKAGE='@PACKAGE@' |
| 6 |
PACKAGE_VERSION='@PACKAGE_VERSION@' |
| 7 |
abs_srcdir='@abs_srcdir@' |
| 8 |
srcdir='@srcdir@' |
| 9 |
abs_top_builddir='@abs_top_builddir@' |
| 10 |
dist_man_MANS='lsrc.1 mkrc.1 rcdn.1 rcup.1 rcrc.5 rcm.7' |
| 11 |
|
| 12 |
# Tarball |
| 13 |
release_build_tarball() { |
| 14 |
([ -d gh-pages ] || git clone --branch gh-pages . gh-pages) && \ |
| 15 |
([ -d gh-pages/dist ] || mkdir gh-pages/dist) && \ |
| 16 |
cp $DIST_ARCHIVES gh-pages/dist && \ |
| 17 |
cd gh-pages && \ |
| 18 |
git add dist/$DIST_ARCHIVES && \ |
| 19 |
git commit -m "Release version $PACKAGE_VERSION tarball" |
| 20 |
} |
| 21 |
|
| 22 |
release_push_tarball() { |
| 23 |
cd gh-pages && \ |
| 24 |
git push |
| 25 |
} |
| 26 |
|
| 27 |
release_clean_tarball() { |
| 28 |
rm -rf gh-pages |
| 29 |
rm -rf $DIST_ARCHIVES |
| 30 |
} |
| 31 |
|
| 32 |
# Arch |
| 33 |
release_build_arch() { |
| 34 |
([ -d gh-pages ] || git clone --branch gh-pages . gh-pages) && \ |
| 35 |
([ -d gh-pages/arch ] || mkdir gh-pages/arch) && \ |
| 36 |
generate_dist_sha && \ |
| 37 |
edit_package arch/PKGBUILD.in > gh-pages/arch/PKGBUILD &&\ |
| 38 |
cd gh-pages &&\ |
| 39 |
git add arch/PKGBUILD &&\ |
| 40 |
git commit -m "Release version $PACKAGE_VERSION Arch package" |
| 41 |
} |
| 42 |
|
| 43 |
release_push_arch() { |
| 44 |
cd gh-pages && \ |
| 45 |
git push |
| 46 |
} |
| 47 |
|
| 48 |
release_clean_arch() { |
| 49 |
rm -rf gh-pages |
| 50 |
rm -rf $DIST_ARCHIVES |
| 51 |
} |
| 52 |
|
| 53 |
generate_dist_sha() { |
| 54 |
export DIST_SHA=$(openssl sha256 $srcdir/$DIST_ARCHIVES | cut -d' ' -f2) |
| 55 |
} |
| 56 |
|
| 57 |
edit_package() { |
| 58 |
sed \ |
| 59 |
-e "s|@PACKAGE[@]|$PACKAGE|g" \ |
| 60 |
-e "s|@PACKAGE_VERSION[@]|$PACKAGE_VERSION|g" \ |
| 61 |
-e "s|@DIST_ARCHIVES[@]|$DIST_ARCHIVES|g" \ |
| 62 |
-e "s|@DIST_SHA[@]|$DIST_SHA|g" \ |
| 63 |
"$1" |
| 64 |
} |
| 65 |
|
| 66 |
# Deb |
| 67 |
release_build_deb() { |
| 68 |
mkdir deb-build && \ |
| 69 |
cp ${DIST_ARCHIVES} deb-build/${PACKAGE}_${PACKAGE_VERSION}.orig.tar.gz && \ |
| 70 |
tar -C deb-build -xf deb-build/${PACKAGE}_${PACKAGE_VERSION}.orig.tar.gz && \ |
| 71 |
cp -R debian deb-build/${PACKAGE}-${PACKAGE_VERSION} && \ |
| 72 |
cd deb-build/${PACKAGE}-${PACKAGE_VERSION} && \ |
| 73 |
dch -d "New upstream release" && dch -r "" && \ |
| 74 |
debuild --prepend-path=/usr/local/bin -F && \ |
| 75 |
cd ${abs_top_builddir} && \ |
| 76 |
([ -d gh-pages ] || git clone --branch gh-pages ${ORIGIN_URL} gh-pages) && \ |
| 77 |
mkdir gh-pages/debs && \ |
| 78 |
mkdir gh-pages/deb-src && \ |
| 79 |
cp deb-build/${PACKAGE}_${PACKAGE_VERSION}*.deb gh-pages/debs && \ |
| 80 |
cp deb-build/${PACKAGE}_${PACKAGE_VERSION}*.dsc gh-pages/deb-src && \ |
| 81 |
cp deb-build/${PACKAGE}_${PACKAGE_VERSION}*.orig.tar.?z gh-pages/deb-src && \ |
| 82 |
cp deb-build/${PACKAGE}_${PACKAGE_VERSION}*.debian.tar.?z gh-pages/deb-src && \ |
| 83 |
cd gh-pages && \ |
| 84 |
git add debs/${PACKAGE}_${PACKAGE_VERSION}*deb && \ |
| 85 |
git add deb-src/${PACKAGE}_${PACKAGE_VERSION}*dsc && \ |
| 86 |
git add deb-src/${PACKAGE}_${PACKAGE_VERSION}*orig.tar.?z && \ |
| 87 |
git add deb-src/${PACKAGE}_${PACKAGE_VERSION}*debian.tar.?z && \ |
| 88 |
git commit -m "Release version ${PACKAGE_VERSION} for Debian" -- debs/${PACKAGE}_${PACKAGE_VERSION}*deb |
| 89 |
} |
| 90 |
|
| 91 |
release_push_deb() { |
| 92 |
cd gh-pages && \ |
| 93 |
git push |
| 94 |
} |
| 95 |
|
| 96 |
release_clean_deb() { |
| 97 |
rm -rf gh-pages |
| 98 |
rm -rf deb-build |
| 99 |
rm -rf $DIST_ARCHIVES |
| 100 |
} |
| 101 |
|
| 102 |
# Tag |
| 103 |
release_build_tag() { |
| 104 |
git tag -s v$PACKAGE_VERSION -m "Release $PACKAGE_VERSION" |
| 105 |
} |
| 106 |
|
| 107 |
release_push_tag() { |
| 108 |
git push origin --tags |
| 109 |
} |
| 110 |
|
| 111 |
release_clean_tag() { |
| 112 |
: |
| 113 |
} |
| 114 |
|
| 115 |
# manpages as HTML |
| 116 |
release_build_man_html() { |
| 117 |
([ -d gh-pages ] || git clone --branch gh-pages . gh-pages) && \ |
| 118 |
for i in $dist_man_MANS; do \ |
| 119 |
mandoc -Thtml -Oman=%N.%S.html man/$i > $abs_top_builddir/gh-pages/$i.html ; \ |
| 120 |
done && \ |
| 121 |
cd $abs_top_builddir/gh-pages && \ |
| 122 |
cp rcm.7.html index.html && \ |
| 123 |
git add -A && \ |
| 124 |
git commit -m "HTML documentation for $PACKAGE_VERSION" |
| 125 |
} |
| 126 |
|
| 127 |
release_push_man_html() { |
| 128 |
cd $abs_top_builddir/gh-pages && \ |
| 129 |
git push -f $ORIGIN_URL gh-pages |
| 130 |
} |
| 131 |
|
| 132 |
release_clean_man_html() { |
| 133 |
rm -rf $abs_top_builddir/gh-pages |
| 134 |
} |
| 135 |
|
| 136 |
# Main: |
| 137 |
|
| 138 |
if [ $# -lt 3 ]; then |
| 139 |
echo "Usage: release (build|push|clean) (tarball|arch|deb|tag|man_html) DIST_ARCHIVES" >&2 |
| 140 |
exit 64 |
| 141 |
fi |
| 142 |
|
| 143 |
if ! command -v git >/dev/null; then |
| 144 |
echo >&2 "release: missing dependency: git" |
| 145 |
exit 1 |
| 146 |
fi |
| 147 |
|
| 148 |
if ! command -v mandoc >/dev/null; then |
| 149 |
echo >&2 "release: missing dependency: git" |
| 150 |
exit 1 |
| 151 |
fi |
| 152 |
|
| 153 |
verb="$1" |
| 154 |
noun="$2" |
| 155 |
DIST_ARCHIVES="$3" |
| 156 |
cmd="release_${verb}_${noun}" |
| 157 |
|
| 158 |
${cmd} |