r11_workflows/action.yml

244 lines
8.3 KiB
YAML
Raw Permalink Normal View History

2025-01-04 13:23:29 +03:00
name: Build and Deploy
description: Build and deploy RPM packages
2025-01-24 00:11:00 +03:00
inputs:
PUBLICATOR:
description: Publicator token
required: true
CI_DEPLOY:
description: CI deploy token
required: true
2025-01-30 17:37:54 +03:00
REPO_DEPLOY:
description: Deploy artefacts to urpm repo
required: true
2025-01-23 13:13:08 +03:00
on:
push:
branches:
- rosa2016.1
2025-01-24 00:11:00 +03:00
# workflow_dispatch:
# inputs:
# PUBLICATOR:
# description: Publicator token
# required: true
# CI_DEPLOY:
# description: CI deploy token
# required: true
2025-01-23 13:13:08 +03:00
2025-01-25 18:24:33 +03:00
runs:
using: "composite"
#jobs:
# build-and-deploy:
2025-01-04 13:23:29 +03:00
steps:
- name: Checkout code
run: |
git clone ${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}.git ${GITHUB_WORKSPACE}
git checkout ${GITHUB_SHA}
2025-01-04 13:23:29 +03:00
export SPECFILE=$(find . -type f -name "*.spec")
echo "SPECFILE=${SPECFILE}" > .env
2025-02-02 15:59:56 +03:00
echo "LC_ALL=C" >> .env
2025-01-04 13:23:29 +03:00
source .env
echo "SPECFILE = ${SPECFILE}"
2025-01-04 15:53:01 +03:00
2025-02-02 01:48:04 +03:00
#- name: Remove all repo
# run: |
2025-01-10 22:44:52 +03:00
# if grep -q "djam_personal" /etc/urpmi/urpmi.cfg; then sudo urpmi.removemedia djam_personal; fi
# Убираем все старые источники
2025-02-02 01:48:04 +03:00
# sudo urpmi.removemedia -a
2025-01-10 22:44:52 +03:00
# Переключаемся на mirror.rosa.ru
# sudo urpmi.addmedia --wget -v --distrib --mirrorbrain https://mirror.rosa.ru/rosa/rosa2016.1/$ARCH
2025-02-02 01:48:04 +03:00
# sudo urpmi.addmedia --distrib --mirrorlist https://tvoygit.ru/Djam/r11_mirrorlist/raw/branch/main/rosa2016.1.x86_64.list
2025-01-04 15:53:01 +03:00
2025-02-07 13:10:22 +03:00
- name: Debug env
run: |
source .env
env
2025-01-10 22:44:52 +03:00
2025-01-27 18:16:49 +03:00
- name: Update repo and pre-install
run: |
2025-02-02 15:59:56 +03:00
source .env
2025-02-04 01:35:45 +03:00
export LC_ALL="C"
2025-02-02 01:48:04 +03:00
export REPOURL="http://newrepo:8080"
2025-01-29 02:37:10 +03:00
sudo urpmi.addmedia personalold http://oldrepo:8090/rosa2016.1/x86_64/main/release/
2025-02-04 00:16:51 +03:00
sudo urpmi.update -aff
2025-02-02 01:48:04 +03:00
sudo urpmi.addmedia newrepo_x86-64 ${REPOURL}/x86_64/
sudo urpmi.addmedia newrepo_noarch ${REPOURL}/noarch/
2025-02-04 01:44:39 +03:00
sudo urpmi --no-suggests --force --auto-update --allow-force --auto-select --auto
2025-02-04 21:38:35 +03:00
sudo urpmi --auto --allow-force tar gzip curl openssl3.3
2025-01-04 15:53:01 +03:00
2025-01-04 13:23:29 +03:00
- name: Download sources artifacts
run: |
2025-02-02 15:59:56 +03:00
source .env
2025-02-02 01:48:04 +03:00
2025-02-02 02:54:46 +03:00
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
2025-01-12 02:57:56 +03:00
- name: Copy all source to rpm source dir
run: |
2025-01-12 03:02:04 +03:00
mkdir -p /home/builder/rpmbuild/SOURCES
2025-01-12 02:59:41 +03:00
cp -a * /home/builder/rpmbuild/SOURCES/
2025-01-04 15:53:01 +03:00
2025-01-12 02:57:56 +03:00
- name: RPM linter
2025-01-04 13:23:29 +03:00
run: |
source .env
2025-02-06 13:24:46 +03:00
rpmlint --file /home/builder/rpmbuild/SOURCES/${{ github.event.repository.name }}.rpmlintrc \
--file /home/builder/rpmbuild/SOURCES/$(basename ${SPECFILE} .spec).rpmlintrc \
${SPECFILE}
2025-01-04 15:53:01 +03:00
2025-01-15 18:16:39 +03:00
- name: Install dependencies
2025-01-04 13:23:29 +03:00
run: |
2025-01-15 18:16:39 +03:00
source .env
2025-02-02 01:48:04 +03:00
2025-02-04 00:16:51 +03:00
sudo urpmi --buildrequires --no-suggests --auto ${SPECFILE}
2025-01-04 15:53:01 +03:00
2025-01-04 13:23:29 +03:00
- name: Build rpm
run: |
source .env
rpmbuild -ba ${SPECFILE}
2025-01-04 15:53:01 +03:00
2025-01-27 18:16:49 +03:00
# - 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
2025-01-06 18:47:14 +03:00
2025-01-27 18:16:49 +03:00
# 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
2025-01-06 17:57:23 +03:00
2025-01-27 18:16:49 +03:00
# if [ "$type" = "srpm" ]; then
# url="${{ github.server_url }}/api/packages/${{ github.repository_owner }}/generic/r11_rpms/srpms/${file}"
# fi
2025-01-06 17:16:25 +03:00
2025-01-27 18:16:49 +03:00
# 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}"
# }
2025-01-04 15:53:01 +03:00
2025-01-27 18:16:49 +03:00
# 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
2025-01-14 16:32:02 +03:00
2025-01-27 18:16:49 +03:00
# - 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
2025-01-30 17:37:54 +03:00
- name: Deploy to urpm packages
if: github.ref == 'refs/heads/rosa2016.1'
run: |
2025-02-02 15:59:56 +03:00
source .env
2025-01-30 17:37:54 +03:00
echo "Deploying src artifacts..."
2025-02-02 13:04:25 +03:00
export REPOURL="http://getrepo:8888"
2025-01-30 17:37:54 +03:00
for file in /home/builder/rpmbuild/SRPMS/*.rpm; do
2025-02-02 00:45:48 +03:00
curl -X POST ${REPOURL}/src \
2025-01-30 17:37:54 +03:00
-H "Authorization: Bearer ${{ inputs.REPO_DEPLOY }}" \
2025-01-31 00:38:04 +03:00
-F "package=@$file"
2025-01-30 17:37:54 +03:00
done
declare -A arch_urls=(
2025-01-31 00:59:50 +03:00
["x86_64"]="${REPOURL}/x86_64"
["noarch"]="${REPOURL}/noarch"
["aarch64"]="${REPOURL}/aarch64"
["riscv64"]="${REPOURL}/riscv64"
2025-01-31 00:38:04 +03:00
["i386"]="${REPOURL}/i386"
2025-01-30 17:37:54 +03:00
)
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
2025-01-04 15:44:15 +03:00
container:
2025-01-27 18:16:49 +03:00
image: docker.io/zhemoitel/r11:builder-20250125
2025-01-23 13:13:08 +03:00