Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8d4157b42d | ||
|
|
57f49822bb | ||
|
|
d5cf44cb57 | ||
|
|
63120e4793 | ||
|
|
0bc914ac8a | ||
|
|
8921c2da13 |
No files matched your search
@@ -0,0 +1,148 @@
|
||||
name: Build and Publish Release
|
||||
|
||||
on:
|
||||
push:
|
||||
tags:
|
||||
- 'v*'
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
release:
|
||||
name: Build Packages and Publish
|
||||
runs-on: fedora
|
||||
steps:
|
||||
- name: Checkout Source Code
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Verify Build Environment
|
||||
run: |
|
||||
echo "=== Runner System Info ==="
|
||||
uname -a
|
||||
python3 --version
|
||||
if ! command -v rpmbuild &>/dev/null; then
|
||||
echo "Installing rpm-build..."
|
||||
sudo dnf install -y rpm-build
|
||||
else
|
||||
echo "rpmbuild is already available: $(which rpmbuild)"
|
||||
fi
|
||||
|
||||
- name: Run Test Suite
|
||||
run: |
|
||||
echo "=== Running Unit Tests ==="
|
||||
python3 -m unittest discover tests
|
||||
|
||||
- name: Build Distribution Packages
|
||||
run: |
|
||||
echo "=== Building Packages (.rpm, .deb, .tar.gz) ==="
|
||||
python3 packaging/build_packages.py
|
||||
echo "=== Built Artifacts ==="
|
||||
ls -lh dist/*.tar.gz dist/*.deb 2>/dev/null || true
|
||||
ls -lh dist/rpm/RPMS/*/*.rpm 2>/dev/null || true
|
||||
|
||||
- name: Publish to Gitea Package Registry
|
||||
env:
|
||||
PKG_TOKEN: ${{ secrets.PACKAGES_GENERATION || secrets.GITHUB_TOKEN }}
|
||||
run: |
|
||||
echo "=== Publishing to Gitea Package Registry ==="
|
||||
RPM_FILE=$(find dist/rpm/RPMS -name "*.rpm" 2>/dev/null | head -n 1)
|
||||
DEB_FILE=$(ls dist/*.deb 2>/dev/null | head -n 1)
|
||||
|
||||
if [ -n "$RPM_FILE" ] && [ -f "$RPM_FILE" ]; then
|
||||
echo "Uploading RPM: $RPM_FILE"
|
||||
HTTP_CODE=$(curl -k -s -o /dev/null -w "%{http_code}" -X PUT \
|
||||
-u "${{ github.actor }}:${PKG_TOKEN}" \
|
||||
--upload-file "$RPM_FILE" \
|
||||
"${{ github.server_url }}/api/packages/${{ github.repository_owner }}/rpm/upload")
|
||||
echo "RPM Registry HTTP status: $HTTP_CODE"
|
||||
fi
|
||||
|
||||
if [ -n "$DEB_FILE" ] && [ -f "$DEB_FILE" ]; then
|
||||
echo "Uploading DEB: $DEB_FILE"
|
||||
HTTP_CODE=$(curl -k -s -o /dev/null -w "%{http_code}" -X PUT \
|
||||
-u "${{ github.actor }}:${PKG_TOKEN}" \
|
||||
--upload-file "$DEB_FILE" \
|
||||
"${{ github.server_url }}/api/packages/${{ github.repository_owner }}/debian/pool/stable/main/upload")
|
||||
echo "Debian Registry HTTP status: $HTTP_CODE"
|
||||
fi
|
||||
|
||||
# Link packages to this repository in Gitea
|
||||
REPO_NAME=$(basename "${{ github.repository }}")
|
||||
echo "Linking RPM package 'linux-updater' to repository ${REPO_NAME}..."
|
||||
LINK_RPM=$(curl -k -s -w " (HTTP %{http_code})" -X POST \
|
||||
-H "Authorization: token ${PKG_TOKEN}" \
|
||||
"${{ github.server_url }}/api/v1/packages/${{ github.repository_owner }}/rpm/linux-updater/-/link/${REPO_NAME}")
|
||||
echo "RPM link result: $LINK_RPM"
|
||||
|
||||
echo "Linking Debian package 'linux-updater' to repository ${REPO_NAME}..."
|
||||
LINK_DEB=$(curl -k -s -w " (HTTP %{http_code})" -X POST \
|
||||
-H "Authorization: token ${PKG_TOKEN}" \
|
||||
"${{ github.server_url }}/api/v1/packages/${{ github.repository_owner }}/debian/linux-updater/-/link/${REPO_NAME}")
|
||||
echo "Debian link result: $LINK_DEB"
|
||||
|
||||
- name: Attach Artifacts to Gitea Release
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
SERVER_URL: ${{ github.server_url }}
|
||||
REPO: ${{ github.repository }}
|
||||
TAG_REF: ${{ github.ref_name }}
|
||||
run: |
|
||||
echo "=== Attaching Assets to Release ==="
|
||||
# Determine tag name (default to package version if workflow_dispatch on branch)
|
||||
TAG="${TAG_REF}"
|
||||
if [[ "$TAG" == "main" || "$TAG" == "" ]]; then
|
||||
VER=$(python3 -c "import linux_updater; print(linux_updater.__version__)")
|
||||
TAG="v${VER}"
|
||||
fi
|
||||
echo "Target Release Tag: $TAG"
|
||||
|
||||
# 1. Fetch release ID or create release if missing
|
||||
REL_JSON=$(curl -k -s -H "Authorization: token ${GITHUB_TOKEN}" \
|
||||
"${SERVER_URL}/api/v1/repos/${REPO}/releases/tags/${TAG}")
|
||||
REL_ID=$(python3 -c "import sys, json; data=json.loads(sys.argv[1]); print(data.get('id', ''))" "$REL_JSON" 2>/dev/null || true)
|
||||
|
||||
if [ -z "$REL_ID" ]; then
|
||||
echo "Release $TAG does not exist yet. Creating release..."
|
||||
CREATE_DATA=$(python3 -c "import sys, json; print(json.dumps({'tag_name': sys.argv[1], 'name': 'Release ' + sys.argv[1], 'body': 'Automated build and release for ' + sys.argv[1]}))" "$TAG")
|
||||
CREATE_RESP=$(curl -k -s -X POST \
|
||||
-H "Authorization: token ${GITHUB_TOKEN}" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d "$CREATE_DATA" \
|
||||
"${SERVER_URL}/api/v1/repos/${REPO}/releases")
|
||||
REL_ID=$(python3 -c "import sys, json; data=json.loads(sys.argv[1]); print(data.get('id', ''))" "$CREATE_RESP" 2>/dev/null || true)
|
||||
echo "Create release response: $CREATE_RESP"
|
||||
fi
|
||||
|
||||
echo "Release ID: $REL_ID"
|
||||
|
||||
if [ -n "$REL_ID" ]; then
|
||||
# Clean up any existing assets for this release (ensures idempotency on re-runs)
|
||||
EXISTING_ASSETS=$(curl -k -s -H "Authorization: token ${GITHUB_TOKEN}" \
|
||||
"${SERVER_URL}/api/v1/repos/${REPO}/releases/${REL_ID}/assets" || true)
|
||||
ASSET_IDS=$(python3 -c "import sys, json; print(' '.join(str(a['id']) for a in json.loads(sys.argv[1])))" "$EXISTING_ASSETS" 2>/dev/null || true)
|
||||
for aid in $ASSET_IDS; do
|
||||
echo "Removing previous asset ID $aid..."
|
||||
curl -k -s -X DELETE -H "Authorization: token ${GITHUB_TOKEN}" \
|
||||
"${SERVER_URL}/api/v1/repos/${REPO}/releases/${REL_ID}/assets/${aid}" || true
|
||||
done
|
||||
|
||||
# Target only user-facing binaries (exclude internal rpm SOURCES and SRPMS)
|
||||
ASSET_FILES=(
|
||||
$(ls dist/*.tar.gz 2>/dev/null || true)
|
||||
$(ls dist/*.deb 2>/dev/null || true)
|
||||
$(ls dist/rpm/RPMS/*/*.rpm 2>/dev/null || true)
|
||||
)
|
||||
|
||||
for f in "${ASSET_FILES[@]}"; do
|
||||
if [ -f "$f" ]; then
|
||||
fname=$(basename "$f")
|
||||
echo "Uploading asset $fname from $f..."
|
||||
curl -k -s -X POST \
|
||||
-H "Authorization: token ${GITHUB_TOKEN}" \
|
||||
-F "attachment=@${f}" \
|
||||
"${SERVER_URL}/api/v1/repos/${REPO}/releases/${REL_ID}/assets?name=${fname}" || echo "Asset upload note: $?"
|
||||
fi
|
||||
done
|
||||
echo "Artifacts successfully attached to release $TAG!"
|
||||
else
|
||||
echo "Could not obtain release ID, skipping asset attachment."
|
||||
fi
|
||||
@@ -49,7 +49,7 @@
|
||||
python3 packaging/build_packages.py
|
||||
|
||||
# Install generated deb:
|
||||
sudo dpkg -i dist/linux-updater_1.2.0_all.deb
|
||||
sudo dpkg -i dist/linux-updater_1.3.0_all.deb
|
||||
```
|
||||
|
||||
### Option 2: Native `.rpm` Package (RHEL / Fedora / AlmaLinux / Rocky)
|
||||
@@ -63,8 +63,8 @@ sudo rpm -Uvh dist/rpm/RPMS/noarch/linux-updater-*.noarch.rpm
|
||||
|
||||
### Option 3: Standalone Tarball (All Linux Distributions)
|
||||
```bash
|
||||
tar -xzf dist/linux-updater-1.2.0.tar.gz
|
||||
cd linux-updater-1.2.0
|
||||
tar -xzf dist/linux-updater-1.3.0.tar.gz
|
||||
cd linux-updater-1.3.0
|
||||
sudo ./install.sh
|
||||
```
|
||||
|
||||
|
||||
@@ -149,6 +149,6 @@ python3 packaging/build_packages.py
|
||||
```
|
||||
|
||||
Generated artifacts:
|
||||
- `dist/linux-updater-1.2.0.tar.gz`: Standalone distribution archive containing `install.sh`.
|
||||
- `dist/linux-updater_1.2.0_all.deb`: Native Debian/Ubuntu binary package.
|
||||
- `dist/rpm/RPMS/noarch/linux-updater-1.2.0-1.*.noarch.rpm`: Native RPM package.
|
||||
- `dist/linux-updater-1.3.0.tar.gz`: Standalone distribution archive containing `install.sh`.
|
||||
- `dist/linux-updater_1.3.0_all.deb`: Native Debian/Ubuntu binary package.
|
||||
- `dist/rpm/RPMS/noarch/linux-updater-1.3.0-1.*.noarch.rpm`: Native RPM package.
|
||||
+2
-2
@@ -27,7 +27,7 @@ linux-updater health
|
||||
|
||||
**Example Output:**
|
||||
```text
|
||||
Linux System Updater v1.2.0
|
||||
Linux System Updater v1.3.0
|
||||
Detected System: Ubuntu 24.04.1 LTS (Family: debian)
|
||||
|
||||
Pre-flight Health Diagnostics:
|
||||
@@ -53,7 +53,7 @@ linux-updater check
|
||||
|
||||
**Example Output:**
|
||||
```text
|
||||
Linux System Updater v1.2.0
|
||||
Linux System Updater v1.3.0
|
||||
Detected System: Fedora Linux 40 (Family: rhel)
|
||||
Checking available updates...
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
"""Linux System Updater - Multi-distribution system updater and health checker."""
|
||||
|
||||
__version__ = "1.2.0"
|
||||
__version__ = "1.3.0"
|
||||
__author__ = "Test Factory"
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
.TH LINUX-UPDATER 8 "October 2026" "linux-updater 1.2.0" "System Administration Utilities"
|
||||
.TH LINUX-UPDATER 8 "October 2026" "linux-updater 1.3.0" "System Administration Utilities"
|
||||
.SH NAME
|
||||
linux-updater \- unified, safe multi-distribution Linux system update utility
|
||||
|
||||
|
||||
@@ -67,7 +67,7 @@ class PackageBuilder:
|
||||
self,
|
||||
source_root: Optional[Path] = None,
|
||||
output_dir: Optional[Path] = None,
|
||||
version: str = "1.2.0",
|
||||
version: str = "1.3.0",
|
||||
) -> None:
|
||||
self.source_root = source_root or Path(__file__).resolve().parent.parent
|
||||
self.output_dir = output_dir or (self.source_root / "dist")
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
Name: linux-updater
|
||||
Version: 1.2.0
|
||||
Version: 1.3.0
|
||||
Release: 1%{?dist}
|
||||
Summary: Unified, safe multi-distribution Linux system updater
|
||||
|
||||
@@ -46,6 +46,10 @@ fi
|
||||
%{_mandir}/man8/linux-updater.8*
|
||||
|
||||
%changelog
|
||||
* Fri Oct 02 2026 Test Factory <admin@localhost> - 1.3.0-1
|
||||
- Add Gitea Actions automated CI/CD pipeline for building RPM, DEB, and tarball packages.
|
||||
- Automated publication to Gitea Package Registry and Gitea Release Assets.
|
||||
|
||||
* Fri Oct 02 2026 Test Factory <admin@localhost> - 1.2.0-1
|
||||
- Fix dnf5 offline reboot and dnf system-upgrade reboot automatic invocation with -y.
|
||||
- Enhanced cross-distribution unattended update and reboot workflows.
|
||||
|
||||
@@ -4,15 +4,21 @@ import tempfile
|
||||
import unittest
|
||||
from pathlib import Path
|
||||
|
||||
from packaging.build_packages import PackageBuilder
|
||||
import importlib.util
|
||||
|
||||
_root_dir = Path(__file__).resolve().parent.parent
|
||||
_pkg_script = _root_dir / "packaging" / "build_packages.py"
|
||||
_spec = importlib.util.spec_from_file_location("build_packages", str(_pkg_script))
|
||||
_module = importlib.util.module_from_spec(_spec)
|
||||
_spec.loader.exec_module(_module)
|
||||
PackageBuilder = _module.PackageBuilder
|
||||
|
||||
class TestPackaging(unittest.TestCase):
|
||||
def setUp(self):
|
||||
self.temp_dir = tempfile.TemporaryDirectory()
|
||||
self.out_dir = Path(self.temp_dir.name)
|
||||
self.root_dir = Path(__file__).resolve().parent.parent
|
||||
self.builder = PackageBuilder(source_root=self.root_dir, output_dir=self.out_dir, version="1.2.0")
|
||||
self.builder = PackageBuilder(source_root=self.root_dir, output_dir=self.out_dir, version="1.3.0")
|
||||
|
||||
def tearDown(self):
|
||||
self.temp_dir.cleanup()
|
||||
|
||||
Reference in new issue
Block a user