Repository navigation
76 lines (71 loc) · 2.88 KB
/
Copy pathwinget.yml
File metadata and controls
76 lines (71 loc) · 2.88 KB
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
name: WinGet Submission
permissions:
contents: read
on:
release:
types: [published]
workflow_dispatch:
inputs:
release_tag:
description: 'Release tag to submit (leave blank for latest release)'
required: false
default: ''
jobs:
winget:
if: github.event.release.prerelease == false
name: Submit to WinGet
runs-on: ubuntu-latest
steps:
- name: Determine Release Tag
id: get-tag
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
CUSTOM_TAG="${{ inputs.release_tag }}"
EVENT_TAG="${{ github.event.release.tag_name }}"
if [ -n "$CUSTOM_TAG" ]; then
TAG="$CUSTOM_TAG"
elif [ -n "$EVENT_TAG" ]; then
TAG="$EVENT_TAG"
else
# GitHub's /releases/latest endpoint strictly excludes draft and pre-release tags by specification
RELEASE_JSON=$(gh api repos/${{ github.repository }}/releases/latest)
IS_PRE=$(echo "$RELEASE_JSON" | jq -r '.prerelease')
if [ "$IS_PRE" = "true" ]; then
echo "::error::Target release is a pre-release! WinGet only accepts stable releases."
exit 1
fi
TAG=$(echo "$RELEASE_JSON" | jq -r '.tag_name')
fi
echo "tag=$TAG" >> $GITHUB_OUTPUT
echo "Selected Stable Release Tag for WinGet: $TAG"
- name: Auto-sync Fork with Microsoft Upstream
env:
GH_TOKEN: ${{ secrets.WINGET_TOKEN }}
TOKEN: ${{ secrets.WINGET_TOKEN }}
run: |
echo "Syncing fork justnullname/winget-pkgs with upstream microsoft/winget-pkgs..."
if gh api --method POST \
-H "Accept: application/vnd.github+json" \
/repos/justnullname/winget-pkgs/merge-upstream \
-f branch='master' 2>/dev/null; then
echo "Successfully synced fork via merge-upstream API."
else
echo "API fast-forward skipped, applying robust shallow reset..."
git config --global user.name "github-actions[bot]"
git config --global user.email "github-actions[bot]@users.noreply.github.com"
git clone --depth 1 https://x-access-token:${TOKEN}@github.com/justnullname/winget-pkgs.git /tmp/winget-fork
cd /tmp/winget-fork
git remote add upstream https://github.com/microsoft/winget-pkgs.git
git fetch --depth 1 upstream master
git reset --hard upstream/master
git push --force origin master
echo "Successfully force-synced fork master with upstream."
fi
- name: Submit to WinGet
uses: vedantmgoyal9/winget-releaser@v2
with:
identifier: justnullname.QuickView
token: ${{ secrets.WINGET_TOKEN }}
installers-regex: '.*_Installer_.*\.exe$'
release-tag: ${{ steps.get-tag.outputs.tag }}