Daily Proxmox Backup Client Version Check #73
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # .github/workflows/daily-pbs-check.yml | |
| name: Daily Proxmox Backup Client Version Check | |
| on: | |
| schedule: | |
| - cron: '0 2 * * *' | |
| workflow_dispatch: | |
| jobs: | |
| check-and-release: | |
| runs-on: ubuntu-latest | |
| container: debian:bookworm-slim | |
| steps: | |
| - name: Install base dependencies | |
| run: | | |
| apt-get update | |
| apt-get install -y --no-install-recommends ca-certificates gnupg wget curl jq | |
| - name: Add Proxmox PBS repository | |
| run: | | |
| echo "deb http://download.proxmox.com/debian/pbs-client bookworm main" > /etc/apt/sources.list.d/pbs-client.list | |
| wget -O- https://enterprise.proxmox.com/debian/proxmox-release-bookworm.gpg | gpg --dearmor -o /etc/apt/trusted.gpg.d/proxmox-release-bookworm.gpg | |
| - name: Update APT and install client | |
| run: | | |
| apt-get update | |
| apt-get install -y --no-install-recommends proxmox-backup-client-static | |
| - name: Get client version and binary path | |
| id: get_current | |
| run: | | |
| CLIENT_PATH=$(which proxmox-backup-client) | |
| if [ -z "$CLIENT_PATH" ]; then | |
| echo "Binary not found" | |
| exit 1 | |
| fi | |
| VERSION=$($CLIENT_PATH version | grep 'client version' | awk '{print $NF}') | |
| if [ -z "$VERSION" ]; then | |
| echo "Failed to extract client version" | |
| exit 1 | |
| fi | |
| echo "current_version=$VERSION" >> $GITHUB_OUTPUT | |
| echo "client_path=$CLIENT_PATH" >> $GITHUB_OUTPUT | |
| - name: Fetch and extract changelog for current version | |
| run: | | |
| VERSION=${{ steps.get_current.outputs.current_version }} | |
| CHANGELOG_URL="http://download.proxmox.com/debian/pbs-client/dists/bookworm/main/binary-amd64/proxmox-backup-client-static_${VERSION}-1.changelog" | |
| RAW_CHANGELOG=$(curl -sL "$CHANGELOG_URL") | |
| if [ $? -ne 0 ] || [ -z "$RAW_CHANGELOG" ]; then | |
| echo "Changelog not available for version $VERSION. URL: $CHANGELOG_URL" > /tmp/release_changelog.txt | |
| else | |
| # Extract the first matching changelog block for this version | |
| echo "$RAW_CHANGELOG" | awk -v ver="$VERSION" ' | |
| BEGIN { in_block = 0 } | |
| /^rust-proxmox-backup \(/ { | |
| if ($0 ~ "rust-proxmox-backup \\(" ver "-") { | |
| in_block = 1 | |
| } else if (in_block) { | |
| exit | |
| } | |
| } | |
| in_block { print } | |
| /^ -- / && in_block { exit } | |
| ' > /tmp/release_changelog.txt | |
| if [ ! -s /tmp/release_changelog.txt ]; then | |
| echo "No changelog entry found for version $VERSION." > /tmp/release_changelog.txt | |
| fi | |
| fi | |
| - name: Install alien and convert .deb to .rpm | |
| id: convert_rpm | |
| run: | | |
| apt-get install -y --no-install-recommends alien | |
| # Try to get .deb from APT cache; if not, download it | |
| DEB_FILE=$(ls /var/cache/apt/archives/proxmox-backup-client-static_*.deb 2>/dev/null | head -n1) | |
| if [ -z "$DEB_FILE" ]; then | |
| apt-get download proxmox-backup-client-static | |
| DEB_FILE=$(ls proxmox-backup-client-static_*.deb | head -n1) | |
| fi | |
| if [ ! -f "$DEB_FILE" ]; then | |
| echo "Failed to locate .deb package" | |
| exit 1 | |
| fi | |
| echo "Converting $DEB_FILE to RPM..." | |
| alien --to-rpm --scripts --keep-version "$DEB_FILE" | |
| RPM_FILE=$(ls proxmox-backup-client-static-*.rpm 2>/dev/null | head -n1) | |
| if [ -z "$RPM_FILE" ]; then | |
| echo "RPM conversion failed" | |
| exit 1 | |
| fi | |
| echo "rpm_path=$RPM_FILE" >> $GITHUB_OUTPUT | |
| echo "Converted RPM: $RPM_FILE" | |
| - name: Get latest released version from GitHub | |
| id: get_latest | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| LATEST_TAG=$(curl -sL \ | |
| -H "Accept: application/vnd.github.v3+json" \ | |
| -H "Authorization: Bearer $GITHUB_TOKEN" \ | |
| "https://api.github.com/repos/${{ github.repository }}/releases/latest" \ | |
| | jq -r '.tag_name // empty') | |
| if [ -z "$LATEST_TAG" ]; then | |
| echo "latest_version=" >> $GITHUB_OUTPUT | |
| else | |
| # Strip 'v' prefix for comparison | |
| VERSION=$(echo "$LATEST_TAG" | sed 's/^v//') | |
| echo "latest_version=$VERSION" >> $GITHUB_OUTPUT | |
| fi | |
| - name: Compare versions | |
| id: compare | |
| run: | | |
| CURRENT=${{ steps.get_current.outputs.current_version }} | |
| LATEST=${{ steps.get_latest.outputs.latest_version }} | |
| echo "Available version: $CURRENT" | |
| echo "Latest released version: $LATEST" | |
| if [ "$CURRENT" = "$LATEST" ]; then | |
| echo "skip_release=true" >> $GITHUB_OUTPUT | |
| else | |
| echo "skip_release=false" >> $GITHUB_OUTPUT | |
| fi | |
| - name: Create new Release | |
| if: steps.compare.outputs.skip_release == 'false' | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| name: "v${{ steps.get_current.outputs.current_version }}" | |
| tag_name: "v${{ steps.get_current.outputs.current_version }}" | |
| body_path: /tmp/release_changelog.txt | |
| files: | | |
| ${{ steps.get_current.outputs.client_path }} | |
| ${{ steps.convert_rpm.outputs.rpm_path }} | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |