-
Notifications
You must be signed in to change notification settings - Fork 45
130 lines (109 loc) · 4.51 KB
/
packages-manager.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
name: "packages manager"
on:
pull_request:
branches:
- develop
- main
types:
- opened
- edited
- synchronize
- reopened
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=1.42.0" >> $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
# 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
Remove-Item $zipFile
shell: pwsh
- name: Prepare
run: |
# Checksum Calculate
$outputFile = "$(Resolve-Path .\chocolatey\tools\mdz.exe)"
$checksum = (Get-FileHash -Path $outputFile -Algorithm SHA256).Hash
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
shell: pwsh
- name: Publish Chocolatey package
env:
CHOCO_API_KEY: ${{ secrets.CHOCO_TOKEN }}
shell: pwsh
run: |
choco pack chocolatey/mdz.nuspec
cd chocolatey
ls
Get-Content mdz.nuspec
cd tools
Get-Content chocolateyinstall.ps1
Get-Content VERIFICATION.txt
cd ./../..
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