Skip to content

[ci] add workflow to copy the latest alpha release to the stable channel #5649

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 39 additions & 4 deletions .github/workflows/debrepo/repo_update.sh
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,14 @@ if [[ "$?" -eq "0" ]]; then
IS_MIRROR=0
fi

if [[ "$TYPE" -eq "stable" ]]; then
# mirror alpha repo
aptly -config=$CONF_FILE -keyring=$KEYRING mirror create boinc-alpha-mirror $BASEREPO/alpha/$DISTRO $DISTRO
exit_on_fail "Could not mirror alpha repository"
# update the packages from remote
aptly -config=$CONF_FILE -keyring=$KEYRING mirror update boinc-alpha-mirror
fi

echo
echo "Is mirror: $IS_MIRROR"
echo "Can create: $ALLOW_CREATE"
Expand All @@ -126,7 +134,7 @@ if [[ ! "$IS_MIRROR" -eq "0" ]]; then
fi

if [[ "$IS_MIRROR" -eq "0" ]]; then
# updates the the packages from remote
# updates the packages from remote
aptly -config=$CONF_FILE -keyring=$KEYRING mirror update boinc-$TYPE-mirror
exit_on_fail "Failed to update the local mirror"

Expand Down Expand Up @@ -181,9 +189,36 @@ if [[ "$IS_MIRROR" -eq "0" ]]; then
aptly -config=$CONF_FILE snapshot show old-boinc-$TYPE-snap
fi

