## GITHUB_TOKEN="<github_access_token>"
## REPO="<user_or_org>/<repo_name>"
## FILE="<name_of_asset_file>"      # the name of your release asset file, e.g. build.tar.gz
## Download release from github
github/download-private-release:
	$(call assert-set,GITHUB_TOKEN)
	$(call assert-set,REPO)
	$(call assert-set,FILE)
	$(call assert-set,VERSION)
	$(call assert-set,OUTPUT)
	$(BUILD_HARNESS_PATH)/bin/github_download_private_release.sh $(VERSION) $(OUTPUT)

## REPO="<user_or_org>/<repo_name>"
## FILE="<name_of_asset_file>"      # the name of your release asset file, e.g. build.tar.gz
## Download release from github
github/download-public-release:
	$(call assert-set,REPO)
	$(call assert-set,FILE)
	$(call assert-set,VERSION)
	$(call assert-set,OUTPUT)
	$(BUILD_HARNESS_PATH)/bin/github_download_public_release.sh $(VERSION) $(OUTPUT)

# To use ghr, you need a GitHub API token.
# Please set it via `GITHUB_TOKEN` env var
## Push all release artifacts to GitHub (Required: `GITHUB_TOKEN`)
github/push-artifacts: packages/install/ghr-linux
	$(call assert-set,GIT_TAG)
	$(call assert-set,ARTIFACTS)
	@ghr $(GIT_TAG) $(ARTIFACTS)

.PHONY : github/latest-release
## Fetch the latest release tag from the GitHub API
github/latest-release:
	@$(BUILD_HARNESS_PATH)/bin/github_repo_metadata.sh '$(GIT_ORG)' '$(GIT_REPO)' 'releases/latest' '.tag_name'

