avoid the admin being kicked out after upgrade (#1033) #45
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build Release | |
on: | |
push: | |
tags: v[1-9]+.[0-9]+.* | |
jobs: | |
test: | |
runs-on: ubuntu-22.04 | |
continue-on-error: ${{ matrix.experimental }} | |
strategy: | |
fail-fast: false | |
matrix: | |
php-version: ['8.2'] | |
experimental: [false] | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Find the version | |
run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/v}" >> $GITHUB_ENV | |
- name: Show the discovered version | |
run: | | |
if [[ ! -z "${{ secrets.BUILD_TEST }}" ]]; then | |
echo "RELEASE_VERSION=build-testing-RC1" >> $GITHUB_ENV | |
fi | |
echo \$RELEASE_VERSION = $RELEASE_VERSION | |
echo \$\{\{ env.RELEASE_VERSION \}\} = ${{ env.RELEASE_VERSION }} | |
echo \$GITHUB_REF = $GITHUB_REF | |
- name: Set up PHP ${{ matrix.php-version }} | |
uses: shivammathur/setup-php@v2 | |
with: | |
php-version: ${{ matrix.php-version }} | |
- name: Setup Packages | |
run: | | |
cd $GITHUB_WORKSPACE | |
sudo apt update && sudo apt install -y rsync | |
- name: Cache Composer dependencies | |
uses: actions/cache@v2 | |
with: | |
path: /tmp/composer-cache | |
key: ${{ matrix.php-version }}-${{ env.RELEASE_VERSION }}-${{ hashFiles('**/composer.lock') }} | |
- name: Install dependencies | |
uses: php-actions/composer@v5 | |
with: | |
dev: yes | |
args: --prefer-dist --no-interaction | |
php_version: ${{ matrix.php-version }} | |
php_extensions: xml | |
version: 2 | |
- name: Install Plugins and Themes | |
run: | | |
cd $GITHUB_WORKSPACE | |
./scripts/install-plugins.sh vendor public_html/lists/admin/plugins/ | |
./scripts/install-themes.sh vendor public_html/lists/admin/ui/ | |
- name: Install the phpList4 based REST API | |
run: | | |
cd $GITHUB_WORKSPACE | |
cd public_html/lists | |
wget https://github.com/phpList/base-distribution/archive/refs/heads/phplist3.zip | |
unzip phplist3.zip | |
rm phplist3.zip | |
mv base-distribution-phplist3 base | |
cd base | |
composer update --no-dev | |
- name: Create Database | |
run: | | |
sudo systemctl start mysql.service | |
sudo mysql -proot -e 'drop database if exists phplistdb' | |
sudo mysqladmin -proot create phplistdb | |
sudo mysql -proot -e 'create user phplist@"%" identified by "phplist"; grant all on phplistdb.* to phplist@"%"' | |
- name: Start Test Server | |
run: | | |
cd $GITHUB_WORKSPACE | |
cp -fv tests/ci/behat.yml tests/behat.yml | |
cp -fv tests/ci/config.php public_html/lists/config/config.php | |
mkdir -p output/screenshots | |
mkdir -p build/mails | |
./bin/start-selenium > output/selenium.log 2>&1 & | |
sleep 5 | |
sudo php -S 0.0.0.0:80 -t public_html > /dev/null 2>&1 & | |
- name: Check PHP syntax errors | |
uses: overtrue/[email protected] | |
with: | |
path: ./public_html | |
options: --exclude=base/vendor | |
- name: Report Versions | |
run: | | |
google-chrome --version | |
php -v | |
chromedriver -v | |
geckodriver -V | |
which geckodriver | |
which chromedriver | |
which rsync | |
rsync --version | |
firefox -v | |
which sftp | |
which sshpass | |
vendor/bin/behat -V | |
- name: Run Behat Tests | |
run: | | |
cd $GITHUB_WORKSPACE/tests | |
../vendor/bin/behat -n -fprogress -p chrome --strict --stop-on-failure --tags=@initialise | |
../vendor/bin/behat -n -fprogress -p chrome --strict --stop-on-failure --tags="~@initialise && ~@wip" | |
- name: Upload the screenshots | |
if: always() | |
uses: actions/upload-artifact@v2 | |
with: | |
path: "output" | |
name: "behat output" | |
retention-days: 3 | |
- name: Clean Up | |
run: | | |
cd $GITHUB_WORKSPACE | |
cd .. | |
mv phplist3 phplist-$RELEASE_VERSION | |
sudo find . -type d -exec chmod 755 {} \; | |
sudo find . -type f -exec chmod 644 {} \; | |
cd phplist-$RELEASE_VERSION | |
chmod 777 public_html/lists/admin/plugins | |
cat public_html/lists/admin/init.php | tr '\n' '\r' | sed 's~//## remove on rollout.*//## end remove on rollout ###~define("VERSION","'${RELEASE_VERSION}'");~' | tr '\r' '\n' > /tmp/$$.init | |
mv -f /tmp/$$.init public_html/lists/admin/init.php | |
sed -i s~define\(\'STRUCTUREVERSION\'.*~define\(\'STRUCTUREVERSION\',\"${RELEASE_VERSION}\"\)\;~ public_html/lists/admin/structure.php | |
sed -i s/^VERSION=.*/VERSION=${RELEASE_VERSION}/ VERSION | |
cd .. | |
zip -rq9 phplist-${RELEASE_VERSION}.zip phplist-${RELEASE_VERSION} | |
tar cf phplist-${RELEASE_VERSION}.tar phplist-${RELEASE_VERSION} | |
remove=( | |
default.behat.yml | |
TESTING.md | |
.dotgitlab-ci.yml | |
.travis.yml | |
composer.json | |
composer.lock | |
.git | |
.github | |
.php_cs | |
.gitmodules | |
Dockerfile | |
Vagrantfile | |
.styleci.yml | |
.gitignore | |
.gitsvnextmodules | |
tests | |
output.log | |
output | |
build | |
.phplist-cache | |
docker_tag | |
vendor | |
public_html/lists/admin/tests | |
scripts | |
bin/start-selenium | |
bin/fake-sendmail.sh | |
bin/imgur-uploader.sh | |
public_html/lists/base/tests | |
public_html/lists/base/.htaccess | |
public_html/lists/base/phpunit.xml.dist | |
public_html/lists/base/composer.lock | |
public_html/lists/base/CODE_OF_CONDUCT.md | |
public_html/lists/admin/ui/default | |
) | |
for item in ${remove[@]}; do | |
[[ -f phplist-$RELEASE_VERSION/$item ]] && { | |
tar -vf phplist-${RELEASE_VERSION}.tar --delete phplist-$RELEASE_VERSION/$item | |
zip -d phplist-${RELEASE_VERSION}.zip phplist-$RELEASE_VERSION/$item | |
} | |
[[ -d phplist-$RELEASE_VERSION/$item ]] && { | |
tar -vf phplist-${RELEASE_VERSION}.tar --delete phplist-$RELEASE_VERSION/$item | |
zip -d phplist-${RELEASE_VERSION}.zip phplist-$RELEASE_VERSION/$item/\* | |
} | |
done | |
gzip phplist-${RELEASE_VERSION}.tar | |
mv phplist-${RELEASE_VERSION}.tar.gz phplist-${RELEASE_VERSION}.tgz | |
md5sum phplist-${RELEASE_VERSION}.* > phplist-${RELEASE_VERSION}.md5 | |
sha256sum phplist-${RELEASE_VERSION}.* > phplist-${RELEASE_VERSION}.sha256 | |
sha1sum phplist-${RELEASE_VERSION}.* > phplist-${RELEASE_VERSION}.sha1 | |
ls -l | |
## move the files for use in Docker build | |
mv phplist-$RELEASE_VERSION phplist3 | |
cd $GITHUB_WORKSPACE | |
cp ../phplist-${RELEASE_VERSION}.tgz . | |
- name: Set up S3cmd cli tool | |
uses: s3-actions/[email protected] | |
with: | |
provider: aws | |
region: 'us-east-1' | |
access_key: ${{ secrets.AWS_KEY_ID }} | |
secret_key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
- name: Upload the files to S3 | |
run: | | |
cd .. | |
s3cmd put phplist-${RELEASE_VERSION}.* s3://${{ secrets.AWS_S3_VERSIONS_BUCKET }}/ | |
s3cmd put phplist3/public_html/lists/admin/images/power-phplist.png s3://${{ secrets.AWS_S3_POWERED_BUCKET }}/images/${RELEASE_VERSION}/ | |
- name: Upload the package as artifact | |
if: always() | |
uses: actions/upload-artifact@v2 | |
with: | |
path: "phplist-*.tgz" | |
name: "phpList Release File" | |
retention-days: 3 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v1 | |
- name: Login to DockerHub | |
uses: docker/login-action@v1 | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
- name: Build and push | |
id: docker_build | |
uses: docker/build-push-action@v2 | |
with: | |
context: . | |
push: true | |
no-cache: true | |
file: Dockerfile.release | |
tags: ${{ secrets.DOCKERHUB_REPO }}/${{ secrets.DOCKERHUB_IMAGE }}:${{ env.RELEASE_VERSION }} | |
build-args: | | |
VERSION=${{ env.RELEASE_VERSION }} | |
- name: Upload the files to SF | |
run: | | |
export SSHPASS=${{ secrets.SF_PASS }} | |
if [[ $RELEASE_VERSION =~ "-RC" ]]; then | |
RELEASE_FOLDER=phplist-development | |
else | |
RELEASE_FOLDER=phplist | |
fi | |
echo "${{ secrets.SF_HOSTKEY }}" >> ~/.ssh/known_hosts | |
cd $GITHUB_WORKSPACE | |
cd .. | |
sshpass -e sftp -oBatchMode=no -b - ${{ secrets.SF_USERNAME }}@${{ secrets.SF_HOST }} << EOF | |
cd /home/frs/project/phplist/$RELEASE_FOLDER | |
mkdir $RELEASE_VERSION | |
cd $RELEASE_VERSION | |
put phplist-${RELEASE_VERSION}.* | |
ls -l | |
bye | |
EOF |