|
| 1 | +name: GitHub Release Upload |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_call: |
| 5 | + |
| 6 | +permissions: |
| 7 | + contents: write |
| 8 | + |
| 9 | +jobs: |
| 10 | + upload: |
| 11 | + name: Upload assets to GitHub draft release |
| 12 | + runs-on: ubuntu-latest |
| 13 | + steps: |
| 14 | + - uses: actions/checkout@v4 |
| 15 | + |
| 16 | + - name: Download builds |
| 17 | + uses: actions/download-artifact@v4 |
| 18 | + with: |
| 19 | + name: 'all-builds' |
| 20 | + path: release |
| 21 | + |
| 22 | + - name: Read version and find draft release |
| 23 | + id: find-release |
| 24 | + env: |
| 25 | + GH_TOKEN: ${{ github.token }} |
| 26 | + run: | |
| 27 | + APP_VERSION=$(jq -r '.version' redisinsight/package.json) |
| 28 | + echo "version=${APP_VERSION}" >> "$GITHUB_OUTPUT" |
| 29 | +
|
| 30 | + RELEASE_TAG=$(gh release list --json tagName,isDraft \ |
| 31 | + --jq ".[] | select(.isDraft and .tagName == \"${APP_VERSION}\") | .tagName" \ |
| 32 | + | head -n 1) |
| 33 | +
|
| 34 | + if [ -z "$RELEASE_TAG" ]; then |
| 35 | + echo "::warning::No draft release found for tag '${APP_VERSION}'. Skipping upload." |
| 36 | + echo "found=false" >> "$GITHUB_OUTPUT" |
| 37 | + else |
| 38 | + echo "Draft release found: ${RELEASE_TAG}" |
| 39 | + echo "found=true" >> "$GITHUB_OUTPUT" |
| 40 | + echo "tag=${RELEASE_TAG}" >> "$GITHUB_OUTPUT" |
| 41 | + fi |
| 42 | +
|
| 43 | + - name: Upload desktop installers to draft release |
| 44 | + if: steps.find-release.outputs.found == 'true' |
| 45 | + env: |
| 46 | + GH_TOKEN: ${{ github.token }} |
| 47 | + run: | |
| 48 | + TAG="${{ steps.find-release.outputs.tag }}" |
| 49 | +
|
| 50 | + PATTERNS=( |
| 51 | + "Redis-Insight-mac-x64.dmg" |
| 52 | + "Redis-Insight-mac-arm64.dmg" |
| 53 | + # "Redis-Insight-win-installer.exe" |
| 54 | + # "Redis-Insight-linux-x86_64.AppImage" |
| 55 | + # "Redis-Insight-linux-arm64.AppImage" |
| 56 | + # "Redis-Insight-linux-amd64.deb" |
| 57 | + # "Redis-Insight-linux-arm64.deb" |
| 58 | + # "Redis-Insight-linux-x86_64.rpm" |
| 59 | + # "Redis-Insight-linux-aarch64.rpm" |
| 60 | + # "Redis-Insight-linux-amd64.snap" |
| 61 | + ) |
| 62 | +
|
| 63 | + FILES=() |
| 64 | + for pattern in "${PATTERNS[@]}"; do |
| 65 | + match=$(find ./release -name "$pattern" -type f 2>/dev/null | head -n 1) |
| 66 | + if [ -n "$match" ]; then |
| 67 | + FILES+=("$match") |
| 68 | + echo "Found: $match" |
| 69 | + else |
| 70 | + echo "::warning::Installer not found: $pattern" |
| 71 | + fi |
| 72 | + done |
| 73 | +
|
| 74 | + if [ ${#FILES[@]} -eq 0 ]; then |
| 75 | + echo "::warning::No desktop installers matched. Nothing to upload." |
| 76 | + exit 0 |
| 77 | + fi |
| 78 | +
|
| 79 | + echo "Uploading ${#FILES[@]} file(s) to release '${TAG}'..." |
| 80 | + gh release upload "$TAG" "${FILES[@]}" --clobber |
| 81 | + echo "Upload complete." |
0 commit comments