feat(docs): implement slice 8 documentation triad, man page, completions and Gitea Actions CI/CD
Build and Publish Release / test-and-release (push) Failing after 48s
Build and Publish Release / test-and-release (push) Failing after 48s
This commit is contained in:
1 parent
c5c3b87bd9
commit
6f23f14b76
14 files changed
+1730
-10
No files matched your search
@@ -0,0 +1,144 @@
|
||||
name: Build and Publish Release
|
||||
|
||||
on:
|
||||
push:
|
||||
tags:
|
||||
- 'v*'
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
version:
|
||||
description: 'Release version (e.g. 1.0.0)'
|
||||
required: false
|
||||
default: ''
|
||||
|
||||
jobs:
|
||||
test-and-release:
|
||||
runs-on: fedora
|
||||
steps:
|
||||
- name: Checkout Source Code
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Setup Build Dependencies
|
||||
run: |
|
||||
echo "[INFO] Verifying build dependencies..."
|
||||
python3 --version
|
||||
if ! command -v rpmbuild >/dev/null 2>&1; then
|
||||
echo "[INFO] Installing rpm-build..."
|
||||
sudo dnf install -y rpm-build
|
||||
fi
|
||||
|
||||
- name: Run Quality Gate Test Suite
|
||||
run: |
|
||||
echo "[INFO] Executing comprehensive test suite..."
|
||||
python3 -m unittest discover tests -v
|
||||
|
||||
- name: Build Distribution Packages
|
||||
id: build_pkgs
|
||||
run: |
|
||||
echo "[INFO] Building .tar.gz, .deb, and .rpm distribution packages..."
|
||||
rm -rf dist
|
||||
python3 packaging/build_packages.py --all --out-dir dist
|
||||
|
||||
TAR_FILE=$(find dist -maxdepth 1 -name "*.tar.gz" | head -n 1)
|
||||
DEB_FILE=$(find dist -maxdepth 1 -name "*.deb" | head -n 1)
|
||||
RPM_FILE=$(find dist -maxdepth 1 -name "*.rpm" | head -n 1)
|
||||
|
||||
echo "TAR_FILE=$TAR_FILE" >> $GITHUB_ENV
|
||||
echo "DEB_FILE=$DEB_FILE" >> $GITHUB_ENV
|
||||
echo "RPM_FILE=$RPM_FILE" >> $GITHUB_ENV
|
||||
|
||||
echo "[INFO] Generated packages:"
|
||||
ls -lh dist/
|
||||
|
||||
- name: Publish to Gitea Package Registry
|
||||
env:
|
||||
PKG_TOKEN: ${{ secrets.PACKAGES_GENERATION || secrets.GITHUB_TOKEN }}
|
||||
run: |
|
||||
echo "[INFO] Uploading packages to Gitea Package Registry..."
|
||||
OWNER="${{ github.repository_owner }}"
|
||||
REPO="${{ github.event.repository.name }}"
|
||||
SERVER="${{ github.server_url }}"
|
||||
|
||||
# Upload RPM
|
||||
if [[ -f "$RPM_FILE" ]]; then
|
||||
echo "[INFO] Publishing RPM to registry..."
|
||||
curl -k -s -f -X PUT -u "${{ github.actor }}:${PKG_TOKEN}" \
|
||||
--upload-file "$RPM_FILE" \
|
||||
"${SERVER}/api/packages/${OWNER}/rpm/upload" || echo "[WARNING] RPM upload returned non-zero (may already exist)"
|
||||
|
||||
# Link package to repository
|
||||
curl -k -s -X POST -H "Authorization: token ${PKG_TOKEN}" \
|
||||
"${SERVER}/api/v1/packages/${OWNER}/rpm/linux-backuper/-/link/${REPO}" || true
|
||||
fi
|
||||
|
||||
# Upload Debian
|
||||
if [[ -f "$DEB_FILE" ]]; then
|
||||
echo "[INFO] Publishing Debian to registry..."
|
||||
curl -k -s -f -X PUT -u "${{ github.actor }}:${PKG_TOKEN}" \
|
||||
--upload-file "$DEB_FILE" \
|
||||
"${SERVER}/api/packages/${OWNER}/debian/pool/stable/main/upload" || echo "[WARNING] DEB upload returned non-zero (may already exist)"
|
||||
|
||||
# Link package to repository
|
||||
curl -k -s -X POST -H "Authorization: token ${PKG_TOKEN}" \
|
||||
"${SERVER}/api/v1/packages/${OWNER}/debian/linux-backuper/-/link/${REPO}" || true
|
||||
fi
|
||||
|
||||
- name: Publish Gitea Release & Upload Assets
|
||||
if: startsWith(github.ref, 'refs/tags/v')
|
||||
env:
|
||||
GITEA_TOKEN: ${{ secrets.PACKAGES_GENERATION || secrets.GITHUB_TOKEN }}
|
||||
run: |
|
||||
TAG_NAME="${GITHUB_REF#refs/tags/}"
|
||||
OWNER="${{ github.repository_owner }}"
|
||||
REPO="${{ github.event.repository.name }}"
|
||||
API_URL="${{ github.server_url }}/api/v1/repos/${OWNER}/${REPO}"
|
||||
|
||||
echo "[INFO] Ensuring Gitea Release exists for tag ${TAG_NAME}..."
|
||||
REL_INFO=$(curl -k -s -H "Authorization: token ${GITEA_TOKEN}" "${API_URL}/releases/tags/${TAG_NAME}")
|
||||
REL_ID=$(echo "$REL_INFO" | grep -o '"id":[0-9]*' | head -n 1 | cut -d: -f2)
|
||||
|
||||
if [[ -z "$REL_ID" || "$REL_ID" == "null" ]]; then
|
||||
echo "[INFO] Creating release for tag ${TAG_NAME}..."
|
||||
CREATE_PAYLOAD=$(cat <<EOF
|
||||
{
|
||||
"tag_name": "${TAG_NAME}",
|
||||
"name": "linux-backuper ${TAG_NAME}",
|
||||
"body": "Automated release of linux-backuper.\\n\\nIncludes:\\n- Native Debian package (.deb)\\n- Native Red Hat / Fedora package (.rpm)\\n- Universal standalone archive (.tar.gz)",
|
||||
"draft": false,
|
||||
"prerelease": false
|
||||
}
|
||||
EOF
|
||||
)
|
||||
NEW_REL=$(curl -k -s -X POST -H "Authorization: token ${GITEA_TOKEN}" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d "$CREATE_PAYLOAD" \
|
||||
"${API_URL}/releases")
|
||||
REL_ID=$(echo "$NEW_REL" | grep -o '"id":[0-9]*' | head -n 1 | cut -d: -f2)
|
||||
fi
|
||||
|
||||
echo "[INFO] Release ID: ${REL_ID}"
|
||||
|
||||
# Idempotently upload assets
|
||||
for FPATH in "$TAR_FILE" "$DEB_FILE" "$RPM_FILE"; do
|
||||
if [[ -f "$FPATH" ]]; then
|
||||
FNAME=$(basename "$FPATH")
|
||||
echo "[INFO] Uploading asset: ${FNAME}..."
|
||||
|
||||
# Delete existing asset with same name if present
|
||||
EXISTING_ASSETS=$(curl -k -s -H "Authorization: token ${GITEA_TOKEN}" "${API_URL}/releases/${REL_ID}/assets")
|
||||
ASSET_ID=$(echo "$EXISTING_ASSETS" | grep -B 2 "\"name\":\"${FNAME}\"" | grep -o '"id":[0-9]*' | head -n 1 | cut -d: -f2 || true)
|
||||
if [[ -n "$ASSET_ID" ]]; then
|
||||
echo "[INFO] Deleting existing asset ${FNAME} (ID: ${ASSET_ID})..."
|
||||
curl -k -s -X DELETE -H "Authorization: token ${GITEA_TOKEN}" "${API_URL}/releases/${REL_ID}/assets/${ASSET_ID}"
|
||||
fi
|
||||
|
||||
# Upload asset
|
||||
curl -k -s -X POST -H "Authorization: token ${GITEA_TOKEN}" \
|
||||
-H "Content-Type: application/octet-stream" \
|
||||
--data-binary @"$FPATH" \
|
||||
"${API_URL}/releases/${REL_ID}/assets?name=${FNAME}"
|
||||
fi
|
||||
done
|
||||
echo "[SUCCESS] Release publishing complete."
|
||||
Reference in new issue
Block a user