Build packages #212
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build packages | |
on: | |
workflow_dispatch: | |
inputs: | |
branch-buildtools: | |
description: 'Branch for buildtools repository' | |
required: true | |
default: 'develop' | |
branch-client: | |
description: 'Branch for client repository' | |
required: true | |
default: 'develop' | |
branch-server: | |
description: 'Branch for server repository' | |
required: true | |
default: 'develop' | |
concurrency: | |
group: ${{ github.ref }} | |
cancel-in-progress: true | |
env: | |
PRODUCT: ${{ github.event.repository.name }} | |
PRODUCT_LOW: echo ${{ github.event.repository.name }} | tr '[:upper:]' '[:lower:]' | |
PRODUCT_VERSION: echo ${{ github.ref }} | grep -oP '\d+\.\d+\.\d+' || echo '1.1.4' | |
BUILD_NUMBER: ${{ github.run_number }} | |
PACKAGE_DIRECTORY: "/home/runner/work/${{ github.event.repository.name }}/${{ github.event.repository.name }}" | |
BRANCH_BUILDTOOLS: ${{ github.event.inputs.branch-buildtools }} | |
BRANCH_CLIENT: ${{ github.event.inputs.branch-client }} | |
BRANCH_SERVER: ${{ github.event.inputs.branch-server }} | |
jobs: | |
build: | |
name: Build Packages | |
runs-on: ubuntu-20.04 | |
permissions: | |
contents: write | |
strategy: | |
matrix: | |
packageType: [deb, rpm] | |
steps: | |
# To avoid mistake "System.IO.IOException: No space left on device" | |
- name: Free Disk Space | |
run: | | |
sudo rm -rf /usr/local/lib/android /opt/ghc | |
sudo docker image prune --all --force | |
- name: Import GPG | |
uses: crazy-max/ghaction-import-gpg@v5 | |
id: gpg_step | |
with: | |
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }} | |
passphrase: ${{ secrets.GPG_PRIVATE_KEY_PASS }} | |
- name: Checkout ${{ env.PRODUCT }}-buildtools | |
uses: actions/checkout@v4 | |
with: | |
repository: ONLYOFFICE/${{ env.PRODUCT }}-buildtools | |
ref: ${{ env.BRANCH_BUILDTOOLS }} | |
submodules: 'recursive' | |
- name: Prepare build | |
run: | | |
wget -O - https://dl.yarnpkg.com/debian/pubkey.gpg | \ | |
sudo gpg --no-default-keyring --keyring gnupg-ring:/usr/share/keyrings/yarnkey.gpg --import | |
sudo chmod 644 /usr/share/keyrings/yarnkey.gpg | |
echo "deb [signed-by=/usr/share/keyrings/yarnkey.gpg] https://dl.yarnpkg.com/debian/ stable main" | \ | |
sudo tee /etc/apt/sources.list.d/yarn.list | |
wget https://packages.microsoft.com/config/$(lsb_release -is | \ | |
tr [:upper:] [:lower:])/$(lsb_release -rs)/packages-microsoft-prod.deb -O packages-microsoft-prod.deb | |
sudo dpkg -i packages-microsoft-prod.deb | |
echo "deb [signed-by=/usr/share/keyrings/nodesource.gpg] https://deb.nodesource.com/node_18.x nodistro main" | \ | |
sudo tee /etc/apt/sources.list.d/nodesource.list | |
wget -O - https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | \ | |
sudo gpg --no-default-keyring --keyring gnupg-ring:/usr/share/keyrings/nodesource.gpg --import | |
sudo chmod 644 /usr/share/keyrings/nodesource.gpg | |
sudo apt-get -y update | |
sudo apt install -y dotnet-sdk-7.0 yarn nodejs rename | |
sudo npm install -g json | |
if [[ "${{ matrix.packageType }}" == "rpm" ]]; then | |
sudo apt install -y python3-rpm python3-pip | |
sudo pip install rpmlint | |
else | |
sudo apt install -y dpkg-sig lintian dh-make | |
fi | |
- name: Build DEB Packages | |
if: matrix.packageType == 'deb' | |
run: | | |
wget https://github.com/ONLYOFFICE/$PRODUCT-buildtools/archive/$BRANCH_BUILDTOOLS.tar.gz -O buildtools.tar.gz && tar -xvf buildtools.tar.gz | |
wget https://github.com/ONLYOFFICE/$PRODUCT-client/archive/$BRANCH_CLIENT.tar.gz -O client.tar.gz && tar -xvf client.tar.gz | |
wget https://github.com/ONLYOFFICE/$PRODUCT-server/archive/$BRANCH_SERVER.tar.gz -O server.tar.gz && tar -xvf server.tar.gz | |
mv $PRODUCT-buildtools-$(echo "$BRANCH_BUILDTOOLS" | tr '/' '-') buildtools | |
mv $PRODUCT-client-$(echo "$BRANCH_CLIENT" | tr '/' '-') client | |
mv $PRODUCT-server-$(echo "$BRANCH_SERVER" | tr '/' '-') server | |
wget https://github.com/ONLYOFFICE/dictionaries/archive/master.tar.gz -O ./client/common/Tests/Frontend.Translations.Tests/dictionaries.tar.gz | |
wget https://github.com/ONLYOFFICE/document-templates/archive/main/community-server.tar.gz -O ./server/products/ASC.Files/Server/DocStore.tar.gz | |
tar -xvf ./server/products/ASC.Files/Server/DocStore.tar.gz && tar -xvf ./client/common/Tests/Frontend.Translations.Tests/dictionaries.tar.gz | |
rm -rf packages-microsoft-prod.deb *.tar.gz | |
cd buildtools/install/deb/ | |
rename -f -v "s/product([^\/]*)$/$(${{ env.PRODUCT_LOW }})\$1/g" debian/* ../common/* ../common/logrotate/* | |
find ../ -type f -exec sed -i "s/{{product}}/$(${{ env.PRODUCT_LOW }})/g" {} ';' | |
sed -i "s/{{package_header_tag_version}}/$(${{ env.PRODUCT_VERSION }}).${{ env.BUILD_NUMBER }}/g" debian/changelog debian/control | |
dpkg-buildpackage -uc -k${{ steps.gpg_step.outputs.fingerprint }} | |
- name: Build RPM Packages | |
if: matrix.packageType == 'rpm' | |
run: | | |
cd install/rpm/SPECS | |
mv ./SOURCES/product.rpmlintrc ./SOURCES/$(${{ env.PRODUCT_LOW }}).rpmlintrc | |
wget https://github.com/ONLYOFFICE/${{ env.PRODUCT }}-buildtools/archive/${{ env.BRANCH_BUILDTOOLS }}.tar.gz \ | |
-O ./SOURCES/${{ env.PRODUCT }}-buildtools-$(echo ${{ env.BRANCH_BUILDTOOLS }} | tr '/' '-').tar.gz | |
wget https://github.com/ONLYOFFICE/${{ env.PRODUCT }}-client/archive/${{ env.BRANCH_CLIENT }}.tar.gz \ | |
-O ./SOURCES/${{ env.PRODUCT }}-client-$(echo ${{ env.BRANCH_CLIENT }} | tr '/' '-').tar.gz | |
wget https://github.com/ONLYOFFICE/${{ env.PRODUCT }}-server/archive/${{ env.BRANCH_SERVER }}.tar.gz \ | |
-O ./SOURCES/${{ env.PRODUCT }}-server-$(echo ${{ env.BRANCH_SERVER }} | tr '/' '-').tar.gz | |
wget https://github.com/ONLYOFFICE/document-templates/archive/main/community-server.tar.gz \ | |
-O ./SOURCES/document-templates-main-community-server.tar.gz | |
wget https://github.com/ONLYOFFICE/dictionaries/archive/master.tar.gz \ | |
-O ./SOURCES/dictionaries-master.tar.gz | |
sed -i -e '/BuildRequires/d' product.spec | |
rpmbuild -D "packager Ascensio System SIA <[email protected]>" \ | |
-D "BRANCH_BUILDTOOLS $(echo ${{ env.BRANCH_BUILDTOOLS }} | tr '/' '-')" \ | |
-D "BRANCH_CLIENT $(echo ${{ env.BRANCH_CLIENT }} | tr '/' '-')" \ | |
-D "BRANCH_SERVER $(echo ${{ env.BRANCH_SERVER }} | tr '/' '-')" \ | |
-D "_topdir $(pwd)" \ | |
-D "version $(${{ env.PRODUCT_VERSION }})" \ | |
-D "release ${{ env.BUILD_NUMBER }}" -ba product.spec | |
- name: Sign RPM Packages | |
if: matrix.packageType == 'rpm' | |
run: | | |
cat << EOF >> $HOME/.rpmmacros | |
%_signature gpg | |
%_gpg_name ${{ secrets.GPG_KEY_NAME }} | |
%_gpg_path $HOME/.gnupg | |
%__gpg /usr/bin/gpg | |
EOF | |
gpg --export --armor --output onlyoffice-gpgkey.pub | |
rpm --import onlyoffice-gpgkey.pub | |
rpm --addsign ${{ env.PACKAGE_DIRECTORY }}/install/rpm/SPECS/RPMS/noarch/*.rpm | |
- name: Upload DEB Packages | |
if: matrix.packageType == 'deb' | |
run: | | |
for deb_package in ${{ env.PACKAGE_DIRECTORY }}/buildtools/install/*.deb; do | |
echo $deb_package | |
curl --verbose \ | |
--user ${{ secrets.REPO_LOGIN }}:${{ secrets.REPO_PASS }} \ | |
-H "Content-Type: multipart/form-data" \ | |
--data-binary "@$deb_package" ${{ secrets.REPO_URL_4TESTING_DEB }} | |
done | |
- name: Upload RPM Packages | |
if: matrix.packageType == 'rpm' | |
run: | | |
for rpm_package in ${{ env.PACKAGE_DIRECTORY }}/install/rpm/SPECS/RPMS/noarch/*.rpm; do | |
curl --verbose \ | |
--user ${{ secrets.REPO_LOGIN }}:${{ secrets.REPO_PASS }} \ | |
--upload-file "$rpm_package" ${{ secrets.REPO_URL_4TESTING_RPM }} | |
done | |
- name: Checking the DEB package for errors | |
if: matrix.packageType == 'deb' | |
run: | | |
lintian --profile debian /home/runner/work/${{ github.event.repository.name }}/${{ github.event.repository.name }}/buildtools/install/*.deb | tee -a LINTIAN | |
if grep -qE '^(W:|E:)' LINTIAN; then | |
echo "::warning Noticedeb=lintian::$(cat LINTIAN | awk '/^W:/ { ws += 1 } /^E:/ { es += 1 } END { print "Warnings:", ws, "Errors:", es }')" | |
fi | |
- name: Checking the RPM package for errors | |
if: matrix.packageType == 'rpm' | |
run: | | |
for rpm_package in ${{ env.PACKAGE_DIRECTORY }}/install/rpm/SPECS/RPMS/noarch/*.rpm; do | |
rpmlint --ignore-unused-rpmlintrc --rpmlintrc ${{ env.PACKAGE_DIRECTORY }}/rpm/SPECS/SOURCES/$(${{ env.PRODUCT_LOW }}).rpmlintrc $rpm_package | tee -a RPM_LINT | |
done | |
if grep -qE '(W:|E:)' RPM_LINT; then | |
echo "::warning Noticerpm=rpmlint::$(cat RPM_LINT | awk '/W:/ { ws += 1 } /E:/ { es += 1 } END { print "Warnings:", ws, "Errors:", es }')" | |
fi |