SilKit Packaging Workflow #41
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: "SilKit Packaging Workflow" | |
on: | |
workflow_dispatch: | |
inputs: | |
silkit_source_repo: | |
description: 'URL to the sil-kit repository in the form namespace/repo.git' | |
required: true | |
type: string | |
silkit_source_ref: | |
description: 'Ref of the SIL Kit sources repo.' | |
required: false | |
type: string | |
default: 'main' | |
silkit_pkg_ref: | |
description: 'sil-kit-pkg ref. Creates a release if not empty' | |
required: false | |
type: string | |
debian_fullname: | |
description: 'Name of the maintainer creating the current package' | |
required: true | |
type: string | |
debian_email: | |
description: 'Email of the maintainer creating the current package' | |
required: true | |
type: string | |
debian_arch: | |
description: 'Ubuntu CPU arch the package should be build for' | |
required: true | |
default: 'amd64' | |
type: string | |
env: | |
PKG_WORKDIR: _i | |
PKG_OUTDIR: _o | |
jobs: | |
package_ubuntu: | |
runs-on: ubuntu-latest | |
name: Job to build .deb for Ubuntu 20.04+ packages | |
container: | |
image: ghcr.io/vectorgrp/sil-kit-docker-build/sil-kit-ci-packaging-ubuntu-20.04:main | |
env: | |
ARTIFACT_NAME: silkit-ubuntu-20.04-deb | |
steps: | |
- name: Checkout (sil-kit-pkg) | |
uses: actions/checkout@v4 | |
with: | |
path: sil-kit-pkg | |
- name: Checkout (sil-kit) | |
uses: actions/checkout@v4 | |
with: | |
repository: ${{ inputs.silkit_source_repo }} | |
submodules: recursive | |
path: sil-kit | |
ref: ${{ inputs.silkit_source_ref }} | |
github-server-url: https://github.com | |
- name: Install cmake | |
run: | | |
sh sil-kit-pkg/.github/actions/fetch_cmake.sh | |
- name: Build | |
id: build | |
env: | |
DEBFULLNAME: ${{ inputs.debian_fullname }} | |
DEBEMAIL: ${{ inputs.debian_fullname }} | |
CI_RUN: "1" | |
BUILD_SETTINGS: | | |
{ | |
"SilKitInfo": { | |
"url": "sil-kit", | |
"ref": "", | |
"recursive": true, | |
"is_local": true | |
}, | |
"package_repo_path": "sil-kit-pkg", | |
"version": { | |
"major": 4, | |
"minor": 0, | |
"patch": 55, | |
"suffix": "~rc1-1" | |
}, | |
"pkgformat": "deb", | |
"work_dir": "${{ env.PKG_WORKDIR }}", | |
"keep_temp": true, | |
"output_dir": "${{ env.PKG_OUTDIR }}", | |
"platform": "Ubuntu-20.04" | |
} | |
run: | | |
mkdir -p $PKG_WORKDIR | |
mkdir -p $PKG_OUTDIR | |
touch $PKG_WORKDIR/build_cfg.json | |
printf %s $BUILD_SETTINGS > $PKG_WORKDIR/build_cfg.json | |
python3 sil-kit-pkg/scripts/silkit_linux_packaging.py \ | |
--build-cfg $PKG_WORKDIR/build_cfg.json \ | |
--verbose | |
- name: Test Package | |
id: test | |
env: | |
PKG_DIR: ./${{ env.PKG_OUTDIR }} | |
TEST_DIR: ./sil-kit-pkg/tests/ | |
run: | | |
python3 sil-kit-pkg/tests/test_deb.py \ | |
--package-directory "$PKG_DIR" \ | |
--test-directory "$TEST_DIR" \ | |
--distro ubuntu | |
- name: Artifact | |
id: artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: ${{ env.ARTIFACT_NAME }} | |
path: | | |
./${{ env.PKG_OUTDIR }}/*.dsc | |
./${{ env.PKG_OUTDIR }}/*.build* | |
./${{ env.PKG_OUTDIR }}/*.changes | |
./${{ env.PKG_OUTDIR }}/*.*deb | |
retention-days: 1 | |
package_almalinux: | |
runs-on: ubuntu-latest | |
name: Job to build Alma Linux 9 packages | |
container: | |
image: ghcr.io/vectorgrp/sil-kit-docker-build/sil-kit-ci-packaging-fedora-40:main | |
options: --privileged | |
env: | |
ARTIFACT_NAME: silkit-almalinux-9-rpm | |
steps: | |
- name: Checkout (sil-kit-pkg) | |
uses: actions/checkout@v4 | |
with: | |
path: sil-kit-pkg | |
- name: Checkout (sil-kit) | |
uses: actions/checkout@v4 | |
with: | |
repository: ${{ inputs.silkit_source_repo }} | |
submodules: recursive | |
path: libsilkit4-4.0.55 | |
ref: ${{ inputs.silkit_source_ref }} | |
github-server-url: https://github.com | |
- name: Build | |
id: build | |
env: | |
CI_RUN: "1" | |
BUILD_SETTINGS: | | |
{ | |
"SilKitInfo": { | |
"url": "libsilkit4-4.0.55", | |
"ref": "", | |
"recursive": true, | |
"is_local": true | |
}, | |
"package_repo_path": "sil-kit-pkg", | |
"version": { | |
"major": 4, | |
"minor": 0, | |
"patch": 55, | |
"suffix": "" | |
"suffix": "~rc1" | |
}, | |
"pkgformat": "rpm", | |
"work_dir": "${{ env.PKG_WORKDIR }}", | |
"keep_temp": true, | |
"output_dir": "${{ env.PKG_OUTDIR }}", | |
"platform": "epel9" | |
} | |
run: | | |
mkdir -p $PKG_WORKDIR | |
mkdir -p $PKG_OUTDIR | |
touch $PKG_WORKDIR/build_cfg.json | |
printf %s $BUILD_SETTINGS > $PKG_WORKDIR/build_cfg.json | |
usermod -a -G mock root | |
python3 sil-kit-pkg/scripts/silkit_linux_packaging.py \ | |
--build-cfg $PKG_WORKDIR/build_cfg.json \ | |
--verbose | |
- name: Test Package | |
id: test | |
env: | |
PKG_DIR: ./${{ env.PKG_OUTDIR }} | |
TEST_DIR: ./sil-kit-pkg/tests | |
run: | | |
dnf install -y cmake clang ninja-build | |
python3 sil-kit-pkg/tests/test_deb.py \ | |
--package-directory "$PKG_DIR" \ | |
--test-directory "$TEST_DIR" \ | |
--distro fedora | |
- name: Artifact | |
id: artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: ${{ env.ARTIFACT_NAME }} | |
path: | | |
./${{ env.PKG_OUTDIR }}/*.rpm | |
retention-days: 1 | |
make-release: | |
runs-on: ubuntu-latest | |
needs: [package_ubuntu, package_almalinux] | |
permissions: | |
contents: write | |
steps: | |
- name: download_artifact | |
uses: actions/download-artifact@v4 | |
- name: Prepare artifact | |
if: inputs.silkit_pkg_ref != '' | |
run: | | |
sha256sum silkit-almalinux-9-rpm/* >> ./SHA256 | |
sha256sum silkit-ubuntu-20.04-deb/* >> ./SHA256 | |
- name: Create git tag | |
if: inputs.silkit_pkg_ref != '' | |
uses: actions/github-script@v7 | |
with: | |
script: | | |
try { | |
await github.rest.git.createRef({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
ref: 'refs/tags/${{ inputs.silkit_pkg_ref }}', | |
sha: context.sha, | |
}) | |
} catch(error) { | |
core.warning("Could not create the specified ref, continuing without it!") | |
} | |
- name: Release artifact | |
if: inputs.silkit_pkg_ref != '' | |
uses: softprops/action-gh-release@v2 | |
with: | |
prerelease: ${{ contains(inputs.silkit_pkg_ref, '-rc') }} | |
draft: false | |
tag_name: ${{ inputs.silkit_pkg_ref }} | |
name: ${{ inputs.silkit_pkg_ref }} | |
files: | | |
${{ github.workspace }}/silkit-ubuntu-20.04-deb/* | |
${{ github.workspace }}/silkit-almalinux-9-rpm/* | |
${{ github.workspace }}/SHA256 |