Repository navigation
85 lines (72 loc) · 2.66 KB
/
Copy pathgithub-release-upload.yml
File metadata and controls
85 lines (72 loc) · 2.66 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
77
78
79
80
81
82
83
84
85
name: GitHub Release Upload
on:
workflow_call:
permissions:
contents: write
jobs:
upload:
name: Upload assets to GitHub draft release
runs-on: ubuntu-latest
continue-on-error: true
steps:
- uses: actions/checkout@v7.0.1
- name: Download builds
uses: actions/download-artifact@v8
with:
name: 'all-builds'
path: release
- name: Read version and find draft release
id: find-release
env:
GH_TOKEN: ${{ github.token }}
run: |
APP_VERSION=$(jq -r '.version' redisinsight/package.json)
echo "version=${APP_VERSION}" >> "$GITHUB_OUTPUT"
RELEASE_TAG=$(gh release list --json tagName,name,isDraft \
--jq "[.[] | select(.isDraft and (.name | contains(\"${APP_VERSION}\")))][0].tagName")
if [ -z "$RELEASE_TAG" ] || [ "$RELEASE_TAG" = "null" ]; then
echo "No draft release found for '${APP_VERSION}'. Creating one."
gh release create "${APP_VERSION}" \
--draft \
--target "${GITHUB_SHA}" \
--title "${APP_VERSION}" \
--notes "Release ${APP_VERSION}"
RELEASE_TAG="${APP_VERSION}"
else
echo "Draft release found (tag: ${RELEASE_TAG})"
fi
echo "tag=${RELEASE_TAG}" >> "$GITHUB_OUTPUT"
- name: Upload desktop installers to draft release
env:
GH_TOKEN: ${{ github.token }}
run: |
TAG="${{ steps.find-release.outputs.tag }}"
PATTERNS=(
"Redis-Insight-mac-x64.dmg"
"Redis-Insight-mac-arm64.dmg"
"Redis-Insight-win-installer.exe"
"Redis-Insight-linux-x86_64.AppImage"
"Redis-Insight-linux-arm64.AppImage"
"Redis-Insight-linux-amd64.deb"
"Redis-Insight-linux-arm64.deb"
"Redis-Insight-linux-x86_64.rpm"
"Redis-Insight-linux-aarch64.rpm"
"Redis-Insight-linux-amd64.snap"
)
FILES=()
for pattern in "${PATTERNS[@]}"; do
match=$(find ./release -name "$pattern" -type f 2>/dev/null | head -n 1)
if [ -n "$match" ]; then
FILES+=("$match")
echo "Found: $match"
else
echo "::warning::Installer not found: $pattern"
fi
done
if [ ${#FILES[@]} -eq 0 ]; then
echo "::warning::No desktop installers matched. Nothing to upload."
exit 0
fi
echo "Uploading ${#FILES[@]} file(s) to release '${TAG}'..."
gh release upload "$TAG" "${FILES[@]}" --clobber
echo "Upload complete."