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