]> git.proxmox.com Git - debcargo-conf.git/blame - release.sh
thiserror-impl: new version
[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
baae6f7c
XL
32if [ "$RERELEASE" = 1 -o "$NOUPDATE" = 1 ]; then
33 REALVER="$(get_existing_version "$PKGDIR")"
34fi
35
2de6944f 36if head -n1 "$PKGDIR/debian/changelog" | grep -qv UNRELEASED-FIXME-AUTOGENERATED-DEBCARGO; then
baae6f7c
XL
37 if [ "$RERELEASE" = 1 ]; then
38 run_debcargo
39 ( cd "$PKGDIR" && dch -a "No-op source-only re-upload for Debian Testing Migration." )
30bf7f25 40 export REUSE_EXISTING_ORIG_TARBALL=1
baae6f7c
XL
41 else
42 abort 0 \
43 "Package already released. If you want to do a source-only re-upload e.g. to" \
44 "hoop-jump through the Debian Testing migration requirements, set RERELEASE=1."
45 fi
2de6944f
XL
46fi
47
e1a9d897
XL
48if [ -e "$PKGDIR/debian/BLOCK" ]; then
49 abort 1 "TODO items remain in $PKGDIR/debian/BLOCK, please deal with those"
50fi
51
32c1fb5b
XL
52PREVBRANCH="$(git rev-parse --abbrev-ref HEAD)"
53case "$PREVBRANCH" in
b6a1d240
XL
54pending-$PKGNAME) true;;
55pending-*) 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";;
56*) if git rev-parse -q --verify "refs/heads/$RELBRANCH" >/dev/null || \
57 git rev-parse -q --verify "refs/remotes/origin/$RELBRANCH" >/dev/null; then
58 git checkout "$RELBRANCH"
59 else
60 git checkout -b "$RELBRANCH"
61 fi;;
62esac
63
64if head -n1 "$PKGDIR/debian/changelog" | grep -qv UNRELEASED-FIXME-AUTOGENERATED-DEBCARGO; then
32c1fb5b 65 git checkout "$PREVBRANCH"
c6709bfe
XL
66 abort 0 "Package already released on branch $RELBRANCH. If that was a mistake then run:" \
67 " git branch -D $RELBRANCH" \
68 "And re-run this script ($0 $*). You might have to delete the remote branch too:" \
69 " git push --delete origin $RELBRANCH"
b6a1d240 70fi
1230b71f 71
931eabc0
XL
72( cd "$PKGDIR"
73sed -i -e s/UNRELEASED-FIXME-AUTOGENERATED-DEBCARGO/UNRELEASED/ debian/changelog
699de4ac
SL
74if test -z "$DISTRO"; then
75 # To upload to other distro like experimental
76 DISTRO=unstable
77fi
78dch -m -r -D $DISTRO ""
931eabc0 79git add debian/changelog
d30bb8e0 80git rm --ignore-unmatch debian/RFS
931eabc0
XL
81)
82
cc003c95 83revert_git_changes() {
8c0b9df4 84 git reset --merge
d30bb8e0
AS
85 git checkout -- "$PKGDIR/debian/changelog"
86 git checkout -q -- "$PKGDIR/debian/RFS" || true
e185876a
XL
87 git checkout "$PREVBRANCH"
88 git branch -d "$RELBRANCH"
cc003c95
XL
89}
90
91if ! run_debcargo --changelog-ready; then
92 revert_git_changes
93 abort 1 "Release attempt failed to run debcargo, probably the package needs updating (./update.sh $*)"
94fi
95
30bf7f25
XL
96# sometimes the copyright years need to be updated, try to do this automatically
97if git diff -- "$PKGDIR_REL/debian/copyright.debcargo.hint" | patch -r - --no-backup-if-mismatch "$PKGDIR_REL/debian/copyright"; then
98 git add "$PKGDIR_REL/debian/copyright.debcargo.hint" "$PKGDIR_REL/debian/copyright"
99else
100 git diff -- "$PKGDIR_REL/debian/copyright.debcargo.hint"
101 revert_git_changes
102 abort 1 \
103 "copyright file needs updating; apply the above diff to $PKGDIR_REL/debian/copyright" \
104 "then commit your changes, and run me again."
105fi
106
cc003c95
XL
107if ! git diff --exit-code -- "$PKGDIR_REL"; then
108 revert_git_changes
baae6f7c
XL
109 abort 1 \
110 "Release attempt resulted in git diffs to $PKGDIR_REL, probably you need to update the package (./update.sh $*)." \
111 "Alternatively, set NOUPDATE=1 to override this requirement, but please have a good reason."
e185876a 112fi
931eabc0 113
1057693c 114if ! ( cd build && SOURCEONLY=1 ./build.sh "$CRATE" $VER ); then
cc003c95 115 revert_git_changes
98cad301
XL
116 abort 1 "Release attempt failed (see messages above), possible reasons are: " \
117 "- build-dependencies not in Debian => release those first." \
118 "- packaged version is out-of-date => run \`./update.sh $*\`"
cc003c95
XL
119fi
120
999f9269 121git commit -m "Release package $PKGNAME"
931eabc0 122
1057693c
XL
123DEBVER=$(dpkg-parsechangelog -l $BUILDDIR/debian/changelog -SVersion)
124DEBSRC=$(dpkg-parsechangelog -l $BUILDDIR/debian/changelog -SSource)
550dd343 125DEB_HOST_ARCH=$(dpkg-architecture -q DEB_HOST_ARCH)
b6a1d240 126
baae6f7c 127if [ "$RERELEASE" = 1 ]; then
baae6f7c 128
508cd1b3
XL
129( cd build && dput "${DEBSRC}_${DEBVER}_source.changes" )
130git push origin "$RELBRANCH"
131git checkout master
baae6f7c 132
508cd1b3
XL
133cat <<eof
134Source-only re-release of $CRATE uploaded. You need to perform the following steps:
9550b9b4 135
baae6f7c 136eof
508cd1b3 137
baae6f7c 138else
508cd1b3 139
baae6f7c 140cat <<eof
508cd1b3
XL
141Release of $CRATE ready as a source package in ${BUILDDIR#$PWD/}. You need to
142perform the following steps:
143
b6a1d240
XL
144Build the package if necessary, and upload
145==========================================
1230b71f
XL
146
147If the source package is already in Debian and this version does not introduce
148new binaries, then you can just go ahead and directly dput the source package.
149
1057693c 150 cd build && dput ${DEBSRC}_${DEBVER}_source.changes
b6a1d240 151
baae6f7c
XL
152For your reference, this source package builds $(grep ^Package build/${CRATE//_/-}/debian/control | wc -l) binary package(s):
153$(sed -ne 's/^Package: //pg' build/hmac/debian/control | tr '\n' ',')
f52ac044 154
1230b71f
XL
155If this is a NEW source package or introduces NEW binary packages not already
156in the Debian archive, you will need to build a binary package out of it. The
157recommended way is to run something like:
158
1057693c 159 cd build && ./build.sh $CRATE $VER && dput ${DEBSRC}_${DEBVER}_${DEB_HOST_ARCH}.changes
1230b71f 160
c6709bfe
XL
161This assumes you followed the "Build environment" instructions in README.rst,
162for setting up a build environment for release.
1230b71f 163
db9d5fab
XL
164If the build fails e.g. due to missing Build-Dependencies you should revert
165what I did (see below) and package those missing Build-Dependencies first.
166
b6a1d240
XL
167Push this pending-release branch
168================================
169
170After you have uploaded the package with dput(1), you should push $RELBRANCH so
171that other people see it's been uploaded. Then, checkout another branch like
172master to continue development on other packages.
173
ea8e55fe 174 git push origin $RELBRANCH && git checkout master
b6a1d240 175
508cd1b3
XL
176eof
177
178fi
179
180cat >&2 <<eof
baae6f7c
XL
181Merge the pending-release branch if/when ACCEPTED
182=================================================
b6a1d240
XL
183
184When it's ACCEPTED by the Debian FTP masters, you may then merge this branch
185back into the master branch, delete it, and push these updates to origin.
186
ea8e55fe
XL
187 git checkout master && git merge $RELBRANCH && git branch -d $RELBRANCH
188 git push origin master :$RELBRANCH
b6a1d240 189
baae6f7c
XL
190Delete this branch without merging if/when REJECTED
191===================================================
b6a1d240 192
baae6f7c
XL
193If your upload is REJECTED, or if you cannot perform an upload in the first
194place e.g. because you are not a Debian Developer, you should revert what I
195just did. To do that, run:
b6a1d240 196
ea8e55fe 197 git checkout master && git branch -D $RELBRANCH
b6a1d240 198
baae6f7c
XL
199Then ask a Debian Developer to re-run me ($0 $*) on your behalf. Also, touch
200and commit ${PKGDIR_REL}/debian/RFS so we can track these easier.
1230b71f 201eof