2019-06-01 19:51:33 +03:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
2019-06-06 23:25:43 +01:00
|
|
|
set -e
|
|
|
|
|
2019-06-07 22:58:23 +01:00
|
|
|
|
2021-02-11 13:45:04 -05:00
|
|
|
if [[ ${GITHUB_REPOSITORY} != 'vimeo/psalm' && -z ${PHAR_REPO_SLUG} ]]; then
|
2019-06-07 22:58:23 +01:00
|
|
|
echo 'Not attempting phar deployment, as this is not vimeo/psalm, and $PHAR_REPO_SLUG is unset or empty'
|
|
|
|
exit 0;
|
|
|
|
fi;
|
|
|
|
|
|
|
|
PHAR_REPO_SLUG=${PHAR_REPO_SLUG:=psalm/phar}
|
|
|
|
|
2021-02-11 13:45:04 -05:00
|
|
|
git clone https://${PHAR_REPO_TOKEN}@github.com/${PHAR_REPO_SLUG}.git phar > /dev/null 2>&1
|
2019-06-07 22:58:23 +01:00
|
|
|
|
|
|
|
set -x # don't do set x above this point to protect the GITHUB_TOKEN
|
|
|
|
|
2019-03-25 13:40:17 -04:00
|
|
|
cd phar
|
2019-06-07 13:18:58 +01:00
|
|
|
rm -rf *
|
2019-06-07 22:58:23 +01:00
|
|
|
cp ../build/psalm.phar ../assets/psalm-phar/* .
|
2021-03-02 05:49:52 +02:00
|
|
|
cp ../build/psalm.phar.asc . || true # not all users have GPG keys
|
2019-06-06 23:12:53 +01:00
|
|
|
mv dot-gitignore .gitignore
|
2021-02-11 13:45:04 -05:00
|
|
|
git config user.email "github@muglug.com"
|
|
|
|
git config user.name "Automated commit"
|
2019-06-06 23:12:53 +01:00
|
|
|
git add --all .
|
2021-02-11 13:45:04 -05:00
|
|
|
git commit -m "Updated Psalm phar to commit ${GITHUB_SHA}"
|
2019-06-01 17:25:26 +03:00
|
|
|
|
2021-02-13 16:45:13 -05:00
|
|
|
tag=${GITHUB_REF/refs\/heads\//}
|
2021-08-09 03:08:34 +03:00
|
|
|
tag=${tag/refs\/tags\//}
|
2021-02-13 16:45:13 -05:00
|
|
|
|
|
|
|
if [[ "$tag" != 'master' ]] ; then
|
|
|
|
git tag "$tag"
|
2019-06-01 17:25:26 +03:00
|
|
|
fi
|
2023-02-24 21:47:11 -04:00
|
|
|
|
|
|
|
# this script runs on:
|
|
|
|
# 1. pushes to master
|
|
|
|
# 2. publishing releases
|
|
|
|
#
|
|
|
|
# So we push master to psalm/phar:master
|
|
|
|
# and tags to psalm/phar:$tag
|
|
|
|
|
|
|
|
git push origin "$tag"
|