1
0
mirror of https://github.com/danog/psalm.git synced 2024-11-27 12:55:26 +01:00
psalm/bin/github-deploy-phar.sh
Bruce Weirdan 62e7e7f470
Reorganize pushes to psalm/phar
Previously we built phar and pushed it:

 1. To `psalm/phar:master` (always)
 2. To `psalm/phar:$tag` (for tagged releases)

However it's entirely possible to tag branches that diverged from master
(like when we do a patch release for a legacy version). In this case our
push to `psalm/phar:master` was rejected and script failed. As a result,
`psalm/phar` was missing the tag (release).

Now we will either:
 * push to `psalm/phar:master` (if the build was for `vimeo/psalm:master`)
 * or push to `psalm/phar:$tag` (if it's a tagged release)
2023-02-24 21:47:11 -04:00

42 lines
1.0 KiB
Bash
Executable File

#!/usr/bin/env bash
set -e
if [[ ${GITHUB_REPOSITORY} != 'vimeo/psalm' && -z ${PHAR_REPO_SLUG} ]]; then
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}
git clone https://${PHAR_REPO_TOKEN}@github.com/${PHAR_REPO_SLUG}.git phar > /dev/null 2>&1
set -x # don't do set x above this point to protect the GITHUB_TOKEN
cd phar
rm -rf *
cp ../build/psalm.phar ../assets/psalm-phar/* .
cp ../build/psalm.phar.asc . || true # not all users have GPG keys
mv dot-gitignore .gitignore
git config user.email "github@muglug.com"
git config user.name "Automated commit"
git add --all .
git commit -m "Updated Psalm phar to commit ${GITHUB_SHA}"
tag=${GITHUB_REF/refs\/heads\//}
tag=${tag/refs\/tags\//}
if [[ "$tag" != 'master' ]] ; then
git tag "$tag"
fi
# 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"