Jelajahi Sumber

[TravisCI] upload to ppa

Andy Li 9 tahun lalu
induk
melakukan
bfac501102
5 mengubah file dengan 106 tambahan dan 30 penghapusan
  1. 2 0
      .gitignore
  2. 20 9
      .travis.yml
  3. TEMPAT SAMPAH
      extra/haxeci_sec.gpg.enc
  4. TEMPAT SAMPAH
      extra/haxeci_ssh.enc
  5. 84 21
      tests/RunCi.hx

+ 2 - 0
.gitignore

@@ -14,6 +14,8 @@
 /extra/bintray.json
 /extra/git-archive-all
 /extra/deploy_key
+/extra/*_sec.gpg
+/extra/*_ssh
 
 /version.ml
 /haxe

+ 20 - 9
.travis.yml

@@ -15,8 +15,10 @@ env:
     - secure: "VBJDQNJ9uvdt0aszo7oU3txuRvjkuLmuHZGOkrd4wE/5B4sX5jzx/+dnrKcNTXJCmQ/rVLuMu9GyxqVjNHlzce678voxdQNOtNkNgpkr1qN9/A9rRnCp77hH27ErdthpWxbmcnE62hAJ83TIKSvn//5lAkx4sMCKS1NXEWQ5qec="
     # HAXECI_GH_TOKEN: haxe-ci Github personal access token
     - secure: "TpEMYTLgNrVD7kR6hs6EwyWNXUxnfV6XO5MGvYQncKXB1N65PG18n4WQFhnKaH8C2QTFE7dq7688ooXGzwWeoT9WAOBey10jP1f7LXEAjMGAUA4vh2zS93qBZ92ZgzCDZnQN7ZOTQGocwU6Xolu+7/6hP2M8041HBixmFuNkXF4="
-    # deploy_key_decrypt
-    - secure: "A75uYqU0Xz6plIgSewEs0QQWe472dCMb9kf3j7Hx0DS7dApXgx8++189sw9Sv0wam5KPtbcIM292MucjGCb5zocVj9xCUVgajhEA0QpTuDMBjk/cg3ClWCGjfybaCl2E5LLdUs7Zy4b4oNWtVikOWLWJ4sC1kaarR9p6kv8yYZg="
+    # PPA configs
+    - PPA="ppa:haxe/snapshots"
+    - DEBFULLNAME="Haxe CI Bot"
+    - DEBEMAIL="[email protected]"
 
 sudo: false
 addons:
@@ -48,10 +50,19 @@ matrix:
       env: TEST=macro
       addons: {apt: {packages: [*apt_cs, *apt_python]}}
     - os: linux
+      sudo: required
+      dist: trusty
       env:
         - TEST=neko
-        - BINTRAY=1
         - DEPLOY=1
+        - BINTRAY=1
+        # haxeci_decrypt (Deploy source package to ppa:haxe/snapshots.)
+        - secure: "Mw3p6bDZuqVQ6u7GrwLQfje5hhIOA4+mdqqLXYHP79UKdhgqb91Dn6IbG9vQ1VXVe64W4YZbQAMBMMRX5kEPDl6JvTVGSBhg00Mi69oO5qrCMcBI6f9FntG72YaVvLf+PA7co+vKrnJzaP2M9pe4SH9Ztbhy0YNxULp7NQ8FLsM="
+        # deploy_key_decrypt (Deploy doc to api.haxe.org.)
+        - secure: "A75uYqU0Xz6plIgSewEs0QQWe472dCMb9kf3j7Hx0DS7dApXgx8++189sw9Sv0wam5KPtbcIM292MucjGCb5zocVj9xCUVgajhEA0QpTuDMBjk/cg3ClWCGjfybaCl2E5LLdUs7Zy4b4oNWtVikOWLWJ4sC1kaarR9p6kv8yYZg="
+      before_script:
+        - travis_retry sudo apt-get install mysql-server -y
+        - mysql -u root -e "create user travis@localhost identified by '';"
     - os: linux
       env:
         - TEST=js
@@ -89,6 +100,7 @@ matrix:
     - os: osx
       env:
         - TEST=neko
+        - DEPLOY=1
         - BINTRAY=1
     - os: osx
       env: TEST=js
@@ -126,18 +138,17 @@ install:
       travis_retry brew install neko --HEAD;
     fi
 
-before_script:
+script:
+  # setup database
   - if [ "${TRAVIS_OS_NAME}" = "osx" ]; then
-    travis_retry brew install mysql &&
-    mysql.server start;
-    mysql -u root -e "create user if not exists travis@localhost identified by '';";
+      travis_retry brew install mysql &&
+      mysql.server start;
+      mysql -u root -e "create user if not exists travis@localhost identified by '';";
     fi
   - mysql -u root -e "CREATE DATABASE haxe_test;"
   - mysql -u root -e "grant all on haxe_test.* to travis@localhost;"
   # start ssh-agent for deployment to haxe.org
   - eval `ssh-agent -s`
-
-script:
   - make package_src -s
   - make -s
   - make tools -s

TEMPAT SAMPAH
extra/haxeci_sec.gpg.enc


TEMPAT SAMPAH
extra/haxeci_ssh.enc


+ 84 - 21
tests/RunCi.hx

@@ -594,15 +594,36 @@ class RunCi {
 				throw haxe_ver;
 		}
 	}
+	static var haxeVerFull(default, never) = {
+		var ver = haxeVer.split(".");
+		while (ver.length < 3) {
+			ver.push("0");
+		}
+		ver.join(".");
+	}
+
+	static function deploy():Void {
+		if (
+			Sys.getEnv("DEPLOY") != null
+		) {
+			changeDirectory(repoDir);
+
+			// generate doc
+			runCommand("make", ["-s", "install_dox"]);
+			runCommand("make", ["-s", "package_doc"]);
 
-	static function bintray():Void {
+			deployBintray();
+			deployApiDoc();
+			deployPPA();
+		}
+	}
+
+	static function deployBintray():Void {
 		if (
 			Sys.getEnv("BINTRAY") != null &&
 			Sys.getEnv("BINTRAY_USERNAME") != null &&
 			Sys.getEnv("BINTRAY_API_KEY") != null
 		) {
-			changeDirectory(repoDir);
-
 			// generate bintray config
 			var tpl = new Template(File.getContent("extra/bintray.tpl.json"));
 			var compatDate = ~/[^0-9]/g.replace(gitInfo.date, "");
@@ -623,24 +644,66 @@ class RunCi {
 			File.saveContent("extra/bintray.json", json);
 			infoMsg("saved " + FileSystem.absolutePath(path) + " with content:");
 			Sys.println(json);
+		}
+	}
 
-			// generate doc
-			runCommand("make", ["-s", "install_dox"]);
-			runCommand("make", ["-s", "package_doc"]);
+	/**
+		Deploy doc to api.haxe.org.
+	*/
+	static function deployApiDoc():Void {
+		if (
+			gitInfo.branch == "development" &&
+			Sys.getEnv("DEPLOY") != null &&
+			Sys.getEnv("deploy_key_decrypt") != null
+		) {
+			// setup deploy_key
+			runCommand("openssl aes-256-cbc -k \"$deploy_key_decrypt\" -in extra/deploy_key.enc -out extra/deploy_key -d");
+			runCommand("chmod 600 extra/deploy_key");
+			runCommand("ssh-add extra/deploy_key");
 
-			// deploy doc to api.haxe.org
-			if (
-				gitInfo.branch == "development" && 
-				Sys.getEnv("DEPLOY") != null && 
-				Sys.getEnv("deploy_key_decrypt") != null
-			) {
-				//setup deploy_key
-				runCommand("openssl aes-256-cbc -k \"$deploy_key_decrypt\" -in extra/deploy_key.enc -out extra/deploy_key -d");
-				runCommand("chmod 600 extra/deploy_key");
-				runCommand("ssh-add extra/deploy_key");
-
-				runCommand("make", ["-s", "deploy_doc"]);
-			}
+			runCommand("make", ["-s", "deploy_doc"]);
+		}
+	}
+
+	/**
+		Deploy source package to ppa:haxe/snapshots.
+	*/
+	static function deployPPA():Void {
+		if (
+			gitInfo.branch == "development" && 
+			Sys.getEnv("DEPLOY") != null && 
+			Sys.getEnv("haxeci_decrypt") != null
+		) {
+			// setup haxeci_ssh
+			runCommand("openssl aes-256-cbc -k \"$haxeci_decrypt\" -in extra/haxeci_ssh.enc -out extra/haxeci_ssh -d");
+			runCommand("chmod 600 extra/haxeci_ssh");
+			runCommand("ssh-add extra/haxeci_ssh");
+			// setup haxeci_sec.gpg
+			runCommand("openssl aes-256-cbc -k \"$haxeci_decrypt\" -in extra/haxeci_sec.gpg.enc -out extra/haxeci_sec.gpg -d");
+			runCommand("gpg --allow-secret-key-import --import extra/haxeci_sec.gpg");
+			runCommand("sudo apt-get install devscripts git-buildpackage ubuntu-dev-tools dh-make -y");
+			var compatDate = ~/[^0-9]/g.replace(gitInfo.date, "");
+			var SNAPSHOT_VERSION = '${haxeVerFull}+1SNAPSHOT${compatDate}+${gitInfo.commit.substr(0,7)}';
+			runCommand('cp out/haxe*_src.tar.gz "../haxe_${SNAPSHOT_VERSION}.orig.tar.gz"');
+			changeDirectory("..");
+			runCommand("git clone https://github.com/HaxeFoundation/haxe-debian.git");
+			changeDirectory("haxe-debian");
+			runCommand("git checkout upstream");
+			runCommand("git checkout next");
+			runCommand('gbp import-orig "../haxe_${SNAPSHOT_VERSION}.orig.tar.gz" -u "${SNAPSHOT_VERSION}" --debian-branch=next');
+			runCommand('dch -v "1:${SNAPSHOT_VERSION}-1" --urgency low "snapshot build"');
+			runCommand("debuild -S -sa");
+			runCommand("backportpackage -d xenial  --upload ${PPA} --yes ../haxe_*.dsc");
+			runCommand("backportpackage -d wily    --upload ${PPA} --yes ../haxe_*.dsc");
+			runCommand("backportpackage -d vivid   --upload ${PPA} --yes ../haxe_*.dsc");
+			runCommand("backportpackage -d trusty  --upload ${PPA} --yes ../haxe_*.dsc");
+			runCommand("git checkout debian/changelog");
+			runCommand("git config --global user.name \"${DEBFULLNAME}\"");
+			runCommand("git config --global user.email \"${DEBEMAIL}\"");
+			runCommand("git merge -X ours --no-edit origin/backport-precise");
+			runCommand('dch -v "1:${SNAPSHOT_VERSION}-1" --urgency low "snapshot build"');
+			runCommand("debuild -S -sa");
+			runCommand("backportpackage -d precise --upload ${PPA} --yes ../haxe_*.dsc");
 		}
 	}
 
@@ -779,8 +842,6 @@ class RunCi {
 	static function main():Void {
 		Sys.putEnv("OCAMLRUNPARAM", "b");
 
-		bintray();
-
 		var tests:Array<TEST> = switch (Sys.getEnv("TEST")) {
 			case null:
 				[Macro];
@@ -1083,6 +1144,8 @@ class RunCi {
 		) {
 			saveOutput();
 		}
+
+		deploy();
 	}
 
 	static function testHxTemplo() {