mirror of
https://github.com/booklore-app/booklore.git
synced 2025-12-23 14:20:48 -05:00
Add scripts and update drafter flow
This commit is contained in:
17
.github/workflows/docker-build-publish.yml
vendored
17
.github/workflows/docker-build-publish.yml
vendored
@@ -181,23 +181,24 @@ jobs:
|
||||
--tag ghcr.io/booklore-app/booklore:latest \
|
||||
--push .
|
||||
|
||||
- name: Create Git Tag (Only for Master)
|
||||
- name: Update Release Draft (Only for Master)
|
||||
if: github.ref == 'refs/heads/master'
|
||||
run: |
|
||||
git config --global user.name "github-actions"
|
||||
git config --global user.email "github-actions@github.com"
|
||||
git tag ${{ env.new_tag }}
|
||||
git push origin ${{ env.new_tag }}
|
||||
uses: release-drafter/release-drafter@v6
|
||||
with:
|
||||
tag: ${{ env.new_tag }}
|
||||
name: "Release ${{ env.new_tag }}"
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ github.token }}
|
||||
|
||||
- name: Publish Draft Release (Only for Master)
|
||||
if: github.ref == 'refs/heads/master'
|
||||
env:
|
||||
GH_TOKEN: ${{ github.token }}
|
||||
GITHUB_TOKEN: ${{ github.token }}
|
||||
run: |
|
||||
gh release edit ${{ env.new_tag }} --draft=false
|
||||
|
||||
- name: Notify Discord of New Release
|
||||
if: github.ref == 'refs/heads/master'
|
||||
if: false
|
||||
continue-on-error: true
|
||||
shell: bash
|
||||
env:
|
||||
|
||||
29
scripts/docker-buildx-push.sh
Normal file
29
scripts/docker-buildx-push.sh
Normal file
@@ -0,0 +1,29 @@
|
||||
#!/bin/bash
|
||||
set -euo pipefail
|
||||
|
||||
# =======================
|
||||
# Multi-arch Docker Build & Push for Booklore
|
||||
# =======================
|
||||
|
||||
# Ensure a version/tag is passed
|
||||
if [ -z "${1:-}" ]; then
|
||||
echo "ERROR: You must provide a version/tag as the first argument."
|
||||
echo "Usage: $0 <version-tag>"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
VERSION="$1"
|
||||
|
||||
echo "Building Booklore App with multi-arch version: $VERSION"
|
||||
|
||||
# Ensure Docker Buildx builder exists and is used
|
||||
docker buildx create --use --name multiarch-builder || true
|
||||
|
||||
# Build and push multi-arch Docker image
|
||||
docker buildx build \
|
||||
--platform linux/amd64,linux/arm64 \
|
||||
-t retr0spect101/booklore:"$VERSION" \
|
||||
--push \
|
||||
.
|
||||
|
||||
echo "Multi-arch Docker image retr0spect101/booklore:$VERSION pushed successfully!"
|
||||
73
scripts/notify-discord.sh
Normal file
73
scripts/notify-discord.sh
Normal file
@@ -0,0 +1,73 @@
|
||||
#!/usr/bin/env bash
|
||||
# notify-discord.sh
|
||||
# Sends a GitHub release notification to Discord
|
||||
set -euo pipefail
|
||||
|
||||
# ===== CONFIGURE HERE =====
|
||||
if [ -z "${1:-}" ]; then
|
||||
echo "ERROR: You must provide the release tag as the first argument."
|
||||
echo "Usage: $0 <release-tag> [discord-webhook-url]"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
NEW_TAG="$1"
|
||||
DISCORD_WEBHOOK_URL="${2:-https://discord.com/api/webhooks/your_webhook_id/your_webhook_token}"
|
||||
|
||||
# Warn if using placeholder values
|
||||
if [[ "$DISCORD_WEBHOOK_URL" == *"YOUR_WEBHOOK_ID"* ]] || [[ "$DISCORD_WEBHOOK_URL" == *"YOUR_WEBHOOK_TOKEN"* ]]; then
|
||||
echo "WARNING: DISCORD_WEBHOOK_URL contains placeholder values; payload will likely fail."
|
||||
fi
|
||||
|
||||
echo "Preparing Discord notification for release $NEW_TAG"
|
||||
|
||||
# Fetch release data from GitHub
|
||||
echo "Running gh release view..."
|
||||
release_json=$(gh release view "$NEW_TAG" --json name,body,url)
|
||||
echo "Release JSON fetched"
|
||||
|
||||
release_name=$(jq -r '.name' <<< "$release_json")
|
||||
release_body=$(jq -r '.body' <<< "$release_json")
|
||||
release_url=$(jq -r '.url' <<< "$release_json")
|
||||
|
||||
dockerhub_image="https://hub.docker.com/r/booklore/booklore/tags/$NEW_TAG"
|
||||
ghcr_image="https://github.com/booklore-app/booklore/pkgs/container/booklore/$NEW_TAG"
|
||||
|
||||
# Clean up body for Discord
|
||||
clean_body=$(echo "$release_body" | tr -d '\r')
|
||||
max_length=1800
|
||||
if [ ${#clean_body} -gt $max_length ]; then
|
||||
clean_body="${clean_body:0:$((max_length-12))}… [truncated]"
|
||||
fi
|
||||
|
||||
# Prepare Discord payload
|
||||
payload=$(jq -n \
|
||||
--arg title "New Release: $release_name" \
|
||||
--arg url "$release_url" \
|
||||
--arg desc "$clean_body" \
|
||||
--arg hub "[View image]($dockerhub_image)" \
|
||||
--arg gh "[View image]($ghcr_image)" \
|
||||
'{
|
||||
content: null,
|
||||
embeds: [{
|
||||
title: $title,
|
||||
url: $url,
|
||||
description: $desc,
|
||||
color: 3066993,
|
||||
fields: [
|
||||
{ name: "Docker Hub", value: $hub, inline: true },
|
||||
{ name: "GHCR", value: $gh, inline: true }
|
||||
]
|
||||
}]
|
||||
}')
|
||||
|
||||
# Debug: show payload
|
||||
echo "=== Discord payload ==="
|
||||
echo "$payload"
|
||||
echo "======================="
|
||||
|
||||
# Send notification
|
||||
echo "Sending notification to Discord..."
|
||||
curl -i -H "Content-Type: application/json" -d "$payload" "$DISCORD_WEBHOOK_URL" \
|
||||
|| echo "⚠️ Request completed with an error; check the above HTTP response"
|
||||
|
||||
echo "Notification sent!"
|
||||
Reference in New Issue
Block a user