You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by hs...@apache.org on 2021/05/27 04:58:43 UTC

[sling-slingpackager] branch travisBuild updated: Refactoring build/release scripts.

This is an automated email from the ASF dual-hosted git repository.

hsaginor pushed a commit to branch travisBuild
in repository https://gitbox.apache.org/repos/asf/sling-slingpackager.git


The following commit(s) were added to refs/heads/travisBuild by this push:
     new 2a9a72f  Refactoring build/release scripts.
2a9a72f is described below

commit 2a9a72fc986df3d945a51453efc5f4bda82722ab
Author: Henry Saginor <hs...@gmail.com>
AuthorDate: Wed May 26 21:58:11 2021 -0700

    Refactoring build/release scripts.
---
 .npmignore                                     |  3 +-
 .travis.yml                                    |  4 +-
 pom.xml                                        |  6 +--
 tools/{travis/setup.sh => scripts/build.sh}    | 43 +++++++++++++++--
 tools/{travis/setup.sh => scripts/publish.sh}  | 19 ++++++--
 tools/{travis/setup.sh => scripts/release.sh}  | 14 ++++--
 tools/{travis => scripts}/setup.sh             |  0
 tools/{travis/setup.sh => scripts/setupenv.sh} | 12 +++--
 tools/{travis/setup.sh => scripts/sign.sh}     | 19 ++++++--
 tools/{travis/build.sh => scripts/test.sh}     | 67 +++++---------------------
 10 files changed, 111 insertions(+), 76 deletions(-)

diff --git a/.npmignore b/.npmignore
index 8603cae..28cef18 100644
--- a/.npmignore
+++ b/.npmignore
@@ -16,4 +16,5 @@
 #
 
 test/
-sling/
\ No newline at end of file
+sling/
+node_modules/
\ No newline at end of file
diff --git a/.travis.yml b/.travis.yml
index 53c5204..11b0ed4 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -30,8 +30,8 @@ before_install:
 - cd $TRAVIS_BUILD_DIR
 install:
 - cd $TRAVIS_BUILD_DIR
-- "./tools/travis/setup.sh"
+- "./tools/scripts/setup.sh"
 - cd $TRAVIS_BUILD_DIR
 script:
 - cd $TRAVIS_BUILD_DIR
-- "./tools/travis/build.sh"
\ No newline at end of file
+- "./tools/scripts/release.sh"
\ No newline at end of file
diff --git a/pom.xml b/pom.xml
index 203bc7c..752f260 100644
--- a/pom.xml
+++ b/pom.xml
@@ -21,9 +21,9 @@
   <packaging>pom</packaging>
 
   <parent>
-    <groupId>org.apache</groupId>
-    <artifactId>apache</artifactId>
-    <version>23</version>
+    <groupId>org.apache.sling</groupId>
+    <artifactId>sling</artifactId>
+    <version>6</version>
   </parent>
 
   <groupId>org.apache.sling</groupId>
diff --git a/tools/travis/setup.sh b/tools/scripts/build.sh
similarity index 50%
copy from tools/travis/setup.sh
copy to tools/scripts/build.sh
index 055de17..94967a0 100755
--- a/tools/travis/setup.sh
+++ b/tools/scripts/build.sh
@@ -1,4 +1,5 @@
 #!/bin/bash
+set -e
 #
 # Licensed to the Apache Software Foundation (ASF) under one or more
 # contributor license agreements.  See the NOTICE file distributed with
@@ -16,7 +17,43 @@
 # limitations under the License.
 #
 
-# install node and npm
-sudo apt-get -y install nodejs npm
+# Build and release script.
 
