Skip to content

v1.45.0-beta.1

v1.45.0-beta.1 #104

name: "packages manager"
on:
release:
types:
- published
jobs:
get_branch:
runs-on: ubuntu-24.04
outputs:
is_main: ${{ steps.verify_branch.outputs.is_main }}
version: ${{ steps.verify_branch.outputs.version }}
steps:
- uses: actions/checkout@v4
- id: verify_branch
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
RAW_RELEASE=$(gh release list --repo $GITHUB_REPOSITORY --limit 1 --json tagName --jq '.[0].tagName')
FORMATTED_RELEASE=$(echo "$RAW_RELEASE" | sed -E 's/-[a-zA-Z0-9.]+//')
echo "Raw release: $RAW_RELEASE"
echo "Formatted release: $FORMATTED_RELEASE"
if [ "$RAW_RELEASE" = "$FORMATTED_RELEASE" ]; then
echo "is_main=true" >> $GITHUB_OUTPUT
else
echo "is_main=false" >> $GITHUB_OUTPUT
fi
version=$(echo "$RAW_RELEASE" | sed 's/^v//')
echo "version=$version" >> $GITHUB_OUTPUT
wait_release:
needs: get_branch
runs-on: ubuntu-24.04
if: needs.get_branch.outputs.is_main == 'true'
steps:
- name: Wait for 10 minutes
run: sleep 600
# NOTE: our cli is in homebrew's autobump.txt because it has been updated so much
# brew_release:
# needs: [get_branch, wait_job]
# runs-on: ubuntu-24.04
# if: needs.get_branch.outputs.is_main == 'true'
# steps:
# - name: Update Homebrew Formula
# uses: dawidd6/action-homebrew-bump-formula@v4
# with:
# token: ${{ secrets.RELEASE_GITHUB_TOKEN }}
# formula: mdz
chocolatey_release:
needs: [get_branch, wait_release]
runs-on: windows-latest
if: needs.get_branch.outputs.is_main == 'true'
steps:
- name: Checkout code
uses: actions/checkout@v3
- 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${{ needs.get_branch.outputs.version }}/midaz_${{ needs.get_branch.outputs.version }}_windows_amd64.zip"
Write-Host "Downloading ZIP from $url to $zipFile"
Invoke-WebRequest -Uri $url -OutFile $zipFile
Write-Host "Extracting $zipFile to $toolsDir"
Expand-Archive -Path $zipFile -DestinationPath $toolsDir -Force
shell: pwsh
- name: Prepare
run: |
# Checksum Calculate
$zipFile = "$(Resolve-Path .\chocolatey\tools\mdz.zip)"
$checksum = (Get-FileHash -Path $zipFile -Algorithm SHA256).Hash
Remove-Item $zipFile
Write-Host "Updating nuspec version to ${{ needs.get_branch.outputs.version }}"
$nuspecPath = Resolve-Path .\chocolatey\mdz.nuspec
(Get-Content $nuspecPath) -replace '<version>.*</version>', "<version>${{ needs.get_branch.outputs.version }}</version>" | Set-Content $nuspecPath
Write-Host "Updating Checksum files $checksum"
$chocoInstallPath = Resolve-Path .\chocolatey\tools\chocolateyinstall.ps1
(Get-Content $chocoInstallPath) -replace '{{CHECKSUM}}', "$checksum" | Set-Content $chocoInstallPath
$verificationPath = Resolve-Path .\chocolatey\tools\VERIFICATION.txt
(Get-Content $verificationPath) -replace '{{CHECKSUM}}', "$checksum" | Set-Content $verificationPath
(Get-Content $verificationPath) -replace '{{VERSION}}', "${{ needs.get_branch.outputs.version }}" -replace '{{VERSION}}', "${{ needs.get_branch.outputs.version }}" | Set-Content $verificationPath
shell: pwsh
- name: Publish Chocolatey package
env:
CHOCO_API_KEY: ${{ secrets.CHOCO_TOKEN }}
shell: pwsh
run: |
choco pack chocolatey/mdz.nuspec
# install local test
choco install mdz --version=${{ needs.get_branch.outputs.version }} --prerelease --source="D:\a\midaz\midaz"
mdz version
choco apikey add -s="https://push.chocolatey.org/" -k="$env:CHOCO_API_KEY"
choco push mdz.${{ needs.get_branch.outputs.version }}.nupkg --source https://push.chocolatey.org/
# test install public mdz chocolatey
choco install mdz --version=${{ needs.get_branch.outputs.version }} --prerelease
mdz version