]> git.proxmox.com Git - debcargo-conf.git/blame - release.sh
build.sh: don't error on source-only build
[debcargo-conf.git] / release.sh
CommitLineData
ea4bf6cd 1#!/bin/bash
931eabc0
XL
2
3. ./vars.sh.frag
4
e19e9e08
SL
5if test ! -d $PKGDIR_REL; then
6 abort 1 "Cannot find $PKGDIR_REL. Did you run ./new-package.sh before?"
7fi
8
c1621660
XL
9if test ! -f "$PKGDIR_REL/debian/changelog"; then
10 abort 1 "Cannot find $PKGDIR_REL/debian/changelog. Did you run ./new-package.sh before?"
11fi
12
e3cf5e2c 13if git grep --quiet FIXME -- "$PKGDIR_REL" :^"$PKGDIR_REL/debian/*.debcargo.hint" :^"$PKGDIR_REL/debian/changelog"; then
89c70e95
XL
14 abort 1 "FIXMEs remain in $PKGDIR_REL, fix and commit those first."
15fi
16
1230b71f
XL
17git diff --quiet --cached || \
18abort 1 "You have other pending changes to git, please complete it or stash it away and re-run this script."
19
20git diff --quiet -- "$PKGDIR_REL" || \
931eabc0
XL
21abort 1 "Please git-add your changes to $PKGDIR_REL before running"
22
1057693c
XL
23type dch >/dev/null || \
24abort 1 "Install devscripts, we need to run dch."
25
b6a1d240
XL
26RELBRANCH="pending-$PKGNAME"
27git fetch origin --prune
2de6944f 28
c75ca09f 29git merge-base --is-ancestor origin/master HEAD || \
90f3bab9 30abort 1 "You are not synced with origin/master, please do so before running this script."
1c8790a3 31
2de6944f
XL
32if head -n1 "$PKGDIR/debian/changelog" | grep -qv UNRELEASED-FIXME-AUTOGENERATED-DEBCARGO; then
33 abort 0 "Package already released."
34fi
35
e1a9d897
XL
36if [ -e "$PKGDIR/debian/BLOCK" ]; then
37 abort 1 "TODO items remain in $PKGDIR/debian/BLOCK, please deal with those"
38fi
39
32c1fb5b
XL
40PREVBRANCH="$(git rev-parse --abbrev-ref HEAD)"
41case "$PREVBRANCH" in
b6a1d240
XL
42pending-$PKGNAME) true;;
43pending-*) abort 1 "You are on a pending-release branch for a package other than $PKGNAME, $0 can only be run on another branch, like master";;
44*) if git rev-parse -q --verify "refs/heads/$RELBRANCH" >/dev/null || \
45 git rev-parse -q --verify "refs/remotes/origin/$RELBRANCH" >/dev/null; then
46 git checkout "$RELBRANCH"
47 else
48 git checkout -b "$RELBRANCH"
49 fi;;
50esac
51
52if head -n1 "$PKGDIR/debian/changelog" | grep -qv UNRELEASED-FIXME-AUTOGENERATED-DEBCARGO; then
32c1fb5b 53 git checkout "$PREVBRANCH"
c6709bfe
XL
54 abort 0 "Package already released on branch $RELBRANCH. If that was a mistake then run:" \
55 " git branch -D $RELBRANCH" \
56 "And re-run this script ($0 $*). You might have to delete the remote branch too:" \
57 " git push --delete origin $RELBRANCH"
b6a1d240 58fi
1230b71f 59
931eabc0
XL
60( cd "$PKGDIR"
61sed -i -e s/UNRELEASED-FIXME-AUTOGENERATED-DEBCARGO/UNRELEASED/ debian/changelog
699de4ac
SL
62if test -z "$DISTRO"; then
63 # To upload to other distro like experimental
64 DISTRO=unstable
65fi
66dch -m -r -D $DISTRO ""
931eabc0 67git add debian/changelog
d30bb8e0 68git rm --ignore-unmatch debian/RFS
931eabc0
XL
69)
70
cc003c95 71revert_git_changes() {
8c0b9df4 72 git reset --merge
d30bb8e0
AS
73 git checkout -- "$PKGDIR/debian/changelog"
74 git checkout -q -- "$PKGDIR/debian/RFS" || true
e185876a
XL
75 git checkout "$PREVBRANCH"
76 git branch -d "$RELBRANCH"
cc003c95
XL
77}
78
79if ! run_debcargo --changelog-ready; then
80 revert_git_changes
81 abort 1 "Release attempt failed to run debcargo, probably the package needs updating (./update.sh $*)"
82fi
83
84if ! git diff --exit-code -- "$PKGDIR_REL"; then
85 revert_git_changes
e185876a
XL
86 abort 1 "Release attempt resulted in git diffs to $PKGDIR_REL, probably the package needs updating (./update.sh $*)"
87fi
931eabc0 88
1057693c 89if ! ( cd build && SOURCEONLY=1 ./build.sh "$CRATE" $VER ); then
cc003c95 90 revert_git_changes
98cad301
XL
91 abort 1 "Release attempt failed (see messages above), possible reasons are: " \
92 "- build-dependencies not in Debian => release those first." \
93 "- packaged version is out-of-date => run \`./update.sh $*\`"
cc003c95
XL
94fi
95
999f9269 96git commit -m "Release package $PKGNAME"
931eabc0 97
1057693c
XL
98DEBVER=$(dpkg-parsechangelog -l $BUILDDIR/debian/changelog -SVersion)
99DEBSRC=$(dpkg-parsechangelog -l $BUILDDIR/debian/changelog -SSource)
550dd343 100DEB_HOST_ARCH=$(dpkg-architecture -q DEB_HOST_ARCH)
1230b71f 101cat >&2 <<eof
b6a1d240
XL
102Release of $CRATE ready as a source package in ${BUILDDIR#$PWD/}. You need to
103perform the following steps:
104
105Build the package if necessary, and upload
106==========================================
1230b71f
XL
107
108If the source package is already in Debian and this version does not introduce
109new binaries, then you can just go ahead and directly dput the source package.
110
1057693c 111 cd build && dput ${DEBSRC}_${DEBVER}_source.changes
b6a1d240 112
79000db2 113For your reference, this source package builds $(grep ^Package build/${CRATE//_/-}/debian/control | wc -l) binary package(s).
f52ac044 114
1230b71f
XL
115If this is a NEW source package or introduces NEW binary packages not already
116in the Debian archive, you will need to build a binary package out of it. The
117recommended way is to run something like:
118
1057693c 119 cd build && ./build.sh $CRATE $VER && dput ${DEBSRC}_${DEBVER}_${DEB_HOST_ARCH}.changes
1230b71f 120
c6709bfe
XL
121This assumes you followed the "Build environment" instructions in README.rst,
122for setting up a build environment for release.
1230b71f 123
db9d5fab
XL
124If the build fails e.g. due to missing Build-Dependencies you should revert
125what I did (see below) and package those missing Build-Dependencies first.
126
b6a1d240
XL
127Push this pending-release branch
128================================
129
130After you have uploaded the package with dput(1), you should push $RELBRANCH so
131that other people see it's been uploaded. Then, checkout another branch like
132master to continue development on other packages.
133
ea8e55fe 134 git push origin $RELBRANCH && git checkout master
b6a1d240
XL
135
136Merge the pending-release branch when ACCEPTED
137==============================================
138
139When it's ACCEPTED by the Debian FTP masters, you may then merge this branch
140back into the master branch, delete it, and push these updates to origin.
141
ea8e55fe
XL
142 git checkout master && git merge $RELBRANCH && git branch -d $RELBRANCH
143 git push origin master :$RELBRANCH
b6a1d240
XL
144
145----
146
147The above assumes you are a Debian Developer with upload rights. If not, you
a957cf62 148should revert what I just did. To do that, run:
b6a1d240 149
ea8e55fe 150 git checkout master && git branch -D $RELBRANCH
b6a1d240 151
680a635e
XL
152Then ask a Debian Developer to re-run me ($0 $*) on your behalf. Also touch
153and commit ${PKGDIR_REL}/debian/RFS so it's easy to track.
1230b71f 154eof