Skip to content

Commit

Permalink
Add support for publishing built artifacts to Github Releases
Browse files Browse the repository at this point in the history
  • Loading branch information
benhylau committed Feb 1, 2018
1 parent ddc9a55 commit 733af88
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 3 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
.github_publish
.vagrant
vagrant-ssh.conf
output-macos/
output-macos/
25 changes: 24 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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=<username>
GITHUB_REPOSITORY=<repository-name>
GITHUB_TOKEN=<github-api-token>
GITHUB_RELEASE_VERSION=<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
Expand Down
5 changes: 5 additions & 0 deletions bootstrap.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
18 changes: 17 additions & 1 deletion src/Makefile
Original file line number Diff line number Diff line change
@@ -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)

0 comments on commit 733af88

Please sign in to comment.