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