-
Notifications
You must be signed in to change notification settings - Fork 28
/
opam-release.sh
executable file
·60 lines (53 loc) · 1.74 KB
/
opam-release.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#!/usr/bin/env bash
set -e
# set -x
if [ -z $1 ] || [ -z $2 ] || [ -z $3 ] || [ -z $4 ] || \
[ $1 == "--help" ] || [ $1 == "-h" ]
then cat <<EOF
usage : packager GITHUBUSER PROJECT VERSION URL"
- GITHUBUSER is your github username, you must have a fork of
coq/opam-coq-archive under
https://github.com/$GITHUBUSER/opam-coq-archive
for this command to work
- VERSION is the opam version number of the package to create
- PROJECT is a name of the project, without space, it is used
solely for generating the name of the branch and PR
- URL is the url of the archive associated with the version to
release
EOF
exit 0
else
GITHUBUSER=$1
PROJECT=$2
VERSION=$3
URL=$4
fi
COA=$(mktemp -d) # stands for Coq Opam Archive
git clone --depth=10 [email protected]:coq/opam-coq-archive $COA -o upstream
git -C $COA remote add\
origin [email protected]:$GITHUBUSER/opam-coq-archive
BRANCH=$PROJECT.$VERSION
git -C $COA checkout -b $BRANCH
PKGS=$COA/released/packages
ARCHIVE=$(mktemp)
curl -L $URL -o $ARCHIVE
SUM=$(sha256sum $ARCHIVE | cut -d " " -f 1)
for opam in *.opam
do B=$(basename $opam .opam)
P=$PKGS/$B/$B.$VERSION
mkdir -p $P
sed "/^version:.*/d" $opam > $P/opam
echo "" >> $P/opam
echo "url {" >> $P/opam
echo " src: \"$URL\"" >> $P/opam
echo " checksum: \"sha256=$SUM\"" >> $P/opam
echo "}" >> $P/opam
opam lint --check-upstream $P/opam
git -C $COA add $P/opam
done
git -C $COA commit -m "Release $PROJECT $VERSION"
git -C $COA push origin -f $BRANCH
echo "**********************************************************************"
echo "Create a pull request by visiting"
echo "https://github.com/$GITHUBUSER/opam-coq-archive/pull/new/$BRANCH"
echo "**********************************************************************"