# imports into the repo the new packages
aptly -config=$CONF_FILE repo add boinc-$TYPE $SRC/*.deb
exit_on_fail "Failed to add new packages"
if [[ "$TYPE" -eq "stable" ]]; then
# get only one latest packages of each type from the alpha repo
packets=$(aptly -config=$CONF_FILE mirror search boinc-alpha-mirror | grep -o '[^[:space:]]*_\([[:digit:]]*\.\)\{2\}[[:digit:]]*-\([[:digit:]]*_\)[^[:space:]]*' | sort -t '_' -k 2 -V -r | uniq)
declare -A split_lists
packets_list=()
while IFS= read -r line; do
packets_list+=("$line")
done <<< "$packets"
for item in "${packets_list[@]}"; do
prefix="${item%%_*}" # Extract the prefix (text before the first underscore)
split_lists["$prefix"]+="$item"$'\n' # Append the item to the corresponding prefix's list
done
for prefix in "${!split_lists[@]}"; do
echo "List for prefix: $prefix"
echo "${split_lists[$prefix]}"
values_list=()
while IFS= read -r line; do
values_list+=("$line")
done <<< "${split_lists[$prefix]}"
for value in "${values_list[@]}"; do
# copy the latest package to the local repo
aptly -config=$CONF_FILE repo import boinc-alpha-mirror boinc-$TYPE $value
break
done
done
else
# imports into the repo the new packages
aptly -config=$CONF_FILE repo add boinc-$TYPE $SRC/*.deb
exit_on_fail "Failed to add new packages"
fi

if [[ "$IS_MIRROR" -eq "0" ]]; then
# create new snapshot of the repo for deployment (with mirror)
Expand Down
167 changes: 167 additions & 0 deletions .github/workflows/linux-package-stable-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,167 @@
# This file is part of BOINC.
# http://boinc.berkeley.edu
# Copyright (C) 2024 University of California
#
# BOINC is free software; you can redistribute it and/or modify it
# under the terms of the GNU Lesser General Public License
# as published by the Free Software Foundation,
# either version 3 of the License, or (at your option) any later version.
#
# BOINC is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# See the GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with BOINC. If not, see <http://www.gnu.org/licenses/>.

name: Linux Package Stable Release
on:
workflow_dispatch:

env:
AWS_ACCESS_KEY_ID: ${{ secrets.S3_ACCESS_KEY }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.S3_SECRET_KEY }}
REPO_PRIV_KEY: ${{ secrets.REPO_PRIV_KEY }}
REPO_KEY: ${{ secrets.REPO_KEY }}
AWS_DEFAULT_REGION: us-west-2
PUBKEY: boinc.gpg # keep extension
MANTAINER: Vitalii Koshura <lestat.de.lionkur@gmail.com>
HOMEPAGE: https://boinc.berkeley.edu/
DESCRIPTION: BOINC lets you help cutting-edge science research using your computer. The BOINC app, running on your computer, downloads scientific computing jobs and runs them invisibly in the background. It's easy and safe.
BASEREPO: https://boinc.berkeley.edu/dl/linux # no trailing slash

jobs:
publish-deb-package:
name: Publish DEB Package
if: github.repository == 'BOINC/boinc'
runs-on: ubuntu-latest
strategy:
matrix:
os: [focal, jammy, noble, buster, bullseye, bookworm]
fail-fast: false
steps:
- name: Check if build is running from origin repo
if: ${{ success() && env.REPO_PRIV_KEY != 0 && env.REPO_KEY != 0 }}
run: |
echo "SKIP_RUN=0" >> $GITHUB_ENV

- name: Check if build is running from fork
if: ${{ success() && (env.REPO_PRIV_KEY == 0 || env.REPO_KEY == 0) }}
run: |
echo "SKIP_RUN=1" >> $GITHUB_ENV

- uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29
if: ${{ success() && env.SKIP_RUN == 0 }}
with:
fetch-depth: 2

- name: Install dependencies
if: ${{ success() && env.SKIP_RUN == 0 }}
run: |
# Install aptly version 1.5.0+ (to support ubuntu xz compression)
# gpg1 is used for compatibility with aptly
wget -qO - https://www.aptly.info/pubkey.txt | sudo apt-key add -
echo "deb http://repo.aptly.info/ squeeze main" | sudo tee -a /etc/apt/sources.list
sudo apt update -qq
sudo apt-get install -y aptly gnupg1 gpgv1

- name: Setup GPG keys
if: ${{ success() && env.SKIP_RUN == 0 }}
run: |
echo "${{ env.REPO_PRIV_KEY }}" > ${{ github.workspace }}/boinc.priv.key
echo "${{ env.REPO_KEY }}" > ${{ github.workspace }}/boinc.pub.key
cp "${{ github.workspace }}/boinc.pub.key" "${{ github.workspace }}/${{ env.PUBKEY }}"

- name: Update or create the repository using aptly
if: ${{ success() && env.SKIP_RUN == 0 }}
run: |
# 0 true / 1 false
ALLOW_CREATE=0
cd ${{ github.workspace }}/.github/workflows/debrepo/
./repo_update.sh "$ALLOW_CREATE" ${{ env.BASEREPO }} ${{ github.workspace }} ${{ matrix.os }} "stable" ${{ env.PUBKEY }}

- uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808
if: ${{ success() && env.SKIP_RUN == 0 }}
with:
name: repo-stable-${{ matrix.os }}
path: "${{ github.workspace }}/repo-stable-${{ matrix.os }}.tar.gz"

- name: Deploy to boinc server
if: ${{ success() && env.SKIP_RUN == 0 }}
run: |
set -e
curl -s --fail --write-out "%{http_code}" -F 'upload_file=@${{ github.workspace }}/repo-stable-${{ matrix.os }}.tar.gz' https://boinc.berkeley.edu/upload.php --cookie "auth=${{ secrets.BOINC_AUTH }}" --form "submit=on"

publish-rpm-package:
name: Publish RPM Package
if: github.repository == 'BOINC/boinc'
runs-on: ubuntu-latest
container:
image: fedora:38
strategy:
matrix:
os: [fc37, fc38, fc39, fc40, suse15_4, suse15_5, suse15_6]
fail-fast: false
env:
ARCH: x86_64
PUBKEY_HASH: D4460B4F0EEDE2C0662092F640254C9B29853EA6
steps:
- name: Check if build is running from origin repo
if: ${{ success() && env.REPO_PRIV_KEY != 0 && env.REPO_KEY != 0 }}
run: |
echo "SKIP_RUN=0" >> $GITHUB_ENV

- name: Check if build is running from fork
if: ${{ success() && (env.REPO_PRIV_KEY == 0 || env.REPO_KEY == 0) }}
run: |
echo "SKIP_RUN=1" >> $GITHUB_ENV

- uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29
if: ${{ success() && env.SKIP_RUN == 0 }}
with:
fetch-depth: 2

- name: DNF Preparation
id: dnf-prep
if: ${{ success() && env.SKIP_RUN == 0 }}
run: |
sudo echo "max_parallel_downloads=10" >> /etc/dnf/dnf.conf
sudo echo "fastestmirror=True" >> /etc/dnf/dnf.conf
sudo dnf install -y wget rpm rpm-build rpm-sign expect createrepo_c dnf-utils jq p7zip-plugins

- name: Setup GPG keys
if: ${{ success() && env.SKIP_RUN == 0 }}
run: |
echo "${{ env.REPO_PRIV_KEY }}" > boinc.priv.key
echo "${{ env.REPO_KEY }}" > boinc.pub.key
cp "boinc.pub.key" "${{ env.PUBKEY }}"
# keyring prepare
gpg --import "boinc.pub.key"
gpg --import "boinc.priv.key"
expect -c 'spawn gpg --edit-key ${{ env.PUBKEY_HASH }} trust quit; send "5\ry\r"; expect eof'
gpg --list-keys

- name: Update or create the repository
if: ${{ success() && env.SKIP_RUN == 0 }}
run: |
# Bash scripts do not support boolean values so convert to 0 true / 1 false
# 0 true / 1 false
ALLOW_CREATE=0
CWD=$(pwd)

cd .github/workflows/rpmrepo/
# Updates or creates the repository
./repo_update.sh "$ALLOW_CREATE" ${{ env.BASEREPO }} ${CWD} ${{ matrix.os }} "stable" ${{ env.PUBKEY }} ${{ env.PUBKEY_HASH }} ${{ env.ARCH }}

- uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808
if: ${{ success() && env.SKIP_RUN == 0 }}
with:
name: repo-stable-${{ matrix.os }}
path: "repo-stable-${{ matrix.os }}.tar.gz"

- name: Deploy to boinc server
if: ${{ success() && env.SKIP_RUN == 0 }}
run: |
set -e
curl -s --fail --write-out "%{http_code}" -F 'upload_file=@repo-stable-${{ matrix.os }}.tar.gz' https://boinc.berkeley.edu/upload.php --cookie "auth=${{ secrets.BOINC_AUTH }}" --form "submit=on"
76 changes: 74 additions & 2 deletions .github/workflows/rpmrepo/repo_update.sh
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,80 @@ if [[ ! "$IS_MIRROR" -eq "0" ]]; then
fi
fi

cp $RPMSRC/*.rpm $CWD/mirror/
exit_on_fail "Failed to add new packages"
if [[ "$TYPE" -eq "stable" ]]; then
# create alpha repo of the same distribution
echo """#
# BOINC Repository
#

[boinc-alpha-$DISTRO]
name = BOINC alpha $DISTRO repository
baseurl = $BASEREPO/alpha/$DISTRO
arch = $ARCH
priority = 100
enabled = 1
gpgcheck = 1
gpgkey = $BASEREPO/alpha/$DISTRO/$RELEASEKEY
max_parallel_downloads = 2

""" > "$CWD/mirror/boinc-alpha-$DISTRO.repo"

# necessary for reposync to work correctly
mkdir -p /etc/yum/repos.d/
cp "$CWD/mirror/boinc-alpha-$DISTRO.repo" /etc/yum/repos.d/
dnf update -y -qq

# mirror the currently deployed alpha repo (if any)
cd $CWD/alpha

reposync --nobest -a $ARCH --download-metadata --norepopath --repoid boinc-alpha-$DISTRO
exit_on_fail "Could not mirror alpha ${REPO}"

# keep only 1 last version of each package
cd $CWD/alpha/
packets=$(find *.rpm | sort -t '-' -k 2 -V | uniq)
declare -A split_lists
packets_list=()
while IFS= read -r line; do
packets_list+=("$line")
done <<< "$packets"
for item in "${packets_list[@]}"; do
prefix=$(echo "$item" | cut -d '-' -f 1-2 ) # Extract the prefix (text before the second dash)
split_lists["$prefix"]+="$item"$'\n' # Append the item to the corresponding prefix's list
done

for prefix in "${!split_lists[@]}"; do
echo "List for prefix: $prefix"
echo "${split_lists[$prefix]}"
count=$(echo "${split_lists[$prefix]}" | wc -l)
number=$(expr $count - 1)
echo "count=$number"
i=0
exceed=$(expr $number - 1)
echo "exceed=$exceed"
if (( exceed > 0)); then
values_list=()
while IFS= read -r line; do
values_list+=("$line")
done <<< "${split_lists[$prefix]}"
for value in "${values_list[@]}"; do
if (( i < exceed )); then
echo "Remove: $value"
i=$((i+1))
rm $value
exit_on_fail "Failed to remove the package"
else
break
fi
done
fi
done
cp $CWD/alpha/*.rpm $CWD/mirror/
exit_on_fail "Failed to add new packages"
else
cp $RPMSRC/*.rpm $CWD/mirror/
exit_on_fail "Failed to add new packages"
fi

cd $CWD/mirror/
# keep only 4 last versions of each package
Expand Down
Loading