Skip to content

Commit

Permalink
Merge pull request #418 from LerianStudio/develop
Browse files Browse the repository at this point in the history
merge: develop to main
  • Loading branch information
maxwelbm authored Dec 23, 2024
2 parents fd0afae + a38fa62 commit ff8f5ce
Show file tree
Hide file tree
Showing 16 changed files with 513 additions and 184 deletions.
83 changes: 83 additions & 0 deletions .github/workflows/packages-manager.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,86 @@ jobs:
with:
token: ${{ secrets.RELEASE_GITHUB_TOKEN }}
formula: mdz

choco_release:
if: github.ref == 'refs/heads/main'
runs-on: windows-latest
steps:
- name: Checkout code
uses: actions/checkout@v3

- uses: actions/create-github-app-token@v1
id: app-token
with:
app-id: ${{ secrets.LERIAN_STUDIO_MIDAZ_PUSH_BOT_APP_ID }}
private-key: ${{ secrets.LERIAN_STUDIO_MIDAZ_PUSH_BOT_PRIVATE_KEY }}

- name: Fetch Latest Tag
id: latest_tag
env:
GH_TOKEN: ${{ steps.app-token.outputs.token }}
run: |
$RawRelease = gh release list --repo $env:GITHUB_REPOSITORY --limit 1 --json tagName --jq '.[0].tagName'
$FormattedRelease = $RawRelease -replace '^v', ''
Write-Host "Formatted release: $FormattedRelease"
echo "tag=$FormattedRelease" >> $env:GITHUB_ENV
shell: pwsh

