r11_workflows/action.yml
2025-02-03 11:54:58 +03:00

241 lines
8.3 KiB
YAML

name: Build and Deploy
description: Build and deploy RPM packages
inputs:
PUBLICATOR:
description: Publicator token
required: true
CI_DEPLOY:
description: CI deploy token
required: true
REPO_DEPLOY:
description: Deploy artefacts to urpm repo
required: true
on:
push:
branches:
- rosa2016.1
# workflow_dispatch:
# inputs:
# PUBLICATOR:
# description: Publicator token
# required: true
# CI_DEPLOY:
# description: CI deploy token
# required: true
runs:
using: "composite"
#jobs:
# build-and-deploy:
steps:
- name: Checkout code
run: |
git clone ${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}.git ${GITHUB_WORKSPACE}
git checkout ${GITHUB_REF_NAME}
export SPECFILE=$(find . -type f -name "*.spec")
echo "SPECFILE=${SPECFILE}" > .env
echo "LC_ALL=C" >> .env
source .env
echo "SPECFILE = ${SPECFILE}"
#- name: Remove all repo
# run: |
# if grep -q "djam_personal" /etc/urpmi/urpmi.cfg; then sudo urpmi.removemedia djam_personal; fi
# Убираем все старые источники
# sudo urpmi.removemedia -a
# Переключаемся на mirror.rosa.ru
# sudo urpmi.addmedia --wget -v --distrib --mirrorbrain https://mirror.rosa.ru/rosa/rosa2016.1/$ARCH
# sudo urpmi.addmedia --distrib --mirrorlist https://tvoygit.ru/Djam/r11_mirrorlist/raw/branch/main/rosa2016.1.x86_64.list
- name: Update repo and pre-install
run: |
source .env
export REPOURL="http://newrepo:8080"
#sudo urpmi --auto --allow-force tar gzip
#sudo echo "/^abf-console-client/" >> /etc/urpmi/skip.list
#sudo echo "/^kvrt/" >> /etc/urpmi/skip.list
sudo urpmi.addmedia personalold http://oldrepo:8090/rosa2016.1/x86_64/main/release/
sudo urpmi.update -fa
sudo urpmi --auto-update --auto --skip abf-console-client
sudo urpmi.addmedia newrepo_x86-64 ${REPOURL}/x86_64/
sudo urpmi.addmedia newrepo_noarch ${REPOURL}/noarch/
sudo urpmi --auto --allow-force tar gzip curl kvrt openssl3.3
urpmq --whatrequires kvrt
- name: Download sources artifacts
run: |
source .env
abfyml=.abf.yml
filestore="https://file-store.rosa.ru"
if [ -e "${abfyml}" ]; then
echo "parsing file '${abfyml}'"
sed -ne '/^[Ss]ources\:.*$/,$p' ${abfyml} | \
sed -rn '$G;s/^[\"'\''[:space:]]*([^[:space:]:\"'\'']+)[\"'\''[:space:]]*.*[\"'\''[:space:]]*([0-9a-fA-F]{40})[\"'\''[:space:]]*$/\1 \2/p' | \
while read -r file sha; do
echo -n "found entry: file=${file} ... "
if [ -e "${file}" ]; then
if echo "${sha} ${file}" | sha1sum -c --status; then
echo "sha1sum correct"
else
echo "sha1sum INCORRECT! skipping..."
fi
else
echo -n "try to download... "
if curl -L "${filestore}/download/${sha}" -o "${file}"; then
echo "ok"
echo -n "check sum... "
if echo "${sha} ${file}" | sha1sum -c --status; then
echo "ok"
else
echo "sha1sum INCORRECT! skipping..."
echo "remove file ${file}"
rm -f "${file}"
fi
else
echo "filed! skipping..."
fi
fi
done
fi
- name: Copy all source to rpm source dir
run: |
mkdir -p /home/builder/rpmbuild/SOURCES
cp -a * /home/builder/rpmbuild/SOURCES/
- name: RPM linter
run: |
source .env
rpmlint --file /home/builder/rpmbuild/SOURCES/${{ github.event.repository.name }}.rpmlintrc ${SPECFILE}
- name: Install dependencies
run: |
source .env
sudo urpmi --buildrequires --auto ${SPECFILE}
- name: Build rpm
run: |
source .env
rpmbuild -ba ${SPECFILE}
# - name: Deploy in repos packages
# if: github.ref == 'refs/heads/rosa2016.1'
# env:
# RPMBUILDROOT: /home/builder/rpmbuild
# run: |
# send_package() {
# local file=$1
# local arch=$2
# local type=$3
# if [ "$arch" = "noarch" ]; then
# url="${{ github.server_url }}/api/packages/${{ github.repository_owner }}/generic/r11_rpms/noarch/${file}"
# else
# url="${{ github.server_url }}/api/packages/${{ github.repository_owner }}/generic/r11_rpms/${arch}/${file}"
# fi
# if [ "$type" = "srpm" ]; then
# url="${{ github.server_url }}/api/packages/${{ github.repository_owner }}/generic/r11_rpms/srpms/${file}"
# fi
# curl --user ${{ github.repository_owner }}:${{ inputs.CI_DEPLOY }} \
# --upload-file "$file" \
# "$url"
# curl --user ${{ github.repository_owner }}:${{ inputs.CI_DEPLOY }} \
# --upload-file "$file" \
# "${{ github.server_url }}/api/packages/${{ github.repository_owner }}/generic/${{ github.event.repository.name }}/rpm/${file}"
# }
# for dir in SRPMS RPMS/*; do
# if [ -d "${RPMBUILDROOT}/${dir}" ]; then
# for file in "${RPMBUILDROOT}/${dir}"/*.rpm; do
# if [ -f "$file" ]; then
# if [ "$dir" = "SRPMS" ]; then
# arch="srpms"
# type="srpm"
# elif [ "$dir" = "noarch" ]; then
# arch="noarch"
# type="rpm"
# else
# arch=$(basename "${dir}")
# type="rpm"
# fi
# echo "********************************************************"
# echo "file: " "$file"
# echo "arch: " "$arch"
# echo "type: " "$type"
# echo "********************************************************"
# send_package "$file" "$arch" "$type"
# fi
# done
# fi
# done
# - name: Deploy in buildkite
# if: github.ref == 'refs/heads/rosa2016.1'
# run: |
# echo "Deploying src artifacts..."
# for file in /home/builder/rpmbuild/SRPMS/*.rpm; do
# curl -X POST https://api.buildkite.com/v2/packages/organizations/r11-team/registries/r11-srpms/packages \
# -H "Authorization: Bearer ${{ inputs.PUBLICATOR }}" \
# -F "file=@$file"
# done
#
# declare -A arch_urls=(
# ["x86_64"]="https://api.buildkite.com/v2/packages/organizations/r11-team/registries/r11-x86-64/packages"
# ["noarch"]="https://api.buildkite.com/v2/packages/organizations/r11-team/registries/r11-noarch/packages"
# )
#
# for arch in "${!arch_urls[@]}"; do
# echo "Deploying rpm artifacts for $arch..."
# for file in /home/builder/rpmbuild/RPMS/$arch/*.rpm; do
# if [ -f "$file" ]; then
# curl -X POST "${arch_urls[$arch]}" \
# -H "Authorization: Bearer ${{ inputs.PUBLICATOR }}" \
# -F "file=@$file"
# fi
# done
# done
- name: Deploy to urpm packages
if: github.ref == 'refs/heads/rosa2016.1'
run: |
source .env
echo "Deploying src artifacts..."
export REPOURL="http://getrepo:8888"
for file in /home/builder/rpmbuild/SRPMS/*.rpm; do
curl -X POST ${REPOURL}/src \
-H "Authorization: Bearer ${{ inputs.REPO_DEPLOY }}" \
-F "package=@$file"
done
declare -A arch_urls=(
["x86_64"]="${REPOURL}/x86_64"
["noarch"]="${REPOURL}/noarch"
["aarch64"]="${REPOURL}/aarch64"
["riscv64"]="${REPOURL}/riscv64"
["i386"]="${REPOURL}/i386"
)
for arch in "${!arch_urls[@]}"; do
echo "Deploying rpm artifacts for $arch..."
for file in /home/builder/rpmbuild/RPMS/$arch/*.rpm; do
if [ -f "$file" ]; then
curl -X POST "${arch_urls[$arch]}" \
-H "Authorization: Bearer ${{ inputs.REPO_DEPLOY }}" \
-F "package=@$file"
fi
done
done
container:
image: docker.io/zhemoitel/r11:builder-20250125