-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Paulo Gomes <[email protected]>
- Loading branch information
Showing
8 changed files
with
118 additions
and
366 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 |
---|---|---|
@@ -1,20 +1,30 @@ | ||
RUNNER ?= docker | ||
POLICIES = $(shell find policy -mindepth 2 -maxdepth 2 -type d | sort -u | cut -f 2 -d'/') | ||
POLICIES = $(shell find policy -mindepth 1 -maxdepth 1 -type d | sort -u | cut -f 2 -d'/') | ||
|
||
# GPG Signing | ||
DRY_RUN ?= false | ||
SIGN_KEY_EMAIL ?= [email protected] | ||
PRIVATE_KEY ?= | ||
PRIVATE_KEY_PASS_PHRASE ?= | ||
TESTING_PRIVATE_KEY ?= | ||
TESTING_PRIVATE_KEY_PASS_PHRASE ?= | ||
|
||
# S3 Upload | ||
TESTING_AWS_ACCESS_KEY_ID ?= | ||
TESTING_AWS_SECRET_ACCESS_KEY ?= | ||
TESTING_AWS_S3_BUCKET ?= | ||
PRODUCTION_AWS_ACCESS_KEY_ID ?= | ||
PRODUCTION_AWS_SECRET_ACCESS_KEY ?= | ||
PRODUCTION_AWS_S3_BUCKET ?= | ||
|
||
ifeq ($(DRY_RUN),true) | ||
DRY_RUN_SIGN := --dry-run | ||
endif | ||
|
||
SHELL := /bin/bash | ||
|
||
include hack/make/version.mk | ||
include hack/make/tools.mk | ||
|
||
.PHONY: build | ||
build: ## build all policies. | ||
|
@@ -55,15 +65,27 @@ build: ## build all policies. | |
$(RUNNER) run --rm \ | ||
-e USER=$(shell id -u) -e GROUP=$(shell id -g) \ | ||
-v $(shell pwd)/build/$(subst :,/,$*):/dist \ | ||
rancher-selinux:$(subst :,/,$*) ./repo-metadata | ||
rancher-selinux:$(subst :,/,$*) ./metadata | ||
|
||
upload: $(AWSCLI) version ## uploads all artefacts from each policy into S3. | ||
$(MAKE) $(addsuffix -upload, $(POLICIES)) | ||
|
||
%-upload: | ||
RPM_CHANNEL=$(RPM_CHANNEL) POLICY=$(subst :,/,$*) \ | ||
TESTING_AWS_ACCESS_KEY_ID="$(TESTING_AWS_ACCESS_KEY_ID)" \ | ||
TESTING_AWS_SECRET_ACCESS_KEY="$(TESTING_AWS_SECRET_ACCESS_KEY)" \ | ||
TESTING_AWS_S3_BUCKET="$(TESTING_AWS_S3_BUCKET)" \ | ||
PRODUCTION_AWS_ACCESS_KEY_ID="$(PRODUCTION_AWS_ACCESS_KEY_ID)" \ | ||
PRODUCTION_AWS_SECRET_ACCESS_KEY="$(PRODUCTION_AWS_SECRET_ACCESS_KEY)" \ | ||
PRODUCTION_AWS_S3_BUCKET="$(PRODUCTION_AWS_S3_BUCKET)" \ | ||
./hack/upload | ||
|
||
version: ## parse and display version. | ||
ifdef VERSION_MSG | ||
@echo $(VERSION_MSG); exit 1 | ||
endif | ||
|
||
@echo Version Information | ||
@echo | ||
@echo RPM_VERSION: $(RPM_VERSION) | ||
@echo RPM_RELEASE: $(RPM_RELEASE) | ||
@echo RPM_CHANNEL: $(RPM_CHANNEL) | ||
|
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,7 @@ | ||
TOOLS_BIN := $(shell mkdir -p build/tools && realpath build/tools) | ||
|
||
AWSCLI = $(TOOLS_BIN)/aws/dist/aws | ||
$(AWSCLI): ## Download awscliv2 if not yet downloaded. | ||
curl "https://awscli.amazonaws.com/awscli-exe-linux-$(shell uname -m).zip" -o "$(TOOLS_BIN)/awscliv2.zip" | ||
cd $(TOOLS_BIN) && unzip -q $(TOOLS_BIN)/awscliv2.zip | ||
rm $(TOOLS_BIN)/awscliv2.zip |
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,86 @@ | ||
#!/bin/bash | ||
set -eo pipefail | ||
|
||
declare AWS_S3_BUCKET_VAR | ||
|
||
function check_vars() | ||
{ | ||
echo "checking for required vars" | ||
|
||
local required_vars | ||
required_vars=(RPM_CHANNEL POLICY) | ||
|
||
for var in "${required_vars[@]}"; do | ||
[ -z "${!var}" ] && echo "$var is not set." && var_unset=true | ||
done | ||
|
||
[ -n "${var_unset}" ] && exit 1 | ||
return 0 | ||
} | ||
|
||
function aws_auth() | ||
{ | ||
case "${RPM_CHANNEL}" in | ||
"testing") | ||
export AWS_ACCESS_KEY_ID="${TESTING_AWS_ACCESS_KEY_ID}" | ||
export AWS_SECRET_ACCESS_KEY="${TESTING_AWS_SECRET_ACCESS_KEY}" | ||
export AWS_S3_BUCKET_VAR=TESTING_AWS_S3_BUCKET | ||
;; | ||
"production") | ||
export AWS_ACCESS_KEY_ID="${PRODUCTION_AWS_ACCESS_KEY_ID}" | ||
export AWS_SECRET_ACCESS_KEY="${PRODUCTION_AWS_SECRET_ACCESS_KEY}" | ||
export AWS_S3_BUCKET_VAR=PRODUCTION_AWS_S3_BUCKET | ||
;; | ||
*) | ||
echo "RPM_CHANNEL $RPM_CHANNEL does not match one of: [testing, production]" | ||
exit 1 | ||
;; | ||
esac | ||
|
||
required_vars=("${AWS_S3_BUCKET_VAR}" AWS_ACCESS_KEY_ID AWS_SECRET_ACCESS_KEY) | ||
for var in "${required_vars[@]}"; do | ||
[ -z "${!var}" ] && echo "$var is not set." && var_unset=true | ||
done | ||
|
||
[ -n "${var_unset}" ] && echo "failing rpm upload" && exit 1 | ||
return 0 | ||
} | ||
|
||
function upload_artefacts() | ||
{ | ||
case "${POLICY}" in | ||
"centos7") | ||
S3_POLICY_DIR="centos/7" | ||
;; | ||
"centos8") | ||
S3_POLICY_DIR="centos/8" | ||
;; | ||
"centos9") | ||
S3_POLICY_DIR="centos/9" | ||
;; | ||
"fedora37") | ||
S3_POLICY_DIR="fedora/37" | ||
;; | ||
"microos") | ||
S3_POLICY_DIR="microos" | ||
;; | ||
*) | ||
echo "unsupported policy: ${POLICY}" | ||
exit 1 | ||
;; | ||
esac | ||
|
||
echo "Uploading RPMs packages and repo metadata files" | ||
############################## | ||
echo aws s3 cp "build/${POLICY}/noarch/" "s3://${!AWS_S3_BUCKET_VAR}/rancher/${RPM_CHANNEL}/${S3_POLICY_DIR}/noarch/" --recursive | ||
echo aws s3 cp "build/${POLICY}/source/" "s3://${!AWS_S3_BUCKET_VAR}/rancher/${RPM_CHANNEL}/${S3_POLICY_DIR}/source/" --recursive | ||
} | ||
|
||
function main() | ||
{ | ||
check_vars | ||
aws_auth | ||
upload_artefacts | ||
} | ||
|
||
main |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.