matrix multi build and release - qbt-workflow-files #84
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
# @credits https://github.com/c0re100/qBittorrent-Enhanced-Edition | |
name: matrix multi build and release - qbt-workflow-files | |
on: | |
workflow_dispatch: | |
inputs: | |
distinct_id: | |
skip_rerun: | |
description: "Skip rerun?" | |
required: true | |
type: boolean | |
retries: | |
description: "Number of rerun retries" | |
required: true | |
default: "5" | |
type: choice | |
options: ["1", "2", "3", "4", "5", "6", "7", "8", "9"] | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.ref }} | |
cancel-in-progress: true | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
strategy: | |
fail-fast: false | |
matrix: | |
os_id: [alpine] | |
os_version_id: [edge] | |
# qbt_cross_name: | |
# [ | |
# armel, | |
# armhf, | |
# armv7, | |
# aarch64, | |
# x86_64, | |
# x86, | |
# s390x, | |
# powerpc, | |
# ppc64el, | |
# mips, | |
# mipsel, | |
# mips64, | |
# mips64el, | |
# riscv64, | |
# ] | |
qbt_cross_name: [armhf, armv7, aarch64, x86_64, x86] | |
qbt_libtorrent_version: ["1.2", "2.0"] | |
qbt_build_tool: ["", cmake] | |
include: | |
- qbt_build_tool: "" | |
qbt_qt_version_name: "qt5-" | |
qbt_qt_version: "5" | |
- qbt_build_tool: "cmake" | |
qbt_qt_version_name: "" | |
qbt_qt_version: "6" | |
name: "${{ matrix.qbt_cross_name }}-${{ matrix.qbt_qt_version_name }}libtorrent-v${{ matrix.qbt_libtorrent_version }}" | |
env: | |
qbt_build_dir: "qbt-build" | |
steps: | |
- name: Checkout ${{ github.event.inputs.distinct_id }} | |
uses: actions/checkout@v4 | |
- name: Host - phased updates ${{ github.event.inputs.distinct_id }} | |
run: printf '%s\n' 'APT::Get::Always-Include-Phased-Updates "false";' | sudo tee /etc/apt/apt.conf.d/99-phased-updates | |
- name: Host - set up lunar repo -t lunar ${{ github.event.inputs.distinct_id }} | |
run: | | |
printf '%b\n' 'Package: *\nPin: release n=lunar\nPin-Priority: 50' | sudo tee /etc/apt/preferences | |
printf '%b\n' 'deb http://archive.ubuntu.com/ubuntu/ lunar main universe restricted' | sudo tee /etc/apt/sources.list.d/lunar.list | |
- name: Host - update ${{ github.event.inputs.distinct_id }} | |
run: sudo apt-get update | |
- name: Host - upgrade ${{ github.event.inputs.distinct_id }} | |
run: sudo apt-get -y upgrade | |
- name: Host - set up qemu-user-static binfmt-support from lunar ${{ github.event.inputs.distinct_id }} | |
run: sudo apt install -t lunar libpipeline1 qemu-user-static binfmt-support | |
- name: Host - Create Docker template env file ${{ github.event.inputs.distinct_id }} | |
run: | | |
printf '%s\n' "qbt_libtorrent_version=${{ matrix.qbt_libtorrent_version }}" > env.custom | |
printf '%s\n' "qbt_qt_version=${{ matrix.qbt_qt_version }}" >> env.custom | |
printf '%s\n' "qbt_build_tool=${{ matrix.qbt_build_tool }}" >> env.custom | |
printf '%s\n' "qbt_cross_name=${{ matrix.qbt_cross_name }}" >> env.custom | |
printf '%s\n' "qbt_patches_url=${{ github.repository }}" >> env.custom | |
printf '%s\n' "qbt_skip_icu=yes" >> env.custom | |
# printf '%s\n' "qbt_boost_tag=" >> env.custom | |
# printf '%s\n' "qbt_libtorrent_tag=" >> env.custom | |
# printf '%s\n' "qbt_qt_tag=" >> env.custom | |
# printf '%s\n' "qbt_qbittorrent_tag=" >> env.custom | |
printf '%s\n' "qbt_libtorrent_master_jamfile=no" >> env.custom | |
printf '%s\n' "qbt_workflow_files=yes" >> env.custom | |
printf '%s\n' "qbt_workflow_artifacts=no" >> env.custom | |
# printf '%s\n' "qbt_cache_dir= >> env.custom | |
printf '%s\n' "qbt_optimise_strip=yes" >> env.custom | |
printf '%s\n' "qbt_build_debug=no" >> env.custom | |
printf '%s\n' "qbt_revision_url=${{ github.repository }}" >> env.custom | |
- name: Host - Create docker multiarch container ${{ github.event.inputs.distinct_id }} | |
run: docker run --name multiarch -it -d --env-file env.custom -w /root -v ${{ github.workspace }}:/root ${{ matrix.os_id }}:${{ matrix.os_version_id }} | |
- name: Docker - apk update ${{ github.event.inputs.distinct_id }} | |
run: docker exec -w /root multiarch apk update | |
- name: Docker - apk install bash ${{ github.event.inputs.distinct_id }} | |
run: docker exec -w /root multiarch apk add bash | |
- name: Docker - Bootstrap ${{ github.event.inputs.distinct_id }} | |
run: docker exec -w /root multiarch bash qbittorrent-nox-static.sh -bs-a | |
- name: Docker - zlib-ng ${{ github.event.inputs.distinct_id }} | |
run: docker exec -w /root multiarch bash qbittorrent-nox-static.sh zlib | |
- name: Docker - iconv ${{ github.event.inputs.distinct_id }} | |
run: docker exec -w /root multiarch bash qbittorrent-nox-static.sh iconv | |
- name: Docker - icu ${{ github.event.inputs.distinct_id }} | |
run: docker exec -w /root multiarch bash qbittorrent-nox-static.sh icu | |
- name: Docker - openssl ${{ github.event.inputs.distinct_id }} | |
run: docker exec -w /root multiarch bash qbittorrent-nox-static.sh openssl | |
- name: Docker - boost ${{ github.event.inputs.distinct_id }} | |
run: docker exec -w /root multiarch bash qbittorrent-nox-static.sh boost | |
- name: Docker - libtorrent ${{ github.event.inputs.distinct_id }} | |
run: docker exec -w /root multiarch bash qbittorrent-nox-static.sh libtorrent | |
- name: Docker - double_conversion ${{ github.event.inputs.distinct_id }} | |
if: matrix.qbt_build_tool == 'cmake' | |
run: docker exec -w /root multiarch bash qbittorrent-nox-static.sh double_conversion | |
- name: Docker - qtbase ${{ github.event.inputs.distinct_id }} | |
run: docker exec -w /root multiarch bash qbittorrent-nox-static.sh qtbase | |
- name: Docker - qttools ${{ github.event.inputs.distinct_id }} | |
run: docker exec -w /root multiarch bash qbittorrent-nox-static.sh qttools | |
- name: Docker - qbittorrent ${{ github.event.inputs.distinct_id }} | |
run: docker exec -w /root multiarch bash qbittorrent-nox-static.sh qbittorrent | |
- name: Docker - Set release asset name ${{ github.event.inputs.distinct_id }} | |
run: docker exec -w /root/${{ env.qbt_build_dir }}/completed multiarch mv -f qbittorrent-nox ${{ matrix.qbt_cross_name }}-${{ matrix.qbt_qt_version_name }}qbittorrent-nox | |
- name: Docker - Release Info ${{ github.event.inputs.distinct_id }} | |
run: docker exec -w /root/${{ env.qbt_build_dir }}/release_info multiarch bash -c 'mv *.md *.json '/root/${{ env.qbt_build_dir }}/completed'' | |
- name: Host - Upload libtorrent-v${{ matrix.qbt_libtorrent_version }}-qbittorrent-nox and release info artifact ${{ github.event.inputs.distinct_id }} | |
uses: actions/upload-artifact@v3 | |
with: | |
name: libtorrent-v${{ matrix.qbt_libtorrent_version }}-${{ matrix.qbt_cross_name }}-${{ matrix.qbt_qt_version_name }}qbittorrent-nox | |
path: | | |
${{ env.qbt_build_dir }}/completed/* | |
!${{ env.qbt_build_dir }}/completed/*.png | |
- name: Host - Upload cmake graphs artifact ${{ github.event.inputs.distinct_id }} | |
if: matrix.qbt_build_tool == 'cmake' | |
uses: actions/upload-artifact@v3 | |
with: | |
name: "${{ matrix.qbt_cross_name }}-libtorrent-v${{ matrix.qbt_libtorrent_version }}-graphs" | |
path: "${{ env.qbt_build_dir }}/completed/*.png" | |
release: | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write | |
needs: build | |
if: always() && contains(needs.*.result, 'success') && !contains(needs.*.result, 'failure') && !contains(needs.*.result, 'cancelled') | |
strategy: | |
fail-fast: false | |
matrix: | |
qbt_libtorrent_version: ["1.2", "2.0"] | |
include: | |
- qbt_libtorrent_version: "2.0" | |
preview_release: false | |
- qbt_libtorrent_version: "1.2" | |
preview_release: true | |
name: "Publish release libtorrent-v${{ matrix.qbt_libtorrent_version }}" | |
env: | |
qbt_build_dir: "qbt-build" | |
steps: | |
- name: Checkout ${{ github.event.inputs.distinct_id }} | |
uses: actions/checkout@v4 | |
- name: Pandoc - Bootstrap | |
run: | | |
pandoc_git_tag="$(git ls-remote -q -t --refs https://github.com/jgm/pandoc.git | awk '/tags\/[0-9]/{sub("refs/tags/", ""); print $2 }' | awk '!/^$/' | sort -rV | head -n 1)" | |
curl -sLo- "https://github.com/jgm/pandoc/releases/latest/download/pandoc-${pandoc_git_tag}-linux-amd64.tar.gz" | tar xzf - --strip-components 2 -C "$(pwd)" --exclude="share" | |
- name: Host - Download qbittorrent-nox artifacts ${{ github.event.inputs.distinct_id }} | |
uses: actions/download-artifact@v3 | |
- name: Host - 1.2 artifacts organise for release ${{ github.event.inputs.distinct_id }} | |
run: | | |
mkdir -p "1.2" | |
for files in libtorrent-v1.2-*-qbittorrent-nox; do | |
cp -rf ${files}/* "1.2/" | |
done | |
- name: Host - 2.0 artifacts organise for release ${{ github.event.inputs.distinct_id }} | |
run: | | |
mkdir -p "2.0" | |
for files in libtorrent-v2.0-*-qbittorrent-nox; do | |
cp -rf ${files}/* "2.0/" | |
done | |
- name: Host - merge release-info ${{ github.event.inputs.distinct_id }} | |
run: | | |
paste -d '\n' 1.2/qt5-*-release.md | uniq > 1.2/tmp-release.md | |
paste -d '\n' 2.0/qt6-*-release.md | uniq > 2.0/tmp-release.md | |
paste -d '\n' 1.2/tmp-release.md 2.0/tmp-release.md | uniq > tmp-release.md | |
./pandoc --wrap=preserve -f gfm tmp-release.md -t gfm -o release.md | |
paste -d '\n' 1.2/qt5-dependency-version.json 2.0/qt6-dependency-version.json | uniq > dependency-version.json | |
- name: Host - Bootstrap release tag ${{ github.event.inputs.distinct_id }} | |
run: printf '%s\n' "release_tag=$(cat ${{ matrix.qbt_libtorrent_version }}/tag.md)" >> $GITHUB_ENV | |
- name: Host - Bootstrap release title ${{ github.event.inputs.distinct_id }} | |
run: printf '%s\n' "release_title=$(cat ${{ matrix.qbt_libtorrent_version }}/title.md)" >> $GITHUB_ENV | |
- name: Host- Create release - tag - assets ${{ github.event.inputs.distinct_id }} | |
uses: ncipollo/release-action@v1 | |
with: | |
prerelease: "${{ matrix.preview_release }}" | |
artifacts: "${{ matrix.qbt_libtorrent_version }}/*-qbittorrent-nox,dependency-version.json" | |
replacesArtifacts: true | |
tag: "${{ env.release_tag }}" | |
name: "${{ env.release_title }}" | |
bodyFile: "release.md" | |
allowUpdates: true | |
token: "${{ secrets.GITHUB_TOKEN }}" | |
rerun-on-failure: | |
if: failure() && inputs.skip_rerun == '0' | |
name: rerun-on-failure | |
needs: release | |
permissions: | |
actions: write | |
runs-on: ubuntu-latest | |
env: | |
GH_TOKEN: "${{ secrets.GITHUB_TOKEN }}" | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Trigger rerun workflow on job failures | |
run: | | |
inputs_retries="${{ inputs.retries }}" | |
gh workflow run rerun.yml -f run_id=${{ github.run_id }} -f attempts=${{ github.run_attempt }} -f retries=${inputs_retries:-5} |