r11_workflows/action.yml

203 lines
6.8 KiB
YAML
Raw Normal View History

2025-01-04 13:23:29 +03:00
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
runs:
using: "composite"
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
source .env
echo "SPECFILE = ${SPECFILE}"
2025-01-04 15:53:01 +03:00
2025-01-04 13:23:29 +03:00
- name: Debug Print environment variables
run: |
source .env
env
2025-01-04 15:53:01 +03:00
2025-01-04 13:23:29 +03:00
- name: Debug os version and check exists spec
run: |
cat /etc/*release*
echo "check specfile" && [ -f ${SPECFILE} ] || exit 1
2025-01-04 15:53:01 +03:00
2025-01-04 13:23:29 +03:00
- name: Remove djam_personal repo
2025-01-04 13:49:19 +03:00
run: |
2025-01-04 16:45:17 +03:00
if grep -q "djam_personal" /etc/urpmi/urpmi.cfg; then sudo urpmi.removemedia djam_personal; fi
2025-01-04 15:53:01 +03:00
2025-01-04 13:23:29 +03:00
- name: Update repo
run: |
sudo urpmi.update -fa
2025-01-04 15:53:01 +03:00
2025-01-04 13:23:29 +03:00
- name: Download sources artifacts
run: |
2025-01-04 16:53:26 +03:00
abfyml=.abf.yml
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 "https://file-store.rosalinux.ru/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-04 15:53:01 +03:00
2025-01-04 13:23:29 +03:00
- name: Linter
run: |
source .env
rpmlint ${SPECFILE}
2025-01-04 15:53:01 +03:00
2025-01-04 13:23:29 +03:00
- name: Install dependies
run: |
source .env
sudo urpmi --buildrequires --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-05 14:00:43 +03:00
- name: DEBUG tokens
2025-01-05 05:00:16 +03:00
env:
2025-01-05 13:48:56 +03:00
CI_DEPLOY_SEC: ${{ secrets.CI_DEPLOY }}
CI_DEPLOY: ${{ inputs.CI_DEPLOY }}
PUBLICATOR: ${{ inputs.PUBLICATOR }}
2025-01-04 13:23:29 +03:00
run: |
echo "Deploying artifacts..."
2025-01-05 13:35:39 +03:00
echo "********************************************************************"
2025-01-05 13:59:43 +03:00
if [ -n "${CI_DEPLOY_SEC}" ]; then
2025-01-05 20:55:53 +03:00
echo "CI_DEPLOY_SEC: ${CI_DEPLOY_SEC:0:3}***${CI_DEPLOY_SEC: -3}"
2025-01-05 13:59:43 +03:00
else
echo "CI_DEPLOY: не передан"
fi
if [ -n "${CI_DEPLOY}" ]; then
echo "CI deploy token: ${CI_DEPLOY:0:3}***${CI_DEPLOY: -3}"
else
echo "CI deploy token: не передан"
fi
if [ -n "${PUBLICATOR}" ]; then
echo "Publicator token: ${PUBLICATOR:0:3}***${PUBLICATOR: -3}"
else
echo "Publicator token: не передан"
fi
2025-01-05 13:35:39 +03:00
echo "********************************************************************"
2025-01-05 13:41:28 +03:00
2025-01-05 13:59:43 +03:00
2025-01-05 13:41:28 +03:00
- name: Deploy in repos packages
if: github.ref == 'refs/heads/rosa2016.1'
env:
2025-01-06 17:16:25 +03:00
RPMBUILDROOT: /home/builder/rpmbuild
2025-01-05 13:41:28 +03:00
run: |
2025-01-06 17:57:23 +03:00
send_package() {
local file=$1
local arch=$2
local type=$3
if [ "$arch" = "noarch" ]; then
2025-01-06 18:47:14 +03:00
url="${{ github.server_url }}/api/packages/${{ github.repository_owner }}/generic/r11_rpms/noarch/${file}"
2025-01-06 17:57:23 +03:00
else
2025-01-06 18:47:14 +03:00
url="${{ github.server_url }}/api/packages/${{ github.repository_owner }}/generic/r11_rpms/${arch}/${file}"
2025-01-06 17:57:23 +03:00
fi
2025-01-06 17:16:25 +03:00
2025-01-06 17:57:23 +03:00
if [ "$type" = "srpm" ]; then
2025-01-06 18:47:14 +03:00
url="${{ github.server_url }}/api/packages/${{ github.repository_owner }}/generic/r11_rpms/srpms/${file}"
2025-01-06 17:57:23 +03:00
fi
2025-01-06 18:02:34 +03:00
curl --user ${{ github.repository_owner }}:${{ inputs.CI_DEPLOY }} \
2025-01-06 17:57:23 +03:00
--upload-file "$file" \
"$url"
2025-01-06 18:47:14 +03:00
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-06 17:57:23 +03:00
}
2025-01-06 19:02:04 +03:00
for dir in SRPMS RPMS/*; do
2025-01-06 17:57:23 +03:00
if [ -d "${RPMBUILDROOT}/${dir}" ]; then
for file in "${RPMBUILDROOT}/${dir}"/*.rpm; do
if [ -f "$file" ]; then
if [ "$dir" = "SRPMS" ]; then
2025-01-06 19:02:04 +03:00
arch="srpms"
2025-01-06 17:57:23 +03:00
type="srpm"
elif [ "$dir" = "noarch" ]; then
arch="noarch"
type="rpm"
else
arch=$(basename "${dir}")
type="rpm"
fi
2025-01-06 18:55:53 +03:00
echo "********************************************************"
echo "file: " "$file"
echo "arch: " "$arch"
echo "type: " "$type"
echo "********************************************************"
send_package "$file" "$arch" "$type"
2025-01-06 17:57:23 +03:00
fi
done
2025-01-06 17:16:25 +03:00
fi
2025-01-06 17:53:07 +03:00
done
2025-01-06 17:16:25 +03:00
# cd /home/builder/rpmbuild/SRPMS/
# for file in *.rpm; do
# curl --user ${GITHUB_REPOSITORY_OWNER}:${{ inputs.CI_DEPLOY }} \
# --upload-file "$file" \
# ${GITHUB_SERVER_URL}/api/packages/${GITHUB_REPOSITORY_OWNER}/generic/srpms/"$file"
# done
# for file in /home/builder/rpmbuild/RPMS/x86_64/*.rpm; do
# curl --user ${GITHUB_REPOSITORY_OWNER}:${{ inputs.CI_DEPLOY }} \
# --upload-file "$file" \
# ${GITHUB_SERVER_URL}/api/packages/${GITHUB_REPOSITORY_OWNER}/rpm/upload
# done
2025-01-04 15:53:01 +03:00
2025-01-04 13:23:29 +03:00
- name: Deploy in buildkitie
2025-01-04 23:39:08 +03:00
if: github.ref == 'refs/heads/rosa2016.1'
2025-01-04 13:23:29 +03:00
run: |
echo "Deploying src artifacts..."
2025-01-04 22:53:49 +03:00
for file in /home/builder/rpmbuild/SRPMS/*.rpm; do
2025-01-04 13:23:29 +03:00
curl -X POST https://api.buildkite.com/v2/packages/organizations/r11-team/registries/r11-srpms/packages \
2025-01-05 20:55:53 +03:00
-H "Authorization: Bearer ${{ inputs.PUBLICATOR }}" \
2025-01-04 22:53:49 +03:00
-F "file=@$file"
done
2025-01-04 13:23:29 +03:00
echo "Deploying rpm artifacts..."
2025-01-04 22:53:49 +03:00
for file in /home/builder/rpmbuild/RPMS/x86_64/*.rpm; do
2025-01-04 13:23:29 +03:00
curl -X POST https://api.buildkite.com/v2/packages/organizations/r11-team/registries/r11-x86-64/packages \
2025-01-05 20:55:53 +03:00
-H "Authorization: Bearer ${{ inputs.PUBLICATOR }}" \
2025-01-04 22:53:49 +03:00
-F "file=@$file"
done
2025-01-04 15:53:01 +03:00
2025-01-04 15:44:15 +03:00
container:
image: packages.buildkite.com/r11-team/r11/builder:latest
2025-01-04 15:30:48 +03:00