-npm install
\ No newline at end of file
+. tools/scripts/setupenv.sh
+
+echo "Build dir $RELEASEDIR"
+
+# Scan code
+mvn clean apache-rat:check
+
+echo "Code scan successful."
+
+# Make new release directory
+if [ -d "$RELEASEDIR" ] 
+then
+    rm -rf $RELEASEDIR
+fi
+mkdir -p $RELEASEDIR
+
+echo "Copeing release files."
+
+# Copy code to release directory
+cp -p -a $ROOTDIR/bin $RELEASEDIR
+cp -p -a $ROOTDIR/cmds $RELEASEDIR
+cp -p -a $ROOTDIR/utils $RELEASEDIR
+cp -p -a $ROOTDIR/test $RELEASEDIR
+cp package.json LICENSE NOTICE .npmignore $RELEASEDIR
+
+# Run tests
+. $SCRIPTDIR/test.sh
+
+cd $RELEASEDIR
+
+# Create release package
+npm pack
+
+# For integration with current Sling Release Management which uses Maven
+# copy generated arifect to target folder
+cp $RELEASEDIR/*.tgz $ROOTDIR/target
+
+cd $ROOTDIR
\ No newline at end of file
diff --git a/tools/travis/setup.sh b/tools/scripts/publish.sh
similarity index 74%
copy from tools/travis/setup.sh
copy to tools/scripts/publish.sh
index 055de17..3a346d1 100755
--- a/tools/travis/setup.sh
+++ b/tools/scripts/publish.sh
@@ -1,4 +1,5 @@
 #!/bin/bash
+set -e
 #
 # Licensed to the Apache Software Foundation (ASF) under one or more
 # contributor license agreements.  See the NOTICE file distributed with
@@ -16,7 +17,19 @@
 # limitations under the License.
 #
 
-# install node and npm
-sudo apt-get -y install nodejs npm
+# Publish release script.
+
+. tools/scripts/setupenv.sh
+
+cd $RELEASEDIR
+
+# Upload signed release package to ASF archive
+# TODO
+
+# Now NPM publish (dry run for now)
+echo "Publishing to NPM"
+npm publish apache-sling-slingpackager-*.tgz --access public --dry-run
+
+cd $ROOTDIR
+
 
-npm install
\ No newline at end of file
diff --git a/tools/travis/setup.sh b/tools/scripts/release.sh
similarity index 85%
copy from tools/travis/setup.sh
copy to tools/scripts/release.sh
index 055de17..9f5d42f 100755
--- a/tools/travis/setup.sh
+++ b/tools/scripts/release.sh
@@ -1,4 +1,5 @@
 #!/bin/bash
+set -e
 #
 # Licensed to the Apache Software Foundation (ASF) under one or more
 # contributor license agreements.  See the NOTICE file distributed with
@@ -16,7 +17,14 @@
 # limitations under the License.
 #
 
-# install node and npm
-sudo apt-get -y install nodejs npm
+. tools/scripts/setupenv.sh
+
+. $SCRIPTDIR/build.sh
+
+# Sign release
+# . $SCRIPTDIR/sign.sh
+
+# Publish release
+. $SCRIPTDIR/publish.sh
+
 
-npm install
\ No newline at end of file
diff --git a/tools/travis/setup.sh b/tools/scripts/setup.sh
similarity index 100%
copy from tools/travis/setup.sh
copy to tools/scripts/setup.sh
diff --git a/tools/travis/setup.sh b/tools/scripts/setupenv.sh
similarity index 68%
copy from tools/travis/setup.sh
copy to tools/scripts/setupenv.sh
index 055de17..6236fcf 100755
--- a/tools/travis/setup.sh
+++ b/tools/scripts/setupenv.sh
@@ -1,4 +1,5 @@
 #!/bin/bash
+set -e
 #
 # Licensed to the Apache Software Foundation (ASF) under one or more
 # contributor license agreements.  See the NOTICE file distributed with
@@ -16,7 +17,12 @@
 # limitations under the License.
 #
 
-# install node and npm
-sudo apt-get -y install nodejs npm
+export SLING_JAR="org.apache.sling.starter-11.jar"
+export SLING_DOWNLOAD="https://downloads.apache.org/sling/$SLING_JAR"
+export PACK_NAME="slingpackager"
+export SCRIPTDIR=$(cd $(dirname "$0") && pwd)
+export ROOTDIR=$(cd $SCRIPTDIR/../.. && pwd)
+export RELEASEDIR="$ROOTDIR/releases/$PACK_NAME"
 
-npm install
\ No newline at end of file
+# echo "ROOTDIR is $ROOTDIR"
+# echo "RELEASEDIR $RELEASEDIR"
diff --git a/tools/travis/setup.sh b/tools/scripts/sign.sh
similarity index 71%
rename from tools/travis/setup.sh
rename to tools/scripts/sign.sh
index 055de17..7182281 100755
--- a/tools/travis/setup.sh
+++ b/tools/scripts/sign.sh
@@ -1,4 +1,5 @@
 #!/bin/bash
+set -e
 #
 # Licensed to the Apache Software Foundation (ASF) under one or more
 # contributor license agreements.  See the NOTICE file distributed with
@@ -16,7 +17,19 @@
 # limitations under the License.
 #
 
-# install node and npm
-sudo apt-get -y install nodejs npm
+# Sign release script.
 
-npm install
\ No newline at end of file
+. tools/scripts/setupenv.sh
+
+cd $RELEASEDIR
+
+# Sign release package
+echo "Prepare to sign package."
+for f in $(find . -type f -name '*.tgz')
+do 
+    echo "Signing file $f"
+    gpg --print-md SHA512 "${f##*/}" > $f.sha512
+    gpg --armor --output "$f.asc" --detach-sig "$f"
+done
+
+cd $ROOTDIR
\ No newline at end of file
diff --git a/tools/travis/build.sh b/tools/scripts/test.sh
similarity index 51%
rename from tools/travis/build.sh
rename to tools/scripts/test.sh
index 7e348c0..fcc073c 100755
--- a/tools/travis/build.sh
+++ b/tools/scripts/test.sh
@@ -17,35 +17,9 @@ set -e
 # limitations under the License.
 #
 
