v1.42.0-beta.2 #78
Workflow file for this run
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
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 | |
- 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: 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 | |
} | |
Write-Host "Updating nuspec version to ${{ needs.get_branch.outputs.version }}" | |
(Get-Content $nuspecPath) -replace '<version>.*</version>', "<version>${{ needs.get_branch.outputs.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${{ 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: Calculate checksum | |
id: calculate-checksum | |
run: | | |
$outputFile = "$(Resolve-Path .\chocolatey\tools\mdz.exe)" | |
$checksum = (Get-FileHash -Path $outputFile -Algorithm SHA256).Hash | |
echo "checksum=$checksum" >> $GITHUB_OUTPUT | |
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 }} | |
shell: pwsh | |
run: | | |
choco pack chocolatey/mdz.nuspec | |
ls | |
# 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 |