mirror of
https://github.com/RedWizardsLab/EchoHub.git
synced 2026-09-04 08:36:11 +02:00
fix: update release workflow to correctly handle version checks and Chocolatey publishing conditions
This commit is contained in:
@@ -14,7 +14,7 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
outputs:
|
outputs:
|
||||||
should_release: ${{ steps.changes.outputs.src_changed == 'true' && steps.check_release.outputs.exists == 'false' }}
|
should_release: ${{ steps.changes.outputs.src_changed == 'true' && steps.check_release.outputs.exists == 'false' }}
|
||||||
src_changed: ${{ steps.changes.outputs.src_changed }}
|
release_exists: ${{ steps.check_release.outputs.exists }}
|
||||||
version: ${{ steps.version.outputs.version }}
|
version: ${{ steps.version.outputs.version }}
|
||||||
tag: ${{ steps.version.outputs.tag }}
|
tag: ${{ steps.version.outputs.tag }}
|
||||||
steps:
|
steps:
|
||||||
@@ -35,7 +35,6 @@ jobs:
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
- name: Read version
|
- name: Read version
|
||||||
if: steps.changes.outputs.src_changed == 'true'
|
|
||||||
id: version
|
id: version
|
||||||
run: |
|
run: |
|
||||||
VERSION=$(grep -oP '(?<=<Version>)[^<]+' src/Directory.Build.props)
|
VERSION=$(grep -oP '(?<=<Version>)[^<]+' src/Directory.Build.props)
|
||||||
@@ -43,7 +42,6 @@ jobs:
|
|||||||
echo "tag=v$VERSION" >> "$GITHUB_OUTPUT"
|
echo "tag=v$VERSION" >> "$GITHUB_OUTPUT"
|
||||||
|
|
||||||
- name: Check if release exists
|
- name: Check if release exists
|
||||||
if: steps.changes.outputs.src_changed == 'true'
|
|
||||||
id: check_release
|
id: check_release
|
||||||
run: |
|
run: |
|
||||||
if gh release view "${{ steps.version.outputs.tag }}" &>/dev/null; then
|
if gh release view "${{ steps.version.outputs.tag }}" &>/dev/null; then
|
||||||
@@ -166,17 +164,32 @@ jobs:
|
|||||||
choco:
|
choco:
|
||||||
name: Publish to Chocolatey
|
name: Publish to Chocolatey
|
||||||
needs: release
|
needs: release
|
||||||
if: needs.release.outputs.src_changed == 'true'
|
if: needs.release.outputs.release_exists == 'true' || needs.release.outputs.should_release == 'true'
|
||||||
runs-on: windows-latest
|
runs-on: windows-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Check if version already published
|
||||||
|
id: choco_check
|
||||||
|
shell: pwsh
|
||||||
|
run: |
|
||||||
|
$version = "${{ needs.release.outputs.version }}"
|
||||||
|
$result = choco search echohub --version $version --exact --source https://community.chocolatey.org/api/v2/ 2>&1
|
||||||
|
if ($result -match "echohub $version") {
|
||||||
|
echo "exists=true" >> $env:GITHUB_OUTPUT
|
||||||
|
Write-Host "Chocolatey package echohub $version already published — skipping."
|
||||||
|
} else {
|
||||||
|
echo "exists=false" >> $env:GITHUB_OUTPUT
|
||||||
|
}
|
||||||
|
|
||||||
- name: Download release asset
|
- name: Download release asset
|
||||||
|
if: steps.choco_check.outputs.exists == 'false'
|
||||||
run: gh release download "v${{ needs.release.outputs.version }}" --pattern "EchoHub-Client-win-x64.zip"
|
run: gh release download "v${{ needs.release.outputs.version }}" --pattern "EchoHub-Client-win-x64.zip"
|
||||||
env:
|
env:
|
||||||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
|
||||||
- name: Pack and push
|
- name: Pack and push
|
||||||
|
if: steps.choco_check.outputs.exists == 'false'
|
||||||
shell: pwsh
|
shell: pwsh
|
||||||
run: |
|
run: |
|
||||||
$version = "${{ needs.release.outputs.version }}"
|
$version = "${{ needs.release.outputs.version }}"
|
||||||
|
|||||||
Reference in New Issue
Block a user