Skip to content

Commit

Permalink
init
Browse files Browse the repository at this point in the history
  • Loading branch information
janosmiko committed May 10, 2024
1 parent fb86ea3 commit aa59deb
Show file tree
Hide file tree
Showing 238 changed files with 180,610 additions and 168 deletions.
38 changes: 20 additions & 18 deletions .goreleaser.dev.yml → .dev.goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ builds:
- CGO_ENABLED=0
main: ./cmd/cloud
ldflags:
- -s -w -X main.VERSION={{.Tag}}-{{ time "200601021504" }}
- -s -w -X main.github.com/rewardenv/reward-cloud-cli/internal/globals.CLITOKEN={{ .Env.REWARD_CLOUD_CLI_TOKEN }} -X main.github.com/rewardenv/reward-cloud-cli/internal/globals.VERSION={{.Tag}}-{{ time "200601021504" }}
goos:
- linux
- windows
Expand All @@ -19,16 +19,17 @@ builds:
- amd64
- "386"
archives:
- replacements:
darwin: Darwin
linux: Linux
windows: Windows
386: i386
amd64: x86_64
format_overrides:
- format_overrides:
- goos: windows
format: zip
name_template: '{{- .ProjectName -}}_{{- .Os -}}_{{- if and (eq .Os "Linux") (eq .Arch "arm64") -}}aarch64{{- else -}}{{- .Arch -}}{{- end -}}'
name_template: |
{{- .ProjectName -}}_
{{- title .Os -}}_
{{- if and (eq .Os "linux") (eq .Arch "arm64") -}}aarch64
{{- else if eq .Arch "amd64" -}}x86_64
{{- else if eq .Arch "386" }}i386
{{- else }}{{- .Arch -}}
{{- end -}}
files:
- none*
release:
Expand All @@ -46,13 +47,14 @@ changelog:
- '^test:'
nfpms:
- package_name: reward-cloud
file_name_template: '{{- .ProjectName -}}_{{- .Os -}}_{{- if and (eq .Os "Linux") (eq .Arch "arm64") -}}aarch64{{- else -}}{{- .Arch -}}{{- end -}}'
replacements:
darwin: Darwin
linux: Linux
windows: Windows
386: i386
amd64: x86_64
file_name_template: |
{{- .ProjectName -}}_
{{- title .Os -}}_
{{- if and (eq .Os "linux") (eq .Arch "arm64") -}}aarch64
{{- else if eq .Arch "amd64" -}}x86_64
{{- else if eq .Arch "386" }}i386
{{- else }}{{- .Arch -}}
{{- end -}}
maintainer: Janos Miko <[email protected]>
description: Reward-Cloud is a plugin for Reward to manipulate Cloud environments.
license: MIT
Expand All @@ -67,7 +69,7 @@ nfpms:
rpm:
compression: lzma
brews:
- tap:
- repository:
owner: rewardenv
name: homebrew-tap
token: "{{ .Env.HOMEBREW_TAP_GITHUB_TOKEN }}"
Expand All @@ -78,7 +80,7 @@ brews:
folder: Formula
description: Reward-Cloud is a plugin for Reward to manipulate Cloud environments.
license: MIT
skip_upload: "true"
skip_upload: "false"
dependencies:
- name: reward-beta
type: optional
1 change: 1 addition & 0 deletions .env.sample
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
REWARD_CLOUD_CLI_TOKEN=
1 change: 1 addition & 0 deletions .envrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
dotenv
3 changes: 2 additions & 1 deletion .github/workflows/dev-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ jobs:
uses: goreleaser/goreleaser-action@v2
with:
version: latest
args: release --clean --config .goreleaser.dev.yml
args: release --clean --config .dev.goreleaser.yml
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
HOMEBREW_TAP_GITHUB_TOKEN: ${{ secrets.HOMEBREW_TAP_GITHUB_TOKEN }}
REWARD_CLOUD_CLI_TOKEN: ${{ secrets.REWARD_CLOUD_CLI_TOKEN }}
1 change: 1 addition & 0 deletions .github/workflows/main-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,4 @@ jobs:
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
HOMEBREW_TAP_GITHUB_TOKEN: ${{ secrets.HOMEBREW_TAP_GITHUB_TOKEN }}
REWARD_CLOUD_CLI_TOKEN: ${{ secrets.REWARD_CLOUD_CLI_TOKEN }}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -100,3 +100,4 @@ Network Trash Folder
Temporary Items
.apdisk

