Add deployment scripts

This commit is contained in:
Alexey Andreev 2021-03-10 11:05:49 +03:00
parent 431e9f0c81
commit 7598a3c1f6
9 changed files with 172 additions and 92 deletions

3
.gitignore vendored
View File

@ -1,5 +1,8 @@
# output dir # output dir
target target
/build-dir
/build-cache
/deploy-with-env.sh
# KDE # KDE
.directory .directory

View File

@ -1,57 +0,0 @@
language: java
sudo: false
addons:
chrome: stable
jdk:
- oraclejdk11
cache:
directories:
- $HOME/mvn_repo
- $HOME/.node_modules
branches:
only:
- master
- travis
- /^release-.+$/
- /^dev-.+/
before_install:
- export MVN_CMD="mvn -Dmaven.repo.local=$HOME/mvn_repo -B"
- OLD_VERSION=`$MVN_CMD help:evaluate -Dexpression=project.version 2>/dev/null | grep -Ev "(^\[|Download)"`
- BASE_VERSION=${OLD_VERSION%-SNAPSHOT}
- NEW_VERSION=${BASE_VERSION}-dev-`printf %d $TRAVIS_BUILD_NUMBER`
- ECLIPSE_VERSION=${BASE_VERSION}.dev_`printf %d $TRAVIS_BUILD_NUMBER`
- export NEW_VERSION
- export ECLIPSE_VERSION
- export BASE_VERSION
- echo "Building version $NEW_VERSION"
- ./set-version.sh $NEW_VERSION $ECLIPSE_VERSION
- rm -rf $HOME/.phpenv
- rm -rf $HOME/.rvm
- rm -rf $HOME/.m2
script:
- $MVN_CMD -e install -Dteavm.junit.optimized=false -Dteavm.junit.js.decodeStack=false -P with-idea -P with-cli -Dteavm.junit.threads=2 -Dteavm.junit.js.runner=browser-chrome -V
- rm -rf $BASE_PATH/tests/target/js-tests
- rm -rf $BASE_PATH/html4j/target/js-tests
- du -sh $HOME/.[!.]* /home/travis/* | sort -h
- df
after_success: >
if [[ "${TRAVIS_PULL_REQUEST:-unknown}" == "false" && $TRAVIS_BRANCH == dev-* ]] ; then
export NEW_VERSION
export FTP_HOST
export FTP_PORT
export FTP_USER
export FTP_PATH
export SSH_KEY
mv -f $HOME/built_artifacts_backup $HOME/mvn_repo/org/teavm
$MVN_CMD deploy -Dteavm.build.all=false -DskipTests --settings travis-settings.xml \
-P deploy-to-bintray -P with-idea -P with-cli -P !download-dependencies && \
./upload-files.sh
fi
before_cache:
- mv -f $HOME/mvn_repo/org/teavm $HOME/built_artifacts_backup

View File

@ -1,9 +1,8 @@
TeaVM TeaVM
===== =====
[![Build Status](https://travis-ci.org/konsoletyper/teavm.svg?branch=master)](https://travis-ci.org/konsoletyper/teavm)
[![Maven Central](https://maven-badges.herokuapp.com/maven-central/org.teavm/teavm-maven-plugin/badge.svg)](https://maven-badges.herokuapp.com/maven-central/org.teavm/teavm-maven-plugin) [![Maven Central](https://maven-badges.herokuapp.com/maven-central/org.teavm/teavm-maven-plugin/badge.svg)](https://maven-badges.herokuapp.com/maven-central/org.teavm/teavm-maven-plugin)
[![Bintray](https://api.bintray.com/packages/konsoletyper/teavm/teavm-dev/images/download.svg)](https://bintray.com/konsoletyper/teavm/teavm-dev/_latestVersion) [![Download](https://teavm.org/maven/badge.svg)](https://teavm.org/maven/_latest)
[![Gitter chat](https://img.shields.io/badge/gitter-join%20chat-green.svg)](https://gitter.im/teavm/Lobby) [![Gitter chat](https://img.shields.io/badge/gitter-join%20chat-green.svg)](https://gitter.im/teavm/Lobby)
[![Code Quality: Java](https://img.shields.io/lgtm/grade/java/g/konsoletyper/teavm.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/konsoletyper/teavm/context:java) [![Code Quality: Java](https://img.shields.io/lgtm/grade/java/g/konsoletyper/teavm.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/konsoletyper/teavm/context:java)
[![Total Alerts](https://img.shields.io/lgtm/alerts/g/konsoletyper/teavm.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/konsoletyper/teavm/alerts) [![Total Alerts](https://img.shields.io/lgtm/alerts/g/konsoletyper/teavm.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/konsoletyper/teavm/alerts)

34
build-all.sh Executable file
View File

@ -0,0 +1,34 @@
#
# Copyright 2021 Alexey Andreev.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
if [[ ! -d build-dir ]] ; then
mkdir build-dir
fi
git archive master | tar -x -C build-dir
pushd build-dir
mvn -e -V install \
-P with-idea -P with-cli \
-Dteavm.junit.optimized=false \
-Dteavm.junit.js.decodeStack=false \
-Dteavm.junit.threads=4 \
-Dteavm.junit.js.runner=browser-chrome
rm -rf *
popd

View File

@ -1,5 +1,5 @@
<!-- <!--
~ Copyright 2017 Alexey Andreev. ~ Copyright 2021 Alexey Andreev.
~ ~
~ Licensed under the Apache License, Version 2.0 (the "License"); ~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License. ~ you may not use this file except in compliance with the License.
@ -20,9 +20,9 @@
http://maven.apache.org/xsd/settings-1.0.0.xsd"> http://maven.apache.org/xsd/settings-1.0.0.xsd">
<servers> <servers>
<server> <server>
<id>bintray-teavm</id> <id>teavm-repo</id>
<username>${env.BINTRAY_LOGIN}</username> <username>${env.TEAVM_DEPLOY_LOGIN}</username>
<password>${env.BINTRAY_API_KEY}</password> <password>${env.TEAVM_DEPLOY_PASSWORD}</password>
</server> </server>
</servers> </servers>
</settings> </settings>

110
deploy.sh Executable file
View File

@ -0,0 +1,110 @@
#
# Copyright 2021 Alexey Andreev.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
mkdir -p build-dir
mkdir -p build-cache/maven-repository
git fetch
git archive master | tar -x -C build-dir || { echo 'Git archive failed' ; exit 1; }
function deploy_teavm {
TEAVM_OLD_VERSION=`mvn help:evaluate -Dexpression=project.version 2>/dev/null | grep -Ev "(^\[|Download)"`
TEAVM_DEPLOY_VERSION=${TEAVM_OLD_VERSION%.0-SNAPSHOT}
git rev-parse master >commit-id.txt
TEAVM_DEPLOY_COMMIT_ID=`cat commit-id.txt`
if [[ "200" == `curl --output response --silent --write-out "%{http_code}" https://teavm.org/maven/versions/$TEAVM_DEPLOY_VERSION.txt` ]] ; then
TEAVM_DEPLOY_BUILD=$((`cat response` + 1))
else
TEAVM_DEPLOY_BUILD=1
fi
rm response
TEAVM_DEPLOY_VERSION_FULL="$TEAVM_DEPLOY_VERSION.0-$TEAVM_DEPLOY_BUILD"
if [[ "200" == `curl --output response --silent --write-out "%{http_code}" https://teavm.org/maven/versions/$TEAVM_DEPLOY_VERSION_FULL-commit.txt` ]] ; then
if [[ "$TEAVM_DEPLOY_COMMIT_ID" == `cat response` ]] ; then
echo "There are no changes compared to previous build."
exit 1
fi
fi
rm response
echo "Building version $TEAVM_DEPLOY_VERSION_FULL"
sed -i -e "s/{{TEAVM_DEPLOY_URL}}/ftp:\/\/${TEAVM_DEPLOY_SERVER//\//\\/}\/maven\/repository/g" pom.xml
mvn -e versions:set \
-DnewVersion="$TEAVM_DEPLOY_VERSION_FULL" \
-DgenerateBackupPoms=false \
|| { echo 'Setting version' ; return 1; }
mvn -e -V deploy \
--settings ../deploy-settings.xml \
-P with-idea -P with-cli -P deploy-to-teavm \
-Dmaven.repo.local=`pwd`/../build-cache/maven-repository \
-Dteavm.build.all=false \
-Dteavm.junit.optimized=false \
-Dteavm.junit.js.decodeStack=false \
-Dteavm.junit.threads=4 \
-Dteavm.junit.js.runner=browser-chrome \
|| { echo 'Deploy failed' ; return 1; }
cat <<EOF >idea-repository.xml
<?xml version="1.0" encoding="UTF-8"?>
<plugins>
<plugin id="org.teavm.idea" url="https://teavm.org/maven/repository/org/teavm/teavm-idea/$TEAVM_DEPLOY_VERSION_FULL/teavm-idea-$TEAVM_DEPLOY_VERSION_FULL.zip" version="$TEAVM_DEPLOY_VERSION_FULL">
<idea-version since-build="182.*" until-build="223.*" />
<description>TeaVM support</description>
</plugin>
</plugins>
EOF
curl --output badge.svg "https://img.shields.io/static/v1?label=download&message=$TEAVM_DEPLOY_VERSION_FULL&color=green"
cat <<EOF >htaccess
Redirect /maven/_latest /maven/repository/org/teavm/teavm-cli/$TEAVM_DEPLOY_VERSION_FULL/teavm-cli-$TEAVM_DEPLOY_VERSION_FULL.jar
EOF
cat $TEAVM_DEPLOY_BUILD >build-number.txt
return 0
}
pushd build-dir
deploy_teavm
EXIT_CODE=$?
if [[ "$EXIT_CODE" == '0' ]] ; then
curl -T build-number.txt \
ftp://$TEAVM_DEPLOY_SERVER/maven/versions/$TEAVM_DEPLOY_VERSION.txt \
--user $TEAVM_DEPLOY_LOGIN:$TEAVM_DEPLOY_PASSWORD
curl -T commit-id.txt \
ftp://$TEAVM_DEPLOY_SERVER/maven/versions/$TEAVM_DEPLOY_VERSION_FULL-commit.txt \
--user $TEAVM_DEPLOY_LOGIN:$TEAVM_DEPLOY_PASSWORD
curl -T badge.svg \
ftp://$TEAVM_DEPLOY_SERVER/maven/badge.svg \
--user $TEAVM_DEPLOY_LOGIN:$TEAVM_DEPLOY_PASSWORD
curl -T htaccess \
ftp://$TEAVM_DEPLOY_SERVER/maven/.htaccess \
--user $TEAVM_DEPLOY_LOGIN:$TEAVM_DEPLOY_PASSWORD
curl -T idea-repository.xml \
ftp://$TEAVM_DEPLOY_SERVER/idea/dev/teavmRepository.xml \
--user $TEAVM_DEPLOY_LOGIN:$TEAVM_DEPLOY_PASSWORD
fi
popd
rm -rf build-dir
rm -rf build-cache/maven-repository/org/teavm
exit $EXIT_CODE

18
pom.xml
View File

@ -214,6 +214,13 @@
</dependencyManagement> </dependencyManagement>
<build> <build>
<extensions>
<extension>
<groupId>org.apache.maven.wagon</groupId>
<artifactId>wagon-ftp</artifactId>
<version>3.4.3</version>
</extension>
</extensions>
<pluginManagement> <pluginManagement>
<plugins> <plugins>
<plugin> <plugin>
@ -402,5 +409,16 @@
</repository> </repository>
</distributionManagement> </distributionManagement>
</profile> </profile>
<profile>
<id>deploy-to-teavm</id>
<distributionManagement>
<repository>
<id>teavm-repo</id>
<name>Development Preview Repository</name>
<url>{{TEAVM_DEPLOY_URL}}</url>
</repository>
</distributionManagement>
</profile>
</profiles> </profiles>
</project> </project>

View File

@ -1,19 +0,0 @@
#!/bin/sh
$MVN_CMD versions:set -DnewVersion=$1 -DgenerateBackupPoms=false
#cd tools/eclipse
#$MVN_CMD tycho-versions:set-version -DnewVersion=$2
#cd core-plugin
#sed -r -i -e "s/<version><!-- update -->(.+)<\/version>/<version><!-- update -->$1<\/version>/" dep-pom.xml
#sed -r -i -e "s/(lib\/teavm(-[a-z]+)+)-.+\.jar/\1-$1.jar/" build.properties
#sed -r -i -e "s/(lib\/teavm(-[a-z]+)+)-.+\.jar/\1-$1.jar/" META-INF/MANIFEST.MF
#cd ..
#cd m2e-plugin
#sed -r -i -e "s/<versionRange>.+<\/versionRange>/<versionRange>$1<\/versionRange>/" lifecycle-mapping-metadata.xml
#cd ..
#cd ../..

View File

@ -12,15 +12,7 @@ scp -o StrictHostKeyChecking=no -i /tmp/sftp_rsa -B -r -P $FTP_PORT tools/cli/ta
# #
# Update IDEA repository descriptor # Update IDEA repository descriptor
# #
cat <<EOF >.idea-repository.xml
<?xml version="1.0" encoding="UTF-8"?>
<plugins>
<plugin id="org.teavm.idea" url="https://dl.bintray.com/konsoletyper/teavm/org/teavm/teavm-idea/$NEW_VERSION/teavm-idea-$NEW_VERSION.zip" version="$NEW_VERSION">
<idea-version since-build="182.*" until-build="223.*" />
<description>TeaVM support</description>
</plugin>
</plugins>
EOF
scp -o StrictHostKeyChecking=no -i /tmp/sftp_rsa -B -r -P $FTP_PORT .idea-repository.xml $SCP_TARGET/idea/dev/teavmRepository.xml scp -o StrictHostKeyChecking=no -i /tmp/sftp_rsa -B -r -P $FTP_PORT .idea-repository.xml $SCP_TARGET/idea/dev/teavmRepository.xml