diff --git a/.github/workflows/packages-manager.yml b/.github/workflows/packages-manager.yml index b3b6af56..89193ac1 100644 --- a/.github/workflows/packages-manager.yml +++ b/.github/workflows/packages-manager.yml @@ -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" | 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 diff --git a/.goreleaser.yml b/.goreleaser.yml index da7c8806..3644f69d 100644 --- a/.goreleaser.yml +++ b/.goreleaser.yml @@ -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 diff --git a/chocolatey/mdz.nuspec b/chocolatey/mdz.nuspec new file mode 100644 index 00000000..f49eb86b --- /dev/null +++ b/chocolatey/mdz.nuspec @@ -0,0 +1,22 @@ + + + + mdz + 2.0.0 + mdz + Lerian Studio + https://github.com/LerianStudio/midaz + https://github.com/LerianStudio/midaz/blob/main/LICENSE + https://avatars.githubusercontent.com/u/148895005?s=200&v=4 + mdz cli ledger golang financial + An open-source ledger for multi-asset, multi-currency financial systems. + + 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. + + + + + + diff --git a/chocolatey/tools/chocolateyinstall.ps1 b/chocolatey/tools/chocolateyinstall.ps1 new file mode 100644 index 00000000..661ffa61 --- /dev/null +++ b/chocolatey/tools/chocolateyinstall.ps1 @@ -0,0 +1,40 @@ +$ErrorActionPreference = 'Stop'; + +$toolsDir = "$(Split-Path -parent $MyInvocation.MyCommand.Definition)" +$binDir = Join-Path $env:ChocolateyInstall 'bin' +$outputFile = Join-Path $toolsDir 'mdz.exe' + +# URL do arquivo zipado +$url = 'https://github.com/maxwelbm/mdz/releases/download/v0.5.7/mdz_0.5.7_windows_amd64.zip' +$checksum = '{{CHECKSUM}}' +$silentArgs = '' + +# Argumentos do pacote +$packageArgs = @{ + packageName = 'mdz' + unzipLocation = $toolsDir + url = $url + softwareName = 'mdz*' + checksum = $checksum + checksumType = 'sha256' +} + +# Instalar e descompactar o pacote +Install-ChocolateyZipPackage @packageArgs + +# Verificar se o arquivo .exe foi extraído corretamente +if (-Not (Test-Path $outputFile)) { + throw "O arquivo mdz.exe não foi encontrado após a extração do zip." +} + +# Certificar-se de que o diretório global 'bin' existe +if (-Not (Test-Path $binDir)) { + New-Item -ItemType Directory -Path $binDir | Out-Null +} + +# Mover o executável para o diretório global +Write-Host "Copiando $outputFile para $binDir" +Copy-Item -Path $outputFile -Destination $binDir -Force + +# Confirmar a instalação +Write-Host "Instalação completa. O executável mdz está disponível globalmente." diff --git a/chocolatey/tools/chocolateyuninstall.ps1 b/chocolatey/tools/chocolateyuninstall.ps1 new file mode 100644 index 00000000..32ff075e --- /dev/null +++ b/chocolatey/tools/chocolateyuninstall.ps1 @@ -0,0 +1,36 @@ +$ErrorActionPreference = 'Stop'; # Stop on all errors + +# Define the paths +$binDir = Join-Path $env:ChocolateyInstall 'bin' +$mdzExecutable = Join-Path $binDir 'mdz.exe' + +# Uninstallation process +Write-Host "Attempting to remove Mdz executable from $binDir..." + +if (Test-Path $mdzExecutable) { + try { + Remove-Item -Path $mdzExecutable -Force + Write-Host "Successfully removed Mdz executable from $binDir." + } catch { + Write-Warning "Failed to remove Mdz executable from $binDir. Error: $_" + } +} else { + Write-Warning "Mdz executable not found in $binDir. Nothing to remove." +} + +# Clean up additional files in the tools directory +$toolsDir = "$(Split-Path -Parent $MyInvocation.MyCommand.Definition)" +Write-Host "Cleaning up tools directory: $toolsDir" + +if (Test-Path $toolsDir) { + try { + Remove-Item -Path $toolsDir -Recurse -Force + Write-Host "Successfully cleaned up tools directory." + } catch { + Write-Warning "Failed to clean up tools directory. Error: $_" + } +} else { + Write-Warning "Tools directory not found. Nothing to clean up." +} + +Write-Host "Uninstallation complete." diff --git a/components/audit/.env.example b/components/audit/.env.example index 1fe629ea..01e48aa5 100644 --- a/components/audit/.env.example +++ b/components/audit/.env.example @@ -2,7 +2,7 @@ # ENV_NAME=production # APP -VERSION=v1.36.0 +VERSION=v1.37.0 SERVER_PORT=3005 SERVER_ADDRESS=:${SERVER_PORT} diff --git a/components/ledger/.env.example b/components/ledger/.env.example index b146e5c2..fc082468 100644 --- a/components/ledger/.env.example +++ b/components/ledger/.env.example @@ -4,7 +4,7 @@ # ENV_NAME=production # APP -VERSION=v1.36.0 +VERSION=v1.37.0 SERVER_PORT=3000 SERVER_ADDRESS=:${SERVER_PORT} diff --git a/components/mdz/.env.example b/components/mdz/.env.example index 47a444d8..26da0631 100644 --- a/components/mdz/.env.example +++ b/components/mdz/.env.example @@ -2,4 +2,4 @@ CLIENT_ID=9670e0ca55a29a466d31 CLIENT_SECRET=dd03f916cacf4a98c6a413d9c38ba102dce436a9 URL_API_AUTH=http://127.0.0.1:8080 URL_API_LEDGER=http://127.0.0.1:3000 -VERSION=v1.36.0 +VERSION=v1.37.0 diff --git a/components/transaction/.env.example b/components/transaction/.env.example index d122115f..775a31bf 100644 --- a/components/transaction/.env.example +++ b/components/transaction/.env.example @@ -4,7 +4,7 @@ # ENV_NAME=production # APP -VERSION=v1.36.0 +VERSION=v1.37.0 APP_CONTEXT=/transaction/v1 SERVER_PORT=3002 SERVER_ADDRESS=:${SERVER_PORT}