]> git.proxmox.com Git - debcargo-conf.git/blob - release.sh
update of the NEWS section
[debcargo-conf.git] / release.sh
1 #!/bin/sh
2
3 . ./vars.sh.frag
4
5 git diff --quiet --cached || \
6 abort 1 "You have other pending changes to git, please complete it or stash it away and re-run this script."
7
8 git diff --quiet -- "$PKGDIR_REL" || \
9 abort 1 "Please git-add your changes to $PKGDIR_REL before running"
10
11 RELBRANCH="pending-$PKGNAME"
12 git fetch origin --prune
13
14 if head -n1 "$PKGDIR/debian/changelog" | grep -qv UNRELEASED-FIXME-AUTOGENERATED-DEBCARGO; then
15 abort 0 "Package already released."
16 fi
17
18 PREVBRANCH="$(git rev-parse --abbrev-ref HEAD)"
19 case "$PREVBRANCH" in
20 pending-$PKGNAME) true;;
21 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";;
22 *) if git rev-parse -q --verify "refs/heads/$RELBRANCH" >/dev/null || \
23 git rev-parse -q --verify "refs/remotes/origin/$RELBRANCH" >/dev/null; then
24 git checkout "$RELBRANCH"
25 else
26 git checkout -b "$RELBRANCH"
27 fi;;
28 esac
29
30 if head -n1 "$PKGDIR/debian/changelog" | grep -qv UNRELEASED-FIXME-AUTOGENERATED-DEBCARGO; then
31 git checkout "$PREVBRANCH"
32 abort 0 "Package already released on branch $RELBRANCH. If that was a mistake then run \`git branch -D $RELBRANCH\`, and re-run this script ($0 $*)"
33 fi
34
35 ( cd "$PKGDIR"
36 sed -i -e s/UNRELEASED-FIXME-AUTOGENERATED-DEBCARGO/UNRELEASED/ debian/changelog
37 dch -r -D unstable ""
38 git add debian/changelog
39 )
40
41 rm -rf "$BUILDDIR" "$(dirname "$BUILDDIR")/rust-${PKGNAME}_$VER"*.orig.tar.*
42 $DEBCARGO package --config "$PKGCFG" --directory "$BUILDDIR" --changelog-ready "$CRATE" "$VER"
43
44 git diff --exit-code -- "$PKGDIR_REL" || \
45 abort 1 "Release attempt resulted in git diffs to $PKGDIR_REL. Check it, git add or reset as appropriate, and re-run this again."
46
47 git commit -m "Release package $PKGNAME"
48
49 ( cd "$BUILDDIR" && dpkg-buildpackage -d -S --no-sign )
50
51 cat >"$BUILDDIR/../sbuild-and-sign.sh" <<'eof'
52 #!/bin/sh
53 set -e
54
55 if [ -n "$DEBCARGO" ]; then
56 true
57 elif which debcargo >/dev/null; then
58 DEBCARGO=$(which debcargo)
59 elif [ -f "$HOME/.cargo/bin/debcargo" ]; then
60 DEBCARGO="$HOME/.cargo/bin/debcargo"
61 else
62 abort 1 "debcargo not found, run \`cargo install debcargo\` or set DEBCARGO to point to it"
63 fi
64
65 CRATE="$1"
66 VER="$2"
67 DISTRIBUTION="${DISTRIBUTION:-unstable}"
68
69 PKGNAME=$($DEBCARGO deb-src-name "$CRATE" $VER || abort 1 "couldn't find crate $CRATE")
70 DEBVER=$(dpkg-parsechangelog -l $PKGNAME/debian/changelog -SVersion)
71 DEBSRC=$(dpkg-parsechangelog -l $PKGNAME/debian/changelog -SSource)
72 DEB_HOST_ARCH=$(dpkg-architecture -q DEB_HOST_ARCH)
73
74 sbuild --no-source --arch-any --arch-all ${CHROOT:+-c $CHROOT }${DISTRIBUTION:+-d $DISTRIBUTION }${DEBSRC}_${DEBVER}.dsc
75 changestool ${DEBSRC}_${DEBVER}_${DEB_HOST_ARCH}.changes adddsc ${DEBSRC}_${DEBVER}.dsc
76 debsign ${DEBSIGN_KEYID:+-k $DEBSIGN_KEYID }--no-re-sign ${DEBSRC}_${DEBVER}_${DEB_HOST_ARCH}.changes
77 eof
78 chmod +x "$BUILDDIR/../sbuild-and-sign.sh"
79
80 DEBVER=$(dpkg-parsechangelog -l build/$PKGNAME/debian/changelog -SVersion)
81 DEBSRC=$(dpkg-parsechangelog -l build/$PKGNAME/debian/changelog -SSource)
82 DEB_HOST_ARCH=$(dpkg-architecture -q DEB_HOST_ARCH)
83 cat >&2 <<eof
84 Release of $CRATE ready as a source package in ${BUILDDIR#$PWD/}. You need to
85 perform the following steps:
86
87 Build the package if necessary, and upload
88 ==========================================
89
90 If the source package is already in Debian and this version does not introduce
91 new binaries, then you can just go ahead and directly dput the source package.
92
93 dput ${DEBSRC}_${DEBVER}_source.changes
94
95 If this is a NEW source package or introduces NEW binary packages not already
96 in the Debian archive, you will need to build a binary package out of it. The
97 recommended way is to run something like:
98
99 cd build
100 ./sbuild-and-sign.sh $CRATE $VER
101 dput ${DEBSRC}_${DEBVER}_${DEB_HOST_ARCH}.changes
102
103 See https://wiki.debian.org/sbuild for instructions on how to set it up. The
104 other tools are from the 'devscripts' package.
105
106 If the build fails e.g. due to missing Build-Dependencies you should revert
107 what I did (see below) and package those missing Build-Dependencies first.
108
109 Push this pending-release branch
110 ================================
111
112 After you have uploaded the package with dput(1), you should push $RELBRANCH so
113 that other people see it's been uploaded. Then, checkout another branch like
114 master to continue development on other packages.
115
116 git push origin $RELBRANCH && git checkout master
117
118 Merge the pending-release branch when ACCEPTED
119 ==============================================
120
121 When it's ACCEPTED by the Debian FTP masters, you may then merge this branch
122 back into the master branch, delete it, and push these updates to origin.
123
124 git checkout master && git merge $RELBRANCH && git branch -d $RELBRANCH
125 git push origin master :$RELBRANCH
126
127 ----
128
129 The above assumes you are a Debian Developer with upload rights. If not, you
130 should revert what I just did. To do that, run:
131
132 git checkout master && git branch -D $RELBRANCH
133
134 Then ask a Debian Developer to re-run me ($0 $*) on your behalf.
135 eof