name: Create Daily Release on: schedule: - cron: '1 0 * * *' # Runs daily at 00:01 UTC workflow_dispatch: jobs: create-daily-release: if: github.repository == 'community-scripts/ProxmoxVE' runs-on: ubuntu-latest permissions: contents: write steps: - name: Checkout repository uses: actions/checkout@v7 - name: Clean CHANGELOG (remove HTML header) run: sed -n '/^## /,$p' CHANGELOG.md > changelog_cleaned.md - name: Extract relevant changelog section id: extract run: | YESTERDAY=$(date -u --date="yesterday" +%Y-%m-%d) echo "Checking for changes on: $YESTERDAY" # Extract the section from "## $YESTERDAY" until the next "## YYYY-MM-DD" sed -n "/^## $YESTERDAY/,/^## [0-9]\{4\}-[0-9]\{2\}-[0-9]\{2\}/p" changelog_cleaned.md | head -n -1 > changelog_tmp_full.md # GitHub fills a release's Contributors only from bare @login mentions sed -i -E 's#\[@([A-Za-z0-9-]+)\]\(https://github\.com/\1\)#@\1#g' changelog_tmp_full.md # Keep whole lines up to 120000 characters (GitHub allows 125000) export LC_ALL=C.UTF-8 SIZE=0 TRUNCATED=false while IFS= read -r line || [ -n "$line" ]; do SIZE=$((SIZE + ${#line} + 1)) if [ "$SIZE" -gt 120000 ]; then TRUNCATED=true break fi printf '%s\n' "$line" done < changelog_tmp_full.md > changelog_tmp.md if [ "$TRUNCATED" = true ]; then printf '\nCut to fit the release size limit. The full list is in [CHANGELOG.md](https://github.com/community-scripts/ProxmoxVE/blob/main/CHANGELOG.md).\n' >> changelog_tmp.md fi echo "=== Extracted Changelog ===" cat changelog_tmp.md echo "===========================" # Abort if no content was found if [ ! -s changelog_tmp.md ]; then echo "No changes found for $YESTERDAY, skipping release." echo "skip=true" >> "$GITHUB_OUTPUT" fi - name: Create GitHub release if: steps.extract.outputs.skip != 'true' env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | YESTERDAY=$(date -u --date="yesterday" +%Y-%m-%d) PREVIOUS=$(gh release view --json tagName --jq .tagName 2>/dev/null || true) if [ -n "$PREVIOUS" ]; then printf '\n**Full Changelog**: https://github.com/community-scripts/ProxmoxVE/compare/%s...%s\n' "$PREVIOUS" "$YESTERDAY" >> changelog_tmp.md fi gh release create "$YESTERDAY" -t "$YESTERDAY" -F changelog_tmp.md