Skip to content

Commit

Permalink
[CI][linux] Build DEB package flow
Browse files Browse the repository at this point in the history
Signed-off-by: Vitalii Koshura <lestat.de.lionkur@gmail.com>
  • Loading branch information
AenBleidd committed Jun 30, 2023
1 parent dc85ad4 commit f784c28
Show file tree
Hide file tree
Showing 15 changed files with 222 additions and 31 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/debrepo/aptly.bullseye.conf
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"S3PublishEndpoints": {},
"SwiftPublishEndpoints": {},
"enableMetricsEndpoint": false,
"logLevel": "debug",
"logLevel": "info",
"logFormat": "default",
"serveInAPIMode": false
}
2 changes: 1 addition & 1 deletion .github/workflows/debrepo/aptly.buster.conf
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"S3PublishEndpoints": {},
"SwiftPublishEndpoints": {},
"enableMetricsEndpoint": false,
"logLevel": "debug",
"logLevel": "info",
"logFormat": "default",
"serveInAPIMode": false
}
2 changes: 1 addition & 1 deletion .github/workflows/debrepo/aptly.focal.conf
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"S3PublishEndpoints": {},
"SwiftPublishEndpoints": {},
"enableMetricsEndpoint": false,
"logLevel": "debug",
"logLevel": "info",
"logFormat": "default",
"serveInAPIMode": false
}
2 changes: 1 addition & 1 deletion .github/workflows/debrepo/aptly.jammy.conf
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"S3PublishEndpoints": {},
"SwiftPublishEndpoints": {},
"enableMetricsEndpoint": false,
"logLevel": "debug",
"logLevel": "info",
"logFormat": "default",
"serveInAPIMode": false
}
8 changes: 4 additions & 4 deletions .github/workflows/debrepo/package_depends.sh
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,18 @@ function exit_usage() {

case "$1_$2" in
# ubuntu distros
"jammy_linux_client-vcpkg")
"jammy_linux_client")
echo "libc6,libxss1 (>= 1.2.3)"
;;
"focal_linux_client-vcpkg")
"focal_linux_client")
echo "libc6,libxss1 (>= 1.2.3)"
;;

# debian distros
"bullseye_linux_client-vcpkg")
"bullseye_linux_client")
echo "libc6,libxss1 (>= 1.2.3)"
;;
"buster_linux_client-vcpkg")
"buster_linux_client")
echo "libc6,libxss1 (>= 1.2.3)"
;;

Expand Down
28 changes: 8 additions & 20 deletions .github/workflows/debrepo/package_prepare.sh
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -63,16 +63,14 @@ function prepare_manager() {

ROOT=$(pwd)

OS="$1" # distro for which the prepare is done
FULLPKG="$2" # full name of the package
PKG="$3" # name of the artifact
BASEPKG="$4" # name of the artifact type
FULLPKG="$1" # full name of the package
BASEPKG="$2" # name of the artifact type

# validity check
case "$BASEPKG" in
"linux_client-vcpkg")
"linux_client")
;;
"linux_manager-without-webview")
"linux_manager")
;;

*) echo "ERROR: Unknown package preparation requested"
Expand All @@ -87,21 +85,11 @@ exit_on_fail
pushd "$ROOT/$FULLPKG"
exit_on_fail

stat "${ROOT}/pkgs/$PKG.zip"
exit_on_fail

# unpack the github artifact
7z x "${ROOT}/pkgs/$PKG.zip"
exit_on_fail

stat "${BASEPKG}.7z"
stat "${ROOT}/pkgs/${BASEPKG}.7z"
exit_on_fail

# unpack the boinc archive
7z x "${BASEPKG}.7z"
exit_on_fail

rm -f "${BASEPKG}.7z"
7z x "${ROOT}/pkgs/${BASEPKG}.7z"
exit_on_fail

find .
Expand All @@ -112,10 +100,10 @@ exit_on_fail

# specialized prepare
case "$BASEPKG" in
"linux_client-vcpkg")
"linux_client")
prepare_client
;;
"linux_manager-without-webview")
"linux_manager")
prepare_manager
;;
*) echo "ERROR: Unknown package preparation requested"
Expand Down
Empty file modified .github/workflows/debrepo/repo_remove.sh
100644 → 100755
Empty file.
6 changes: 5 additions & 1 deletion .github/workflows/debrepo/repo_update.sh
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash -xe
#!/bin/bash

