diff --git a/.gitignore b/.gitignore index cbee256..78f4ccb 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ +.github_publish .vagrant vagrant-ssh.conf -output-macos/ +output-macos/ \ No newline at end of file diff --git a/README.md b/README.md index cf99902..b2d8d29 100644 --- a/README.md +++ b/README.md @@ -49,8 +49,31 @@ find the built artifacts in the **output** directory of your host: Then you may destroy the Vagrant machine with `vagrant destroy`. +Publish to GitHub Releases +-------------------------- + +If you wish to publish the built artifacts to _GitHub Releases_, create a file +named **.github_publish** in the project root before `vagrant up` with the +following information: + + GITHUB_USERNAME= + GITHUB_REPOSITORY= + GITHUB_TOKEN= + GITHUB_RELEASE_VERSION= + +The _GitHub API Token_ should have `public_repo` scope for public repositories +and `repo` scope for private repositories. + + GITHUB_USERNAME=benhylau + GITHUB_REPOSITORY=mesh-router-builder + GITHUB_TOKEN=0123456789abcdef0123456789abcdef01234567 + GITHUB_RELEASE_VERSION=v0.1 + +After `make` completes, you can call `make publish` and all artifacts will be +published to _Github Releases_ in your repository. + macOS High Sierra ------------------- +----------------- There is a known bug in macOS High Sierra that prevents Synced Folders from working. You will have to get the built artifacts manually before destroying the diff --git a/bootstrap.sh b/bootstrap.sh index 53ff1ea..144430f 100644 --- a/bootstrap.sh +++ b/bootstrap.sh @@ -37,3 +37,8 @@ apt-get install -y nodejs # Copy build scripts from Synced Folder to Vagrant machine user home cp -r /vagrant/src/* /home/vagrant/ chown -R vagrant:vagrant /home/vagrant/* + +# Load github release publishing configurations +set -a +. /vagrant/.github_publish 2>/dev/null || true +set +a \ No newline at end of file diff --git a/src/Makefile b/src/Makefile index 3451aec..6de2f46 100644 --- a/src/Makefile +++ b/src/Makefile @@ -1,12 +1,28 @@ # -# Build all artifacts from each subdirectory +# Build all artifacts from each subdirectory and optionally publish # PACKAGES_DIR = debian-packages IMAGES_DIR = mesh-orange-images +PACKAGES_DIR = /vagrant/output/debian-packages +IMAGES_DIR = /vagrant/output/mesh-orange-images +PUBLISH_DIR = /tmp/publish + build_images: build_packages $(MAKE) -C $(IMAGES_DIR) build_packages: $(MAKE) -C $(PACKAGES_DIR) + +publish: + rm -rf $(PUBLISH_DIR) + mkdir $(PUBLISH_DIR) + cp $(PACKAGES_DIR)/* $(PUBLISH_DIR)/ + cp $(IMAGES_DIR)/* $(PUBLISH_DIR)/ + go get -u github.com/tcnksm/ghr + go/bin/ghr \ + -username ${GITHUB_USERNAME} \ + -repository ${GITHUB_REPOSITORY} \ + -token ${GITHUB_TOKEN} \ + ${GITHUB_RELEASE_VERSION} $(PUBLISH_DIR)