From 2bc076641485c8d52a86441898d62c0fb86231fb Mon Sep 17 00:00:00 2001
From: "Kali Kaneko (leap communications)" <kali@leap.se>
Date: Sun, 15 Sep 2019 00:15:00 +0200
Subject: [PATCH] [pkg] entrypoint for all vendored builds

---
 .gitlab-ci.yml                       | 14 ++++++++++++++
 Makefile                             |  7 +++++++
 branding/scripts/build-all-providers | 17 +++++++++++++++++
 branding/templates/makefile/Makefile |  2 +-
 4 files changed, 39 insertions(+), 1 deletion(-)
 create mode 100755 branding/scripts/build-all-providers

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 1430603b..518cb2c2 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -3,6 +3,7 @@ stages:
   - build
   - push
   - trigger
+  - vendor
 
 variables:
   GOPATH: /go
@@ -149,3 +150,16 @@ trigger_deb:
   stage: trigger
   script:
     - "curl -X POST -F token=$RISEUP_VPN_DEB_TRIGGER_TOKEN -F ref=master https://0xacab.org/api/v4/projects/1916/trigger/pipeline"
+
+vendorize:
+  image: 0xacab.org:4567/leap/docker/bitmask-vpn:latest
+  stage: vendor
+  script:
+    - PROVIDERS="riseup" make build_all_providers
+ artifacts:
+   name: installers-$CI_COMMIT_REF_NAME
+   paths:
+     - deploy/RiseupVPN-*.exe
+     - deploy/RiseupVPN-*.pkg
+     - deploy/riseup-vpn-*.deb
+   expire_in: 1 month
diff --git a/Makefile b/Makefile
index 0023324d..bfcb174f 100644
--- a/Makefile
+++ b/Makefile
@@ -109,6 +109,13 @@ clean:
 	@rm -rf build/
 	@unlink branding/assets/default
 
+#########################################################################
+# build them all
+#########################################################################
+
+build_all_providers:
+	branding/scripts/build-all-providers
+
 #########################################################################
 # packaging templates
 #########################################################################
diff --git a/branding/scripts/build-all-providers b/branding/scripts/build-all-providers
new file mode 100755
index 00000000..2efcfc5e
--- /dev/null
+++ b/branding/scripts/build-all-providers
@@ -0,0 +1,17 @@
+#!/bin/bash
+
+# run the build process for all the providers passed
+# on a environment variable
+
+: "${PROVIDERS:=riseup}"
+
+set -e
+
+export XBUILD=yes
+
+for _provider in $PROVIDERS; do
+    export PROVIDER=$_provider;
+    make prepare
+    make build
+    make packages
+done
diff --git a/branding/templates/makefile/Makefile b/branding/templates/makefile/Makefile
index 3e6332f4..39c4a50e 100755
--- a/branding/templates/makefile/Makefile
+++ b/branding/templates/makefile/Makefile
@@ -54,8 +54,8 @@ pkg_osx:
 	echo "[+] Building osx package..."
 	cp ../bin/darwin/bitmask-vpn dist/$(APPNAME).app/Contents/MacOS/
 	cp ../bin/darwin/bitmask-helper dist/$(APPNAME).app/Contents/MacOS/
-	chmod +x $(STAGING)/openvpn-osx
 	cp $(STAGING)/openvpn-osx dist/$(APPNAME).app/Contents/Resources/openvpn.leap
+	chmod +x dist/$(APPNAME).app/Contents/Resources/openvpn.leap
 ifeq ($(SYSTEM), Darwin)
 	osx/quickpkg --output dist/$(APPNAME)-$(VERSION)_unsigned.pkg --scripts osx/scripts/ dist/$(APPNAME).app/
 	@if [ $(BUILD_RELEASE) = no ]; then\
-- 
GitLab