- name: Set up Chocolatey
run: |
Set-ExecutionPolicy Bypass -Scope Process -Force
[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072
Invoke-WebRequest https://chocolatey.org/install.ps1 -UseBasicParsing | Invoke-Expression
shell: pwsh

- name: Update nuspec version
run: |
$nuspecPath = Resolve-Path .\chocolatey\mdz.nuspec
if (-Not (Test-Path $nuspecPath)) {
Write-Error "The nuspec file was not found at $nuspecPath"
exit 1
}

$version = '${{ env.tag }}'
Write-Host "Updating nuspec version to $version"
(Get-Content $nuspecPath) -replace '<version>.*</version>', "<version>$version</version>" | Set-Content $nuspecPath
shell: pwsh

- name: Download and extract ZIP
run: |
$toolsDir = "$(Resolve-Path .\chocolatey\tools)"
New-Item -ItemType Directory -Force -Path $toolsDir | Out-Null
$zipFile = Join-Path $toolsDir 'mdz.zip'
$outputFile = Join-Path $toolsDir 'mdz.exe'
$url = 'https://github.com/LerianStudio/midaz/releases/download/v${{ env.version }}/mdz_{{ env.version }}_windows_amd64.zip'
# Download the ZIP file
Write-Host "Downloading ZIP from $url to $zipFile"
Invoke-WebRequest -Uri $url -OutFile $zipFile
# Extract the ZIP file
Write-Host "Extracting $zipFile to $toolsDir"
Expand-Archive -Path $zipFile -DestinationPath $toolsDir -Force
shell: pwsh

- name: Calculate checksum
id: calculate-checksum
run: |
$outputFile = "$(Resolve-Path .\chocolatey\tools\mdz.exe)"
$checksum = (Get-FileHash -Path $outputFile -Algorithm SHA256).Hash
echo "::set-output name=checksum::$checksum"
shell: pwsh

- name: Replace checksum in chocolateyinstall.ps1
run: |
(Get-Content .\chocolatey\tools\chocolateyinstall.ps1) -replace '{{CHECKSUM}}', '${{ steps.calculate-checksum.outputs.checksum }}' | Set-Content .\chocolatey\tools\chocolateyinstall.ps1
shell: pwsh

- name: Publish Chocolatey package
env:
CHOCO_API_KEY: ${{ secrets.CHOCO_TOKEN }}
run: |
choco pack chocolatey/mdz.nuspec
choco push mdz.${{ env.version }}.nupkg --source https://push.chocolatey.org/ --api-key $env:CHOCO_API_KEY
shell: pwsh
7 changes: 1 addition & 6 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,7 @@ builds:
- -X github.com/LerianStudio/midaz/components/mdz/pkg/environment.Version={{.Version}}

archives:
- id: "mdz"
builds:
- "mdz"
format: tar.gz
name_template: "{{ .Binary }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}"
wrap_in_directory: true
- format: zip

nfpms:
- id: packages
Expand Down
22 changes: 22 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,25 @@
## [1.37.0-beta.2](https://github.com/LerianStudio/midaz/compare/v1.37.0-beta.1...v1.37.0-beta.2) (2024-12-20)


### Features

* publish cli midaz in the choco ([fac503f](https://github.com/LerianStudio/midaz/commit/fac503f593fe344ba47e3aebc9a4e880c5661d68))

## [1.37.0-beta.1](https://github.com/LerianStudio/midaz/compare/v1.36.0...v1.37.0-beta.1) (2024-12-20)


### Bug Fixes

* help :bug: ([8f9358f](https://github.com/LerianStudio/midaz/commit/8f9358f0d0608ce82f96084f0761de6edc7dcdae))
* **audit:** improve makefile changing docker-compose to a choose based version command :bug: ([14506fe](https://github.com/LerianStudio/midaz/commit/14506fec46ee5f5c946d67c7fc63135a08a739aa))
* **auth:** improve makefile changing docker-compose to a choose based version command :bug: ([d9ee74c](https://github.com/LerianStudio/midaz/commit/d9ee74c64e3e64e0b06ac390dd0feda4810b4daf))
* **infra:** improve makefile changing docker-compose to a choose based version command :bug: ([e43892c](https://github.com/LerianStudio/midaz/commit/e43892ce9eb930b2f57e0814b0b3793be11c8be7))
* **ledger:** improve makefile changing docker-compose to a choose based version command :bug: ([89552e0](https://github.com/LerianStudio/midaz/commit/89552e066cbf45e18d8d824d9ad025ef48bee71b))
* **midaz:** improve makefile changing docker-compose to a choose based version command :bug: ([9951e8c](https://github.com/LerianStudio/midaz/commit/9951e8c706c12bcee8fadf6af01186a82834f547))
* **transaction:** improve makefile changing docker-compose to a choose based version command :bug: ([44a1b1f](https://github.com/LerianStudio/midaz/commit/44a1b1fc977b85bedb59a368075089f0b2d5da2c))
* info :bug: ([3f01ba4](https://github.com/LerianStudio/midaz/commit/3f01ba4452082a728580a0296f4b64bff6c40e16))
* remove wire reference :bug: ([a7c61ee](https://github.com/LerianStudio/midaz/commit/a7c61ee2426ec1523d7750fc22041e9478f9ebad))

## [1.36.0](https://github.com/LerianStudio/midaz/compare/v1.35.0...v1.36.0) (2024-12-19)


Expand Down
64 changes: 54 additions & 10 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,38 +1,52 @@
AUDIT_DIR := ./components/audit
AUTH_DIR := ./components/auth
INFRA_DIR := ./components/infra
MDZ_DIR := ./components/mdz
LEDGER_DIR := ./components/ledger
TRANSACTION_DIR := ./components/transaction
MDZ_DIR := ./components/mdz
AUDIT_DIR := ./components/audit

.PHONY: help test cover lint format check-logs check-tests \
setup-git-hooks check-hooks goreleaser tidy sec set-env up auth infra ledger \
transaction audit all-services

BLUE := \033[36m
NC := \033[0m
BOLD := \033[1m
RED := \033[31m
MAGENTA := \033[35m

DOCKER_VERSION := $(shell docker version --format '{{.Server.Version}}')
DOCKER_MIN_VERSION := 20.10.13

DOCKER_CMD := $(shell \
if [ "$(shell printf '%s\n' "$(DOCKER_MIN_VERSION)" "$(DOCKER_VERSION)" | sort -V | head -n1)" = "$(DOCKER_MIN_VERSION)" ]; then \
echo "docker compose"; \
else \
echo "docker-compose"; \
fi \
)

.PHONY: help
help:
@echo ""
@echo ""
@echo "$(BOLD)Midaz Project Management Commands$(NC)"
@echo ""
@echo ""
@echo "$(BOLD)Core Commands:$(NC)"
@echo " make test - Run tests on all projects"
@echo " make cover - Run test coverage"
@echo ""
@echo ""
@echo "$(BOLD)Code Quality Commands:$(NC)"
@echo " make lint - Run golangci-lint and performance checks"
@echo " make format - Format Go code using gofmt"
@echo " make check-logs - Verify error logging in usecases"
@echo " make check-tests - Verify test coverage for components"
@echo " make sec - Run security checks using gosec"
@echo ""
@echo ""
@echo "$(BOLD)Git Hook Commands:$(NC)"
@echo " make setup-git-hooks - Install and configure git hooks"
@echo " make check-hooks - Verify git hooks installation status"
@echo ""
@echo ""
@echo "$(BOLD)Setup Commands:$(NC)"
@echo " make set-env - Copy .env.example to .env for all components"
@echo "Usage:"
Expand All @@ -52,6 +66,7 @@ help:
@echo " make all-services Run a command to all services passing any individual container command."
@echo " make generate-docs-all Run a command to inside the ledger and transaction app to generate swagger docs."
@echo ""
@echo ""
@echo "$(BOLD)Service Commands:$(NC)"
@echo " make up - Start all services with Docker Compose"
@echo " make auth COMMAND=<cmd> - Run command in auth service"
Expand All @@ -60,11 +75,16 @@ help:
@echo " make transaction COMMAND=<cmd> - Run command in transaction service"
@echo " make audit COMMAND=<cmd> - Run command in audit service"
@echo " make all-services COMMAND=<cmd> - Run command across all services"
@echo " make clean-docker - Run command to clean docker"
@echo ""
@echo ""
@echo "$(BOLD)Development Commands:$(NC)"
@echo " make tidy - Run go mod tidy"
@echo " make goreleaser - Create a release snapshot"
@echo ""
@echo ""

.PHONY: test
test:
@echo "$(BLUE)Running tests...$(NC)"
@if ! command -v go >/dev/null 2>&1; then \
Expand All @@ -73,6 +93,7 @@ test:
fi
go test -v ./... ./...

.PHONY: cover
cover:
@echo -e "$(BLUE)Generating test coverage...$(NC)"
@if ! command -v go >/dev/null 2>&1; then \
Expand All @@ -82,22 +103,27 @@ cover:
@sh ./scripts/coverage.sh
@go tool cover -html=coverage.out -o coverage.html

.PHONY: lint
lint:
@echo "$(BLUE)Running linter and performance checks...$(NC)"
./make.sh "lint"

.PHONY: format
format:
@echo "$(BLUE)Formatting Go code...$(NC)"
./make.sh "format"

.PHONY: check-logs
check-logs:
@echo "$(BLUE)Checking error logging in usecases...$(NC)"
./make.sh "checkLogs"

.PHONY: check-tests
check-tests:
@echo "$(BLUE)Verifying test coverage...$(NC)"
./make.sh "checkTests"

.PHONY: sec
sec:
@echo "$(BLUE)Running security checks...$(NC)"
@if ! command -v gosec >/dev/null 2>&1; then \
Expand All @@ -107,14 +133,17 @@ sec:
fi
gosec ./...

.PHONY: setup-git-hooks
setup-git-hooks:
@echo "$(BLUE)Setting up git hooks...$(NC)"
./make.sh "setupGitHooks"

.PHONY: check-hooks
check-hooks:
@echo "$(BLUE)Checking git hooks status...$(NC)"
./make.sh "checkHooks"

.PHONY: set-env
set-env:
@echo "$(BLUE)Setting up environment files...$(NC)"
cp -r $(AUTH_DIR)/.env.example $(AUTH_DIR)/.env
Expand All @@ -125,34 +154,41 @@ set-env:
cp -r $(AUDIT_DIR)/.env.example $(AUDIT_DIR)/.env
@echo "$(BLUE)Environment files created successfully$(NC)"

.PHONY: up
up:
@echo "$(BLUE)Starting all services...$(NC)"
docker-compose -f $(AUTH_DIR)/docker-compose.yml up --build -d && \
docker-compose -f $(INFRA_DIR)/docker-compose.yml up --build -d && \
docker-compose -f $(LEDGER_DIR)/docker-compose.yml up --build -d && \
docker-compose -f $(TRANSACTION_DIR)/docker-compose.yml up --build -d
@$(DOCKER_CMD) -f $(AUTH_DIR)/docker-compose.yml up --build -d
@$(DOCKER_CMD) -f $(INFRA_DIR)/docker-compose.yml up --build -d
@$(DOCKER_CMD) -f $(LEDGER_DIR)/docker-compose.yml up --build -d
@$(DOCKER_CMD) -f $(TRANSACTION_DIR)/docker-compose.yml up --build -d
@echo "$(BLUE)All services started successfully$(NC)"

.PHONY: auth
auth:
@echo "$(BLUE)Executing command in auth service...$(NC)"
$(MAKE) -C $(AUTH_DIR) $(COMMAND)

.PHONY: infra
infra:
@echo "$(BLUE)Executing command in infra service...$(NC)"
$(MAKE) -C $(INFRA_DIR) $(COMMAND)

.PHONY: ledger
ledger:
@echo "$(BLUE)Executing command in ledger service...$(NC)"
$(MAKE) -C $(LEDGER_DIR) $(COMMAND)

.PHONY: transaction
transaction:
@echo "$(BLUE)Executing command in transaction service...$(NC)"
$(MAKE) -C $(TRANSACTION_DIR) $(COMMAND)

.PHONY: audit
audit:
@echo "$(BLUE)Executing command in audit service...$(NC)"
$(MAKE) -C $(AUDIT_DIR) $(COMMAND)

.PHONY: all-services
all-services:
@echo "$(BLUE)Executing command across all services...$(NC)"
$(MAKE) -C $(AUTH_DIR) $(COMMAND) && \
Expand All @@ -161,17 +197,25 @@ all-services:
$(MAKE) -C $(TRANSACTION_DIR) $(COMMAND) && \
$(MAKE) -C $(AUDIT_DIR) $(COMMAND)

.PHONY: clean-docker
clean-docker:
docker system prune -a -f && docker volume prune -a -f

.PHONY: test_integration_cli
test_integration_cli:
go test -v -tags=integration ./components/mdz/test/integration/...

.PHONY: goreleaser
goreleaser:
@echo "$(BLUE)Creating release snapshot...$(NC)"
goreleaser release --snapshot --skip-publish --rm-dist

.PHONY: tidy
tidy:
@echo "$(BLUE)Running go mod tidy...$(NC)"
go mod tidy

.PHONY: generate-docs-all
generate-docs-all:
@echo "$(BLUE)Executing command to generate swagger...$(NC)"
$(MAKE) -C $(LEDGER_DIR) generate-docs && \
Expand Down
22 changes: 22 additions & 0 deletions chocolatey/mdz.nuspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="utf-8"?>
<package xmlns="http://schemas.microsoft.com/packaging/2015/06/nuspec.xsd">
<metadata>
<id>mdz</id>
<version>2.0.0</version>
<title>mdz</title>
<authors>Lerian Studio</authors>
<projectUrl>https://github.com/LerianStudio/midaz</projectUrl>
<licenseUrl>https://github.com/LerianStudio/midaz/blob/main/LICENSE<licenseUrl/>
<iconUrl>https://avatars.githubusercontent.com/u/148895005?s=200&v=4</iconUrl>
<tags>mdz cli ledger golang financial</tags>
<summary>An open-source ledger for multi-asset, multi-currency financial systems.</summary>
<description>
Midaz is part of Lerian's Core Banking Platform, offering an immutable ledger to modernize financial operations.
Currently under development and not production-ready.
This package provides a CLI tool to manage APIs and services from the ledger.
</description>
</metadata>
<files>
<file src="tools\**" target="tools" />
</files>
</package>
Loading

0 comments on commit ff8f5ce

Please sign in to comment.