-# Build script for Travis-CI.
+# Run tests script.
 
-SLING_JAR="org.apache.sling.starter-11.jar"
-SLING_DOWNLOAD="https://downloads.apache.org/sling/$SLING_JAR"
-PACK_NAME="slingpackager"
-SCRIPTDIR=$(cd $(dirname "$0") && pwd)
-ROOTDIR=$(cd $SCRIPTDIR/../.. && pwd)
-RELEASEDIR="$ROOTDIR/releases/$PACK_NAME"
-
-# Scan code
-mvn apache-rat:check
-
-echo "Code scan successful."
-
-# Make new release directory
-if [ -d "$RELEASEDIR" ] 
-then
-    rm -rf $RELEASEDIR
-fi
-mkdir -p $RELEASEDIR
-
-echo "Copeing release files."
-
-# Copy code to release directory
-cp -p -a $ROOTDIR/bin $RELEASEDIR
-cp -p -a $ROOTDIR/cmds $RELEASEDIR
-cp -p -a $ROOTDIR/utils $RELEASEDIR
-cp -p -a $ROOTDIR/test $RELEASEDIR
-cp package.json LICENSE NOTICE $RELEASEDIR
+. tools/scripts/setupenv.sh
 
 cd $RELEASEDIR
 
@@ -53,7 +27,7 @@ cd $RELEASEDIR
 mkdir sling
 cd sling
 echo "Downloading Sling jar $SLING_DOWNLOAD"
-curl $SLING_DOWNLOAD -o $SLING_JAR
+curl $SLING_DOWNLOAD -o $RELEASEDIR/sling/$SLING_JAR
 
 echo "Starting sling in ${PWD}"
 ( 
@@ -77,33 +51,16 @@ fi
 
 echo "Sling PID is " & cat sling.pid
 
+# Stop sling before exit for any reason.
+function finish {
+    echo "Stopping test sling instance."
+    cd $RELEASEDIR/sling
+    java -jar $SLING_JAR stop
+}
+trap finish EXIT
+
 # Run tests
 cd $RELEASEDIR
 npm test
 
-# Stop and remove sling
-cd sling
-java -jar $SLING_JAR stop
-sleep 2
-cd $RELEASEDIR
-rm -rf sling
-
-# Create release package
-npm pack
-
-# Sign release package
-echo "Prepare to sign package."
-for f in $(find . -type f -name '*.tgz')
-do 
-    echo "Signing file $f"
-    gpg --print-md SHA512 "${f##*/}" > $f.sha512
-    gpg --armor --output "$f.asc" --detach-sig "$f"
-done
-
-# Upload signed release package to ASF archive
-
-# Now NPM publish (dry run for now)
-cd $RELEASEDIR
-npm publish apache-sling-slingpackager-*.tgz --access public --dry-run
-
-
+cd $ROOTDIR
\ No newline at end of file