.env
39 changes: 21 additions & 18 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ builds:
- CGO_ENABLED=0
main: ./cmd/cloud
ldflags:
- -s -w -X main.VERSION={{.Tag}}
- -s -w -X github.com/rewardenv/reward-cloud-cli/internal/globals.CLITOKEN={{ .Env.REWARD_CLOUD_CLI_TOKEN }} -X github.com/rewardenv/reward-cloud-cli/internal/globals.VERSION={{.Tag}}-{{ time "200601021504" }}
goos:
- linux
- windows
Expand All @@ -19,16 +19,17 @@ builds:
- amd64
- "386"
archives:
- replacements:
darwin: Darwin
linux: Linux
windows: Windows
386: i386
amd64: x86_64
format_overrides:
- format_overrides:
- goos: windows
format: zip
name_template: '{{- .ProjectName -}}_{{- .Os -}}_{{- if and (eq .Os "Linux") (eq .Arch "arm64") -}}aarch64{{- else -}}{{- .Arch -}}{{- end -}}'
name_template: |
{{- .ProjectName -}}_
{{- title .Os -}}_
{{- if and (eq .Os "linux") (eq .Arch "arm64") -}}aarch64
{{- else if eq .Arch "amd64" -}}x86_64
{{- else if eq .Arch "386" }}i386
{{- else }}{{- .Arch -}}
{{- end -}}
files:
- none*
release:
Expand All @@ -44,13 +45,15 @@ changelog:
- '^test:'
nfpms:
- package_name: reward-cloud
file_name_template: '{{- .ProjectName -}}_{{- .Os -}}_{{- if and (eq .Os "Linux") (eq .Arch "arm64") -}}aarch64{{- else -}}{{- .Arch -}}{{- end -}}'
replacements:
darwin: Darwin
linux: Linux
windows: Windows
386: i386
amd64: x86_64
file_name_template: |
{{- .ProjectName -}}_
{{- title .Os -}}_
{{- if and (eq .Os "linux") (eq .Arch "arm64") -}}aarch64
{{- else if eq .Arch "amd64" -}}x86_64
{{- else if eq .Arch "386" }}i386
{{- else }}{{- .Arch -}}
{{- end -}}
maintainer: Janos Miko <[email protected]>
description: Reward-Cloud is a plugin for Reward to manipulate Cloud environments.
license: MIT
Expand All @@ -65,7 +68,7 @@ nfpms:
rpm:
compression: lzma
brews:
- tap:
- repository:
owner: rewardenv
name: homebrew-tap
token: "{{ .Env.HOMEBREW_TAP_GITHUB_TOKEN }}"
Expand All @@ -76,7 +79,7 @@ brews:
folder: Formula
description: Reward-Cloud is a plugin for Reward to manipulate Cloud environments.
license: MIT
skip_upload: "true"
skip_upload: "false"
dependencies:
- name: reward
type: optional
28 changes: 28 additions & 0 deletions .local.goreleaser.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
---
project_name: reward-cloud
before:
hooks:
- go mod download
- go generate ./...
builds:
- env:
- CGO_ENABLED=0
main: ./cmd/cloud
ldflags:
- -s -w -X github.com/rewardenv/reward-cloud-cli/internal/globals.CLITOKEN={{ .Env.REWARD_CLOUD_CLI_TOKEN }} -X github.com/rewardenv/reward-cloud-cli/internal/globals.VERSION={{.Tag}}-{{ time "200601021504" }}
goos:
- linux
- windows
- darwin
goarch:
- arm64
- amd64
- "386"
archives:
- format: binary
changelog:
sort: asc
filters:
exclude:
- '^docs:'
- '^test:'
22 changes: 19 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ ifeq (gen,$(firstword $(MAKECMDGOALS)))
$(eval $(GEN_ARGS):;@:)
endif

## —— Commands —————————————————————————————————————————————————————————
## —— Commands —————————————————————————————————————————————————————————————————
build: ## Build the command to ./dist
go mod download
go generate ./...
Expand All @@ -25,9 +25,9 @@ package: ## Build the binaries and packages using goreleaser (without releasing
goreleaser --clean --snapshot --skip-publish

build-local: ## Build the binaries only using goreleaser (without releasing it)
goreleaser --clean --snapshot --skip-publish
goreleaser --clean --snapshot --skip-publish --config .local.goreleaser.yml

## —— Go Commands —————————————————————————————————————————————————————————
## —— Go Commands ——————————————————————————————————————————————————————————————
gomod: ## Update Go Dependencies
go mod tidy

Expand All @@ -39,3 +39,19 @@ lint-fix: ## Lint Go Code

test: ## Run Go tests
go test -race -v ./...

## —— API Generation Commands ——————————————————————————————————————————————————
api-remove-jsonld: ## Remove JSON-LD files
docker run --rm -v "$${PWD}:/app" -w /app python:3 /bin/bash -c 'pip3 install -r hack/requirements.txt && python3 hack/main.py --input pkg/api/reward-cloud-api.yaml --output pkg/api/reward-cloud-api-no-jsonld.yaml'

