-
-
Notifications
You must be signed in to change notification settings - Fork 164
98 lines (88 loc) · 4.43 KB
/
release-chocolatey.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
name: Release Chocolatey Package
on:
# We cannot run chocolatey release continusly every time we release something as sometimes we release a couple of times a day and overload chocolatey pipelines
# More details https://github.com/asyncapi/cli/issues/503
schedule:
- cron: '0 23 * * *' # Run every day at 23:00 UTC
# Since now release depends on schedule, might be that there is a situation we cannot wait for schedule and trigger release manually
workflow_dispatch:
inputs:
version:
description: 'Version to release (optional)'
required: false
jobs:
release:
name: Publish to Chocolatey Community
runs-on: windows-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Set Version
id: release_version
run: |
if ( "${{ github.event_name }}" -eq "workflow_dispatch" -and "${{ github.event.inputs.version }}" -ne "" ) {
$version = "${{ github.event.inputs.version }}"
}
else {
$version = $(npm pkg get version)
}
$version = $version.Replace("`"", "")
echo "Setting version to $version"
echo "version=$version" >> $env:GITHUB_OUTPUT
- name: Check if this is a new version to release
id: check_new_version
run: |
$output = choco search asyncapi-cli --version=${{ steps.release_version.outputs.version }}
# Output is of the form:
# Chocolatey v2.2.2
# asyncapi-cli 0.0.1 [Approved]
# 1 packages found.
# If the version is not found, the output will of the form:
# Chocolatey v2.2.2
# 0 packages found.
if ($output -match "0 packages found.") {
echo "This is a new version to release"
echo "new_version=true" >> $env:GITHUB_OUTPUT
}
else {
echo "This is not a new version to release"
echo "new_version=false" >> $env:GITHUB_OUTPUT
}
- name: Download release
if: steps.check_new_version.outputs.new_version == 'true'
run: |
echo "Downloading release assets for version ${{ steps.release_version.outputs.version }}"
mkdir -p ./dist/win32
curl -L "https://github.com/asyncapi/cli/releases/download/v${{ steps.release_version.outputs.version }}/asyncapi.x64.exe" -o "./dist/win32/asyncapi.x64.exe"
curl -L "https://github.com/asyncapi/cli/releases/download/v${{ steps.release_version.outputs.version }}/asyncapi.x86.exe" -o "./dist/win32/asyncapi.x86.exe"
- name: Get Checksum of the release
if: steps.check_new_version.outputs.new_version == 'true'
id: release_checksum
run: |
$checksum = (Get-FileHash -Path "./dist/win32/asyncapi.x86.exe" -Algorithm SHA256).Hash
$checksum64 = (Get-FileHash -Path "./dist/win32/asyncapi.x64.exe" -Algorithm SHA256).Hash
echo "Setting checksum to $checksum"
echo "checksum=$checksum" >> $env:GITHUB_OUTPUT
echo "Setting checksum64 to $checksum64"
echo "checksum64=$checksum64" >> $env:GITHUB_OUTPUT
- name: Make nuspec from the template
if: steps.check_new_version.outputs.new_version == 'true'
run: |
cd ./.github/workflows/deploy/chocolatey
pwsh -File ./replace.ps1 -version ${{ steps.release_version.outputs.version }} -checksum ${{ steps.release_checksum.outputs.checksum }} -checksum64 ${{ steps.release_checksum.outputs.checksum64 }}
- name: Run Chocolatey Pack
if: steps.check_new_version.outputs.new_version == 'true'
run: |
cd ./.github/workflows/deploy/chocolatey
choco pack ./asyncapi-cli.nuspec
choco apikey add --source "'https://push.chocolatey.org/'" --key ${{ secrets.CHOCOLATEY_API_KEY }}
choco push ./asyncapi.${{ steps.release_version.outputs.version }}.nupkg --source "'https://push.chocolatey.org/'"
- if: failure() # Only, on failure, send a message on the 94_bot-failing-ci slack channel
name: Report workflow run status to Slack
uses: 8398a7/action-slack@fbd6aa58ba854a740e11a35d0df80cb5d12101d8 #using https://github.com/8398a7/action-slack/releases/tag/v3.15.1
with:
status: ${{ job.status }}
fields: repo,action,workflow
text: 'AsyncAPI CLI release to Chocolatey failed'
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_CI_FAIL_NOTIFY }}