Skip to content

Commit

Permalink
enh(ci): package lua dependencies using nfpm (#175)
Browse files Browse the repository at this point in the history
Refs: MON-33552
  • Loading branch information
hamzabessa authored Jan 30, 2024
1 parent dce5ece commit b5f46c2
Show file tree
Hide file tree
Showing 29 changed files with 560 additions and 588 deletions.
2 changes: 1 addition & 1 deletion .github/actions/deb-delivery/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ runs:
using: "composite"
steps:
- name: Use cache DEB files
uses: actions/cache/restore@704facf57e6136b1bc63b828d79edcd491f0ee84 # v3.3.2
uses: actions/cache/restore@13aacd865c20de90d75de3b17ebe84f7a17d57d2 # v4.0.0
with:
path: ./*.deb
key: ${{ inputs.cache_key }}
Expand Down
26 changes: 15 additions & 11 deletions .github/actions/package-nfpm/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,8 @@ inputs:
distrib:
description: The package distrib
required: true
major_version:
description: The major version
required: false
minor_version:
description: The minor version
version:
description: The version
required: false
release:
description: The package release number
Expand Down Expand Up @@ -53,6 +50,7 @@ runs:
RPM_GPG_SIGNING_KEY_ID: ${{ inputs.rpm_gpg_signing_key_id }}
RPM_GPG_SIGNING_PASSPHRASE: ${{ inputs.rpm_gpg_signing_passphrase }}
run: |
export VERSION="${{ inputs.version }}"
export ARCH="${{ inputs.arch }}"
if [ "${{ inputs.package_extension }}" = "rpm" ]; then
Expand All @@ -72,22 +70,28 @@ runs:
export RPM_SIGNING_KEY_ID="$RPM_GPG_SIGNING_KEY_ID"
export NFPM_RPM_PASSPHRASE="$RPM_GPG_SIGNING_PASSPHRASE"
sed -i "s/@luaver@/$luaver/g" ./${{ inputs.nfpm_file_pattern }}
sed -i "s/@COMMIT_HASH@/${{ inputs.commit_hash }}/g" ./${{ inputs.nfpm_file_pattern }}
nfpm package --config ./${{ inputs.nfpm_file_pattern }} --packager ${{ inputs.package_extension }}
for FILE in ${{ inputs.nfpm_file_pattern }}; do
DIRNAME=$(dirname $FILE)
BASENAME=$(basename $FILE)
cd $DIRNAME
sed -i "s/@luaver@/$luaver/g" $BASENAME
sed -i "s/@COMMIT_HASH@/${{ inputs.commit_hash }}/g" $BASENAME
nfpm package --config $BASENAME --packager ${{ inputs.package_extension }}
cd -
mv $DIRNAME/*.${{ inputs.package_extension }} ./
done
shell: bash

- name: Cache packages
uses: actions/cache/save@704facf57e6136b1bc63b828d79edcd491f0ee84 # v3.3.2
uses: actions/cache/save@13aacd865c20de90d75de3b17ebe84f7a17d57d2 # v4.0.0
with:
path: ./*.${{ inputs.package_extension }}
key: ${{ inputs.cache_key }}

# Update if condition to true to get packages as artifacts
- if: ${{ false }}
name: Upload package artifacts
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@26f96dfa697d77e81fd5907df203aa23a56210a8 # v4.3.0
with:
name: packages-${{ inputs.distrib }}
path: ./*.${{ inputs.package_extension}}
Expand Down
2 changes: 1 addition & 1 deletion .github/actions/rpm-delivery/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ runs:
using: "composite"
steps:
- name: Use cache RPM files
uses: actions/cache/restore@704facf57e6136b1bc63b828d79edcd491f0ee84 # v3.3.2
uses: actions/cache/restore@13aacd865c20de90d75de3b17ebe84f7a17d57d2 # v4.0.0
with:
path: ./*.rpm
key: ${{ inputs.cache_key }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,18 @@ ARG REGISTRY_URL

FROM ${REGISTRY_URL}/almalinux:8

RUN <<EOF
RUN bash -e <<EOF

dnf install -y dnf-plugins-core epel-release
dnf config-manager --set-enabled powertools

echo '[goreleaser]
name=GoReleaser
baseurl=https://repo.goreleaser.com/yum/
enabled=1
gpgcheck=0' | tee /etc/yum.repos.d/goreleaser.repo

dnf install -y rpm-build rpm-sign zstd nfpm lua
dnf install -y git zstd nfpm-2.35.2 lua lua-devel
dnf clean all

EOF

WORKDIR /src
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,18 @@ ARG REGISTRY_URL

FROM ${REGISTRY_URL}/almalinux:9

RUN <<EOF
RUN bash -e <<EOF

dnf install -y dnf-plugins-core epel-release
dnf config-manager --set-enabled crb

echo '[goreleaser]
name=GoReleaser
baseurl=https://repo.goreleaser.com/yum/
enabled=1
gpgcheck=0' | tee /etc/yum.repos.d/goreleaser.repo

dnf install -y rpm-build rpm-sign zstd nfpm lua
dnf install -y git zstd nfpm-2.35.2 lua lua-devel
dnf clean all

EOF

WORKDIR /src
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,13 @@ FROM ${REGISTRY_URL}/debian:bullseye
RUN bash -e <<EOF

apt-get update
apt-get install -y debmake pbuilder aptitude zstd ca-certificates lua5.4
apt-get install -y git zstd ca-certificates lua5.3 liblua5.3-dev

echo 'deb [trusted=yes] https://repo.goreleaser.com/apt/ /' | tee /etc/apt/sources.list.d/goreleaser.list

apt-get update
apt-get install -y nfpm
apt-get install -y nfpm=2.35.2

apt-get clean
apt-get clean all

EOF

WORKDIR /src
4 changes: 2 additions & 2 deletions .github/workflows/docker-packaging.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ jobs:

- uses: docker/build-push-action@4a13e500e55cf31b7a5d59a38ab2040ab0f42f56 # v5.1.0
with:
file: .github/docker/Dockerfile.packaging-${{ matrix.distrib }}
file: .github/docker/Dockerfile.packaging-stream-connectors-nfpm-${{ matrix.distrib }}
context: .
build-args: "REGISTRY_URL=${{ vars.DOCKER_PROXY_REGISTRY_URL }}"
pull: true
push: true
tags: ${{ vars.DOCKER_INTERNAL_REGISTRY_URL }}/packaging-stream-connectors-${{ matrix.distrib }}:latest
tags: ${{ vars.DOCKER_INTERNAL_REGISTRY_URL }}/packaging-stream-connectors-nfpm-${{ matrix.distrib }}:latest
144 changes: 144 additions & 0 deletions .github/workflows/lua-cffi.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,144 @@
name: lua-cffi

concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true

on:
workflow_dispatch:
pull_request:
paths:
- dependencies/lua-cffi/**
push:
branches:
- develop
- master
paths:
- dependencies/lua-cffi/**

jobs:
get-environment:
uses: ./.github/workflows/get-environment.yml

package:
needs: [get-environment]

strategy:
fail-fast: false
matrix:
distrib: [el8, el9, bullseye]
include:
- package_extension: rpm
image: packaging-stream-connectors-nfpm-alma8
distrib: el8
- package_extension: rpm
image: packaging-stream-connectors-nfpm-alma9
distrib: el9
- package_extension: deb
image: packaging-stream-connectors-nfpm-bullseye
distrib: bullseye

runs-on: ubuntu-22.04

container:
image: ${{ vars.DOCKER_INTERNAL_REGISTRY_URL }}/${{ matrix.image }}:latest
credentials:
username: ${{ secrets.DOCKER_REGISTRY_ID }}
password: ${{ secrets.DOCKER_REGISTRY_PASSWD }}

name: package ${{ matrix.distrib }}

steps:
- name: Checkout sources
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1

- name: Install dependencies
run: |
if [ "${{ matrix.package_extension }}" = "rpm" ]; then
dnf install -y make gcc gcc-c++ meson cmake libffi libffi-devel
else
apt-get update
apt-get install -y make gcc g++ meson cmake libffi7 libffi-dev
fi
shell: bash

- name: Checkout cffi-lua sources
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
with:
repository: "q66/cffi-lua"
path: "cffi-lua-src"
ref: "v0.2.3"

- name: Prepare packaging of lua-cffi
run: |
cd cffi-lua-src
mkdir build
cd build
if [ "${{ matrix.distrib }}" = "el9" ]; then
meson .. -Dlua_version=5.4
else
meson .. -Dlua_version=5.3
fi
ninja all
cd ../..
mkdir -p dependencies/lua-cffi/lua-cffi
mv cffi-lua-src/build/cffi.so dependencies/lua-cffi/lua-cffi/
shell: bash

- name: Package
uses: ./.github/actions/package-nfpm
with:
nfpm_file_pattern: "dependencies/lua-cffi/packaging/*.yaml"
distrib: ${{ matrix.distrib }}
package_extension: ${{ matrix.package_extension }}
arch: amd64
version: "0.2.3"
commit_hash: ${{ github.sha }}
cache_key: ${{ github.sha }}-${{ github.run_id }}-${{ matrix.package_extension }}-${{ matrix.distrib }}
rpm_gpg_key: ${{ secrets.RPM_GPG_SIGNING_KEY }}
rpm_gpg_signing_key_id: ${{ secrets.RPM_GPG_SIGNING_KEY_ID }}
rpm_gpg_signing_passphrase: ${{ secrets.RPM_GPG_SIGNING_PASSPHRASE }}

deliver-rpm:
if: ${{ contains(fromJson('["unstable", "testing", "stable"]'), needs.get-environment.outputs.stability) }}
needs: [get-environment, package]
runs-on: ubuntu-22.04
strategy:
matrix:
distrib: [el8, el9]
name: deliver ${{ matrix.distrib }}

steps:
- name: Checkout sources
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1

- name: Publish RPM packages
uses: ./.github/actions/rpm-delivery
with:
module_name: lua-cffi
distrib: ${{ matrix.distrib }}
artifactory_token: ${{ secrets.ARTIFACTORY_ACCESS_TOKEN }}
cache_key: ${{ github.sha }}-${{ github.run_id }}-rpm-lua-cffi-${{ matrix.distrib }}
stability: ${{ needs.get-environment.outputs.stability }}

deliver-deb:
if: ${{ contains(fromJson('["unstable", "testing", "stable"]'), needs.get-environment.outputs.stability) }}
needs: [get-environment, package]
runs-on: ubuntu-22.04
strategy:
matrix:
distrib: [bullseye]
name: deliver ${{ matrix.distrib }}

steps:
- name: Checkout sources
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1

- name: Publish DEB packages
uses: ./.github/actions/deb-delivery
with:
module_name: lua-cffi
distrib: ${{ matrix.distrib }}
artifactory_token: ${{ secrets.ARTIFACTORY_ACCESS_TOKEN }}
cache_key: ${{ github.sha }}-${{ github.run_id }}-deb-lua-cffi-${{ matrix.distrib }}
stability: ${{ needs.get-environment.outputs.stability }}
Loading

0 comments on commit b5f46c2

Please sign in to comment.