6c9c7e6
#!/bin/bash
6c9c7e6
6c9c7e6
NAME=$(basename $PWD)
6c9c7e6
OWNER=$(sed   -n '/^%global gh_owner/{s/.* //;p}'   $NAME.spec)
6c9c7e6
PROJECT=$(sed -n '/^%global gh_project/{s/.* //;p}' $NAME.spec)
6c9c7e6
VERSION=$(sed -n '/^Version:/{s/.* //;p}'           $NAME.spec)
6c9c7e6
COMMIT=$(sed  -n '/^%global gh_commit/{s/.* //;p}'  $NAME.spec)
6c9c7e6
SHORT=${COMMIT:0:7}
6c9c7e6
6c9c7e6
echo -e "\nCreate git snapshot\nName=$NAME, Owner=$OWNER, Project=$PROJECT, Version=$VERSION\n"
6c9c7e6
6c9c7e6
echo "Cloning..."
6c9c7e6
rm -rf $PROJECT-$COMMIT
6c9c7e6
git clone https://github.com/$OWNER/$PROJECT.git $PROJECT-$COMMIT
6c9c7e6
6c9c7e6
echo "Getting commit..."
6c9c7e6
pushd $PROJECT-$COMMIT
6c9c7e6
git checkout $COMMIT
6c9c7e6
cp composer.json ../composer-$VERSION.json
6c9c7e6
popd
6c9c7e6
6c9c7e6
echo "Archiving..."
6c9c7e6
tar czf $NAME-$VERSION-$SHORT.tgz --exclude .git $PROJECT-$COMMIT
6c9c7e6
6c9c7e6
echo "Cleaning..."
6c9c7e6
rm -rf $PROJECT-$COMMIT
6c9c7e6
6c9c7e6
echo "Done."