mirror of
https://tvoygit.ru/Djam/r11_workflows.git
synced 2025-02-23 17:02:46 +00:00
203 lines
6.9 KiB
YAML
203 lines
6.9 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
|
|
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}"
|
|
|
|
# - name: Debug Print environment variables
|
|
# run: |
|
|
# source .env
|
|
# env
|
|
|
|
# - name: Debug os version and check exists spec
|
|
# run: |
|
|
# cat /etc/*release*
|
|
# echo "check specfile" && [ -f ${SPECFILE} ] || exit 1
|
|
|
|
- name: Remove djam_personal repo
|
|
run: |
|
|
if grep -q "djam_personal" /etc/urpmi/urpmi.cfg; then sudo urpmi.removemedia djam_personal; fi
|
|
|
|
- name: Update repo
|
|
run: |
|
|
sudo urpmi.update -fa
|
|
sudo urpmi --auto rpm-mandriva-setup-build
|
|
|
|
- name: Download sources artifacts
|
|
run: |
|
|
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
|
|
|
|
- name: Linter
|
|
run: |
|
|
source .env
|
|
rpmlint ${SPECFILE}
|
|
|
|
- name: Install dependies
|
|
run: |
|
|
source .env
|
|
sudo urpmi --buildrequires --auto ${SPECFILE}
|
|
|
|
- name: Build rpm
|
|
run: |
|
|
source .env
|
|
rpmbuild -ba ${SPECFILE}
|
|
|
|
- name: DEBUG tokens
|
|
env:
|
|
CI_DEPLOY_SEC: ${{ secrets.CI_DEPLOY }}
|
|
CI_DEPLOY: ${{ inputs.CI_DEPLOY }}
|
|
PUBLICATOR: ${{ inputs.PUBLICATOR }}
|
|
run: |
|
|
echo "Deploying artifacts..."
|
|
echo "********************************************************************"
|
|
if [ -n "${CI_DEPLOY_SEC}" ]; then
|
|
echo "CI_DEPLOY_SEC: ${CI_DEPLOY_SEC:0:3}***${CI_DEPLOY_SEC: -3}"
|
|
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
|
|
echo "********************************************************************"
|
|
|
|
|
|
|
|
- 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
|
|
|
|
|
|
|
|
# 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
|
|
|
|
- name: Deploy in buildkitie
|
|
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
|
|
echo "Deploying rpm artifacts..."
|
|
for file in /home/builder/rpmbuild/RPMS/x86_64/*.rpm; do
|
|
curl -X POST https://api.buildkite.com/v2/packages/organizations/r11-team/registries/r11-x86-64/packages \
|
|
-H "Authorization: Bearer ${{ inputs.PUBLICATOR }}" \
|
|
-F "file=@$file"
|
|
done
|
|
|
|
container:
|
|
image: packages.buildkite.com/r11-team/r11/builder:latest
|
|
|