.PHONY: generate
api-generate: ## Generate Go code from OpenAPI spec
#docker run --rm -v "$${PWD}/pkg/api/:/app" -w /app openapitools/openapi-generator-cli:v7.4.0 generate -i reward-cloud-api.yaml -c config.yaml -g go --global-property apiTests=false,apiDocs=false,modelTests=false,modelDocs=false -o rewardcloud
docker run --rm -v "$${PWD}/pkg/api/:/app" -w /app openapitools/openapi-generator-cli:v7.0.1 generate -i reward-cloud-api-no-jsonld.yaml -c config.yaml -g go --global-property apiTests=false,apiDocs=false,modelTests=false,modelDocs=false -o rewardcloud
rm -f pkg/api/rewardcloud/go.mod && rm -f pkg/api/rewardcloud/go.sum
go fmt ./pkg/api/...

.PHONY: all
api: ## Generate Go code from OpenAPI spec
make api-remove-jsonld
make api-generate
6 changes: 6 additions & 0 deletions assets/assets.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package assets

import "embed"

//go:embed all:*
var Assets embed.FS
28 changes: 28 additions & 0 deletions assets/templates/build/Dockerfile.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{{- if eq .Values.projectType "magento" -}}
{{- include "magento-dockerfile-start" . | nindent 0 -}}
{{- else if eq .Values.projectType "wordpress" -}}
{{- include "wordpress-dockerfile-start" . | nindent 0 -}}
{{- else if eq .Values.projectType "shopware" -}}
{{- include "shopware-dockerfile-start" . | nindent 0 -}}
{{- else if eq .Values.projectType "magento-pwa" -}}
{{- include "magento-pwa-dockerfile-start" . | nindent 0 -}}
{{- else if eq .Values.projectType "shopware-pwa" -}}
{{- include "shopware-pwa-dockerfile-start" . | nindent 0 -}}
{{- end }}

{{- range $key, $value := .Values.envVars }}
ARG {{ printf "%s=%s" $key $value }}
ENV {{ printf "%s $%s" $key $key }}
{{- end }}

{{- if eq .Values.projectType "magento" -}}
{{- include "magento-dockerfile-end" . | nindent 0 -}}
{{- else if eq .Values.projectType "wordpress" -}}
{{- include "wordpress-dockerfile-end" . | nindent 0 -}}
{{- else if eq .Values.projectType "shopware" -}}
{{- include "shopware-dockerfile-end" . | nindent 0 -}}
{{- else if eq .Values.projectType "magento-pwa" -}}
{{- include "magento-pwa-dockerfile-end" . | nindent 0 -}}
{{- else if eq .Values.projectType "shopware-pwa" -}}
{{- include "shopware-pwa-dockerfile-end" . | nindent 0 -}}
{{- end }}
7 changes: 7 additions & 0 deletions assets/templates/build/_common.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{{- define "php-version" -}}
{{- printf "%s" .Values.phpVersion -}}
{{- end -}}

{{- define "build-image-suffix" -}}
-debian-bullseye-rootless
{{- end -}}
75 changes: 75 additions & 0 deletions assets/templates/build/_magento.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
{{- define "magento-dockerfile-start" -}}
FROM rewardenv/php-fpm:{{ include "php-version" . }}-magento2-web{{ include "build-image-suffix" . }}

ARG COMPOSER_INSTALL
ARG COMPOSER_VERSION=2.2.19
ARG COMPOSER_AUTH
ARG COMPOSER_GITHUB_USER
ARG COMPOSER_GITHUB_TOKEN
ARG COMPOSER_BITBUCKET_PUBLIC_KEY
ARG COMPOSER_BITBUCKET_PRIVATE_KEY
ARG COMPOSER_GITLAB_HOST
ARG COMPOSER_GITLAB_OAUTH_TOKEN
ARG COMPOSER_GITLAB_TOKEN
ARG MAGENTO_PUBLIC_KEY
ARG MAGENTO_PRIVATE_KEY
ARG MAGENTO_LANGUAGES
ARG MAGENTO_DI_COMPILE=true
ARG MAGENTO_STATIC_CONTENT_DEPLOY=false
ARG MAGENTO_DEV_STATIC_SIGN=true
ARG MAGENTO_DEV_JS_MERGE=true
ARG MAGENTO_DEV_JS_MINIFY=true
ARG MAGENTO_DEV_JS_BUNDLING=false
ARG MAGENTO_DEV_CSS_MERGE=true
ARG MAGENTO_DEV_CSS_MINIFY=true
ARG MAGENTO_DEV_HTML_MINIFY=false
ARG COMMAND_BEFORE_COMPOSER_INSTALL
ARG COMMAND_AFTER_COMPOSER_INSTALL
ARG COMMAND_BEFORE_DI_COMPILE
ARG COMMAND_AFTER_DI_COMPILE
ARG COMPOSER_DUMP_AUTOLOAD=true
{{- end -}}

