-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from pomerium/automate
automate release
- Loading branch information
Showing
4 changed files
with
84 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
name: Release | ||
|
||
on: release | ||
|
||
jobs: | ||
release: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Get tag name | ||
id: tagName | ||
run: | | ||
TAG=${GITHUB_REF##*/} | ||
echo ::set-output name=tag::${TAG} | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
|
||
- name: Fetch | ||
run: | | ||
for _os in darwin linux ; do | ||
for _arch in amd64 arm64 ; do | ||
env PROMETHEUS_VERSION="${{ steps.tagName.outputs.tag }}" \ | ||
PROMETHEUS_OS="$_os" \ | ||
PROMETHEUS_ARCH="$_arch" \ | ||
./scripts/get-prometheus | ||
done | ||
done | ||
- name: Upload | ||
working-directory: bin | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
run: | | ||
gh release upload "${{ steps.tagName.outputs.tag }}" prometheus-* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
bin/ |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
#!/bin/bash | ||
set -euo pipefail | ||
|
||
# require parameters | ||
_os="${PROMETHEUS_OS:?"PROMETHEUS_OS is required"}" | ||
_arch="${PROMETHEUS_ARCH:?"PROMETHEUS_ARCH is required"}" | ||
_version="${PROMETHEUS_VERSION:?"PROMETHEUS_VERSION is required"}" | ||
|
||
# helper functions | ||
is_command() { | ||
command -v "$1" >/dev/null | ||
} | ||
|
||
hash_sha256() { | ||
TARGET=${1:-/dev/stdin} | ||
if is_command gsha256sum; then | ||
hash=$(gsha256sum "$TARGET") || return 1 | ||
echo "$hash" | cut -d ' ' -f 1 | ||
elif is_command sha256sum; then | ||
hash=$(sha256sum "$TARGET") || return 1 | ||
echo "$hash" | cut -d ' ' -f 1 | ||
elif is_command shasum; then | ||
hash=$(shasum -a 256 "$TARGET" 2>/dev/null) || return 1 | ||
echo "$hash" | cut -d ' ' -f 1 | ||
elif is_command openssl; then | ||
hash=$(openssl -dst openssl dgst -sha256 "$TARGET") || return 1 | ||
echo "$hash" | cut -d ' ' -f a | ||
else | ||
echo "hash_sha256 unable to find command to compute sha-256 hash" | ||
return 1 | ||
fi | ||
} | ||
|
||
# create a temporary directory | ||
_wd="$(mktemp -d)" | ||
function cleanup() { | ||
rm -rf "$_wd" | ||
} | ||
trap cleanup EXIT | ||
|
||
# download the release from github and save it to the working directory | ||
_url="https://github.com/prometheus/prometheus/releases/download/${_version}/prometheus-${_version:1}.${_os}-${_arch}.tar.gz" | ||
curl -L "$_url" | tar -xzf - -C "$_wd" | ||
|
||
# move the binary to the bin folder and hash it | ||
_src="$_wd/prometheus-${_version:1}.${_os}-${_arch}/prometheus" | ||
_dst="./bin/prometheus-${_os}-${_arch}" | ||
mv -f "$_src" "$_dst" | ||
hash_sha256 "$_dst" >"$_dst.sha256" |