# support functions
function exit_on_fail() {
Expand Down Expand Up @@ -115,6 +115,10 @@ if [[ "$IS_MIRROR" -eq "0" ]]; then
aptly -config=$CONF_FILE repo import boinc-$TYPE-mirror boinc-$TYPE "Name"
exit_on_fail "Failed to import the remote mirror into local"

###
aptly -config=$CONF_FILE repo search boinc-$TYPE
###

# creates the snapshot of the old situation
aptly -config=$CONF_FILE snapshot create old-boinc-$TYPE-snap from repo boinc-$TYPE
exit_on_fail "Failed to create old snapshot of the local repo"
Expand Down
201 changes: 200 additions & 1 deletion .github/workflows/linux-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@ env:
AWS_ACCESS_KEY_ID: ${{ secrets.S3_ACCESS_KEY }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.S3_SECRET_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:
prepare-binaries:
Expand Down Expand Up @@ -109,4 +114,198 @@ jobs:
if: success()
with:
name: linux-package_${{ matrix.type }}_${{ github.event.pull_request.head.sha }}
path: deploy/linux_${{ matrix.type }}.7z
path: deploy/linux_${{ matrix.type }}.7z

build-deb-package:
name: Build DEB Package
if: github.repository == 'BOINC/boinc'
runs-on: ubuntu-latest
needs: prepare-binaries
strategy:
matrix:
os: [jammy, focal, bullseye, buster]
type: [client, manager]
fail-fast: false
env:
ARCH: amd64
steps:
- name: Check if build is running from origin repo
if: ${{ success() && env.AWS_ACCESS_KEY_ID != 0 && env.AWS_SECRET_ACCESS_KEY != 0 }}
run: |
echo "SKIP_RUN=0" >> $GITHUB_ENV
- name: Check if build is running from fork
if: ${{ success() && (env.AWS_ACCESS_KEY_ID == 0 || env.AWS_SECRET_ACCESS_KEY == 0) }}
run: |
echo "SKIP_RUN=1" >> $GITHUB_ENV
- uses: actions/checkout@v3
if: ${{ success() && env.SKIP_RUN == 0 }}
with:
fetch-depth: 2

- name: Packages info preparation
if: ${{ success() && env.SKIP_RUN == 0 }}
run: |
PKG_VERSION=$(cat version.h | grep BOINC_VERSION_STRING | sed -e 's|#define BOINC_VERSION_STRING||' | jq -r .)
if [[ "x${PKG_VERSION}" == "x" ]]; then
printf "Could not obtain release package version from version.h"
exit 1
fi
# Setup Environment vars
PKG_NAME="boinc-${{ matrix.type }}"
PKG_VERSION="${PKG_VERSION}-${{ github.run_number }}"
PKG_FULL="${PKG_NAME}_${PKG_VERSION}_${{ env.ARCH }}"
echo "PKG_VERSION=${PKG_VERSION}" >> $GITHUB_ENV
echo "PKG_NAME=${PKG_NAME}" >> $GITHUB_ENV
echo "PKG_FULL=${PKG_FULL}" >> $GITHUB_ENV
echo "PUBKEY=${{ env.PUBKEY }}" >> $GITHUB_ENV
echo "Package name: ${PKG_NAME}"
echo "Package version: ${PKG_VERSION}"
echo "Full package name: ${PKG_FULL}"
echo "Key file: ${{ env.PUBKEY }}"
- name: Download
if: ${{ success() && env.SKIP_RUN == 0 }}
uses: actions/download-artifact@v3
with:
name: linux-package_${{ matrix.type }}_${{ github.event.pull_request.head.sha }}
path: pkgs/

- name: Prepare package
if: ${{ success() && env.SKIP_RUN == 0 }}
run: |
ls -l pkgs/
mkdir ${PKG_FULL}
${{ github.workspace }}/.github/workflows/debrepo/package_prepare.sh "${PKG_FULL}" "linux_${{ matrix.type }}"
- name: Prepare package definition
if: ${{ success() && env.SKIP_RUN == 0 }}
run: |
# Derive the package dependencies for the selected package / os / release combination selected
cd ${{ github.workspace }}/.github/workflows/debrepo/
PKG_DEPS=$(bash package_depends.sh ${{ matrix.os }} linux_${{ matrix.type }})
echo "Dependencies: ${PKG_DEPS}"
# Produce the package DEB definition
cd "${{ github.workspace }}/${PKG_FULL}"
echo "Name:${PKG_NAME}
Package:${PKG_NAME}
Version:${PKG_VERSION}
Maintainer:${{ env.MANTAINER }}
Depends:${PKG_DEPS}
Architecture:${{ env.ARCH }}
Homepage:${{ env.HOMEPAGE }}
Description:${{ env.DESCRIPTION }}" \
> "${{ github.workspace }}/${PKG_FULL}/DEBIAN/control"
echo "------------------------"
cat "${{ github.workspace }}/${PKG_FULL}/DEBIAN/control"
echo "------------------------"
- name: Create Ubuntu Package
if: ${{ success() && env.SKIP_RUN == 0 && ( matrix.os == 'jammy' || matrix.os == 'focal') }}
run: |
cd ${{ github.workspace }}/
# Build the actual package for Ubuntu with XZ compression
dpkg-deb -Zxz --build "${{ github.workspace }}/${PKG_FULL}"
- name: Create Debian Package
if: ${{ success() && env.SKIP_RUN == 0 && ( matrix.os == 'bullseye' || matrix.os == 'buster') }}
run: |
cd ${{ github.workspace }}/
# Build the actual package for Debian with GZIP compression
dpkg-deb -Zgzip --build "${{ github.workspace }}/${PKG_FULL}"
- name: Get info from generated package
if: ${{ success() && env.SKIP_RUN == 0 }}
run: |
# Get info from the generated package
dpkg-deb --info "${{ github.workspace }}/${PKG_FULL}.deb"
- name: Upload artifacts
uses: actions/upload-artifact@v3
if: ${{ success() && env.SKIP_RUN == 0 }}
with:
name: linux-package_${{ matrix.type }}_${{ matrix.os }}_${{ github.event.pull_request.head.sha }}
path: ${{ github.workspace }}/${{ env.PKG_FULL }}.deb

publish-deb-package:
name: Publish DEB Package
if: github.repository == 'BOINC/boinc'
runs-on: ubuntu-latest
needs: build-deb-package
strategy:
matrix:
os: [jammy, focal, bullseye, buster]
fail-fast: false
steps:
- name: Check if build is running from origin repo
if: ${{ success() && env.AWS_ACCESS_KEY_ID != 0 && env.AWS_SECRET_ACCESS_KEY != 0 }}
run: |
echo "SKIP_RUN=0" >> $GITHUB_ENV
- name: Check if build is running from fork
if: ${{ success() && (env.AWS_ACCESS_KEY_ID == 0 || env.AWS_SECRET_ACCESS_KEY == 0) }}
run: |
echo "SKIP_RUN=1" >> $GITHUB_ENV
- uses: actions/checkout@v3
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 "${{ secrets.REPO_PRIV_KEY }}" > ${{ github.workspace }}/boinc.priv.key
echo "${{ secrets.REPO_KEY }}" > ${{ github.workspace }}/boinc.pub.key
cp "${{ github.workspace }}/boinc.pub.key" "${{ github.workspace }}/${{ env.PUBKEY }}"
- name: Download client
if: ${{ success() && env.SKIP_RUN == 0 }}
uses: actions/download-artifact@v3
with:
name: linux-package_client_${{ matrix.os }}_${{ github.event.pull_request.head.sha }}

- name: Download manager
if: ${{ success() && env.SKIP_RUN == 0 }}
uses: actions/download-artifact@v3
with:
name: linux-package_manager_${{ matrix.os }}_${{ github.event.pull_request.head.sha }}

- 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/
# alpha or stable
RELEASE_TYPE=alpha
echo "RELEASE_TYPE=${RELEASE_TYPE}" >> $GITHUB_ENV
./repo_update.sh "$ALLOW_CREATE" ${{ env.BASEREPO }} ${{ github.workspace }} ${{ matrix.os }} ${RELEASE_TYPE} ${{ env.PUBKEY }}
- uses: actions/upload-artifact@v3
if: ${{ success() && env.SKIP_RUN == 0 }}
with:
name: repo-${{ env.RELEASE_TYPE }}-${{ matrix.os }}
path: "${{ github.workspace }}/repo-${{ env.RELEASE_TYPE }}-${{ 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-${{ env.RELEASE_TYPE }}-${{ matrix.os }}.tar.gz' https://boinc.berkeley.edu/upload.php --cookie "auth=${{ secrets.BOINC_AUTH }}" --form "submit=on"
2 changes: 1 addition & 1 deletion .github/workflows/rpm-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ env:
BASEREPO: https://boinc.berkeley.edu/dl/linux # no trailing slash
GH_REPO_API: parvit/boinc # no trailing or prefix slash
PUBKEY: boinc.gpg # keep extension
PUBKEY_HASH: 506D26EC67F5DE515A77A702631096B97E29B2B4
PUBKEY_HASH: D4460B4F0EEDE2C0662092F640254C9B29853EA6

concurrency:
group: rpm-package
Expand Down
Empty file modified .github/workflows/rpmrepo/package_depends.sh
100644 → 100755
Empty file.
Empty file modified .github/workflows/rpmrepo/package_filelist.sh
100644 → 100755
Empty file.
Empty file modified .github/workflows/rpmrepo/package_prepare.sh
100644 → 100755
Empty file.
Empty file modified .github/workflows/rpmrepo/repo_remove.sh
100644 → 100755
Empty file.
Empty file modified .github/workflows/rpmrepo/repo_update.sh
100644 → 100755
Empty file.

0 comments on commit f784c28

Please sign in to comment.