{{- define "magento-dockerfile-end" -}}
COPY --chown=www-data:www-data . .

RUN <<-EOF
set -eux
if [ "${COMPOSER_VERSION:-2}" = "1" ]; then
alternatives --altdir ~/.local/etc/alternatives --admindir ~/.local/var/lib/alternatives --set composer "${HOME}/.local/bin/composer1";
else
alternatives --altdir ~/.local/etc/alternatives --admindir ~/.local/var/lib/alternatives --set composer "${HOME}/.local/bin/composer2";
if [ "${COMPOSER_VERSION:-2}" = "2" ]; then
composer self-update --stable;
else
composer self-update "${COMPOSER_VERSION:-2}";
fi
fi
if [ -n "${MAGENTO_PUBLIC_KEY-}" ]; then composer global config http-basic.repo.magento.com ${MAGENTO_PUBLIC_KEY-} ${MAGENTO_PRIVATE_KEY-}; fi
if [ -n "${COMPOSER_GITHUB_USER-}" ]; then composer global config http-basic.github.com ${COMPOSER_GITHUB_USER-} ${COMPOSER_GITHUB_TOKEN-}; fi
if [ -n "${COMPOSER_BITBUCKET_PUBLIC_KEY-}" ]; then composer global config bitbucket-oauth.bitbucket.org ${COMPOSER_BITBUCKET_PUBLIC_KEY-} ${COMPOSER_BITBUCKET_PRIVATE_KEY-}; fi
if [ -n "${COMPOSER_GITLAB_OAUTH_TOKEN-}" ]; then composer global config gitlab-oauth.${COMPOSER_GITLAB_HOST:-gitlab.com} ${COMPOSER_GITLAB_OAUTH_TOKEN-}; fi
if [ -n "${COMPOSER_GITLAB_TOKEN-}" ]; then composer global config gitlab-oauth.${COMPOSER_GITLAB_HOST:-gitlab.com} ${COMPOSER_GITLAB_TOKEN-}; fi
if [ -n "${COMMAND_BEFORE_COMPOSER_INSTALL-}" ]; then eval "${COMMAND_BEFORE_COMPOSER_INSTALL-}"; fi
if [ "${COMPOSER_VERSION:-2}" != "1" ]; then composer config --no-plugins allow-plugins.magento/* true; fi
if [ "${COMPOSER_VERSION:-2}" != "1" ]; then composer config --no-plugins allow-plugins.laminas/laminas-dependency-plugin true; fi
if [ "${COMPOSER_VERSION:-2}" != "1" ]; then composer config --no-plugins allow-plugins.dealerdirect/phpcodesniffer-composer-installer true; fi
if [ "${COMPOSER_VERSION:-2}" != "1" ]; then composer config --no-plugins allow-plugins.cweagans/composer-patches true; fi
if [ "${COMPOSER_INSTALL:-true}" = "true" ]; then composer install --no-interaction --no-progress; fi
if [ -n "${COMMAND_AFTER_COMPOSER_INSTALL-}" ]; then eval "${COMMAND_AFTER_COMPOSER_INSTALL-}"; fi
composer --no-interaction clear-cache
if [ -n "${COMMAND_BEFORE_DI_COMPILE-}" ]; then eval "${COMMAND_BEFORE_DI_COMPILE}"; fi
if [ ! -f app/etc/config.php ]; then
php bin/magento module:enable --no-interaction --all;
fi
if [ "${MAGENTO_DI_COMPILE-}" = "true" ] && [ "${MAGENTO_DI_COMPILE_ON_DEMAND:-false}" != "true" ]; then
php bin/magento setup:di:compile --no-interaction;
fi
if [ -n "${COMMAND_AFTER_DI_COMPILE-}" ]; then eval "${COMMAND_AFTER_DI_COMPILE-}"; fi
if [ "${COMPOSER_DUMP_AUTOLOAD-}" = "true" ]; then composer dump-autoload -o; fi
if [ "${MAGENTO_STATIC_CONTENT_DEPLOY-}" = "true" ] && [ "${MAGENTO_SCD_ON_DEMAND:-false}" != "true" ];
then bin/magento setup:static-content:deploy --no-interaction --jobs=$(nproc) -fv ${MAGENTO_LANGUAGES:-};
fi
printf "<?php\nprintf(\"php-version: %%g </br>\", phpversion());\nprintf(\"build-date: $(date '+%Y/%m/%d %H:%M:%S')\");\n?>\n" > pub/version.php
EOF
{{- end -}}
Loading

0 comments on commit aa59deb

Please sign in to comment.