Skip to content

Commit 56014e0

Browse files
committed
feat: auto-trigger winget bump on latest release with manual version input and x64 architecture fix
1 parent c05ea92 commit 56014e0

1 file changed

Lines changed: 46 additions & 8 deletions

File tree

‎.github/workflows/winget.yml‎

Lines changed: 46 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@ name: Bump Winget PR
22

33
on:
44
workflow_dispatch:
5+
inputs:
6+
version:
7+
description: 'Version to publish (e.g. 1.4.2). Leave empty to use latest tag.'
8+
required: false
9+
release:
10+
types: [released]
511

612
jobs:
713
winget-bump:
@@ -12,23 +18,55 @@ jobs:
1218

1319
- name: Get release version
1420
run: |
15-
# Extract tag
16-
TAG_NAME="${{ github.event.release.tag_name }}"
17-
if [ -z "$TAG_NAME" ]; then
21+
# Priority: manual input > release event > latest tag
22+
if [ -n "${{ github.event.inputs.version }}" ]; then
23+
VERSION="${{ github.event.inputs.version }}"
24+
VERSION=$(echo "$VERSION" | sed 's/^v//')
25+
elif [ -n "${{ github.event.release.tag_name }}" ]; then
26+
VERSION=$(echo "${{ github.event.release.tag_name }}" | sed 's/^v//')
27+
else
1828
TAG_NAME=$(git fetch --tags && git describe --tags $(git rev-list --tags --max-count=1))
29+
VERSION=$(echo "$TAG_NAME" | sed 's/^v//')
1930
fi
2031
21-
# Remove 'v' before tag
22-
VERSION=$(echo "$TAG_NAME" | sed 's/^v//')
23-
2432
echo "Release version: $VERSION"
2533
echo "VERSION=$VERSION" >> $GITHUB_ENV
2634
27-
- name: Use winget-releaser to create a PR
35+
- name: Create winget PR
2836
uses: vedantmgoyal9/winget-releaser@main
2937
with:
3038
identifier: "Nethesis.NethLink"
3139
version: ${{ env.VERSION }}
3240
token: ${{ secrets.WINGET_GITHUB_TOKEN }}
3341
fork-user: edospadoni
34-
release-tag: v${{ env.VERSION }}
42+
release-tag: v${{ env.VERSION }}
43+
44+
- name: Patch installer architecture to x64
45+
run: |
46+
# Find the branch created by winget-releaser on the fork
47+
BRANCH=$(gh api repos/edospadoni/winget-pkgs/branches --jq '.[].name' | grep "Nethesis.NethLink" | grep "${{ env.VERSION }}" | head -1)
48+
if [ -z "$BRANCH" ]; then
49+
echo "No branch found for version ${{ env.VERSION }}, skipping patch"
50+
exit 0
51+
fi
52+
echo "Branch: $BRANCH"
53+
54+
# Clone the fork branch and fix the architecture
55+
git clone --depth 1 --branch "$BRANCH" "https://x-access-token:${WINGET_TOKEN}@github.com/edospadoni/winget-pkgs.git" winget-pkgs
56+
57+
INSTALLER_YAML="winget-pkgs/manifests/n/Nethesis/NethLink/${{ env.VERSION }}/Nethesis.NethLink.installer.yaml"
58+
59+
# Only patch if architecture is not already x64
60+
if grep -q 'Architecture: x86' "$INSTALLER_YAML"; then
61+
sed -i 's/Architecture: x86/Architecture: x64/' "$INSTALLER_YAML"
62+
cd winget-pkgs
63+
git add .
64+
git commit -m "Fix architecture to x64"
65+
git push
66+
echo "Patched architecture to x64"
67+
else
68+
echo "Architecture already x64, no patch needed"
69+
fi
70+
env:
71+
GITHUB_TOKEN: ${{ secrets.WINGET_GITHUB_TOKEN }}
72+
WINGET_TOKEN: ${{ secrets.WINGET_GITHUB_TOKEN }}

0 commit comments

Comments
 (0)