Skip to content

Update workflow to support additional develop package #105

Update workflow to support additional develop package

Update workflow to support additional develop package #105

Workflow file for this run

name: Build and Upload
on:
#schedule:
# - cron: "0 0 * * *"
# @TODO when v6 is released this should be uncommented
push:
#branches-ignore:
# - 'master'
# @TODO when v6 is released this should be uncommented
pull_request:
release:
types: [published]
workflow_dispatch:
env:
#CORE_HASH:
#WEB_HASH:
#FTL_HASH:
CORE_BRANCH: development-v6
WEB_BRANCH: development-v6
FTL_BRANCH: development-v6
# @TODO when v6 is released *_HASH should be set to release commit hashes and *_BRANCH to release branches
jobs:
globals:
concurrency: globals-${{ github.ref_name || github.run_id }}
runs-on: ubuntu-latest
if: ${{ !contains(github.head_ref, 'gh-pages') }}
outputs:
VERSION: ${{ steps.globals.outputs.VERSION }}
CORE_REF: ${{ steps.globals.outputs.CORE_REF }}
WEB_REF: ${{ steps.globals.outputs.WEB_REF }}
FTL_REF: ${{ steps.globals.outputs.FTL_REF }}
steps:
- name: Checkout own repository
uses: actions/checkout@v4
- name: Set outputs
id: globals
run: bash ./scripts/globals.sh
build-core:
concurrency: build-core-${{ github.ref_name || github.run_id }}
needs: [globals]
runs-on: ubuntu-latest
outputs:
VERSION: ${{ steps.version.outputs.OUTPUT }}
steps:
- name: Checkout own repository
uses: actions/checkout@v4
- name: Checkout pi-hole/pi-hole repository
uses: actions/checkout@v4
with:
repository: pi-hole/pi-hole
ref: ${{ needs.globals.outputs.CORE_REF }}
path: ./stage
- name: Cache result
id: cache
uses: ./.github/actions/cache
with:
key_prefix: core-
patches_prefix: core
- name: Apply patches
if: steps.cache.outputs.cache-hit != 'true'
uses: ./.github/actions/patch
with:
patches_prefix: core
- name: Save repository version infos
if: steps.cache.outputs.cache-hit != 'true'
uses: ./.github/actions/version
- name: Remove .git directory
run: rm -fr ./stage/.git
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: core
path: ./stage/*
retention-days: 1
build-web:
concurrency: build-web-${{ github.ref_name || github.run_id }}
needs: [globals]
runs-on: ubuntu-latest
outputs:
VERSION: ${{ steps.version.outputs.OUTPUT }}
steps:
- name: Checkout own repository
uses: actions/checkout@v4
- name: Checkout pi-hole/web repository
uses: actions/checkout@v4
with:
repository: pi-hole/web
ref: ${{ needs.globals.outputs.WEB_REF }}
path: ./stage
- name: Cache result
id: cache
uses: ./.github/actions/cache
with:
key_prefix: web-
patches_prefix: web
- name: Apply patches
if: steps.cache.outputs.cache-hit != 'true'
uses: ./.github/actions/patch
with:
patches_prefix: web
- name: Save repository version infos
if: steps.cache.outputs.cache-hit != 'true'
uses: ./.github/actions/version
- name: Remove .git directory
run: rm -fr ./stage/.git
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: web
path: ./stage/*
retention-days: 1
build-binary:
concurrency: build-binary-${{ github.ref_name || github.run_id }}-${{ matrix.arch }}
needs: [globals]
runs-on: ubuntu-latest
continue-on-error: ${{ matrix.allow-failure }}
outputs:
VERSION: ${{ steps.version.outputs.OUTPUT }}
strategy:
fail-fast: false
matrix:
include:
# - arch: aarch64
# platform: linux/aarch64
# allow-failure: false
# - arch: armv5
# platform: linux/arm/v5 # EOS by Entware team
# allow-failure: true
- arch: armv7
platform: linux/arm/v7
allow-failure: false
# - arch: mipsel
# platform: linux/mipsel # Not supported by Pi-hole
# allow-failure: true
# - arch: mips
# platform: linux/mips # Not supported by Pi-hole
# allow-failure: true
# - arch: amd64
# platform: linux/amd64
# allow-failure: false
# - arch: 386
# platform: linux/386 # EOS by Entware team
# allow-failure: false
steps:
- name: Fail this job
if: ${{ matrix.allow-failure && github.ref_name != 'master' && !startsWith(github.ref, 'refs/tags/') }}
run: exit 1
- name: Checkout own repository
uses: actions/checkout@v4
- name: Checkout pi-hole/FTL repository
uses: actions/checkout@v4
with:
repository: pi-hole/FTL
ref: ${{ needs.globals.outputs.FTL_REF }}
path: ./stage
- name: Cache result
id: cache
uses: ./.github/actions/cache
with:
key_prefix: binary-${{ matrix.arch }}-
patches_prefix: FTL
files: |
./stage/pihole-FTL
./stage/.version
- name: Apply patches
if: steps.cache.outputs.cache-hit != 'true'
uses: ./.github/actions/patch
with:
patches_prefix: FTL
- name: Save repository version infos
if: steps.cache.outputs.cache-hit != 'true'
uses: ./.github/actions/version
- name: Fetch pi-hole/FTL repository infos
if: steps.cache.outputs.cache-hit != 'true'
id: version_infos
working-directory: ./stage
run: |
echo "GIT_BRANCH=$(git rev-parse --abbrev-ref HEAD)" >> $GITHUB_OUTPUT
echo "GIT_TAG=$(git describe --tags --always 2> /dev/null)" >> $GITHUB_OUTPUT
echo "GIT_HASH=$(git rev-parse --short=8 HEAD)" >> $GITHUB_OUTPUT
- name: Set up Docker Buildx
if: steps.cache.outputs.cache-hit != 'true'
uses: docker/setup-buildx-action@v3
- name: Build and test FTL
if: steps.cache.outputs.cache-hit != 'true'
uses: docker/build-push-action@v5
with:
platforms: ${{ matrix.platform }}
pull: true
push: false
context: ./stage
target: result
file: ./stage/.github/Dockerfile
outputs: |
type=tar,dest=stage/build.tar
build-args: |
"CI_ARCH=${{ matrix.platform }}"
"GIT_BRANCH=${{ steps.version_infos.outputs.GIT_BRANCH }}"
"GIT_TAG=${{ steps.version_infos.outputs.GIT_TAG }}"
- name: Extract FTL binary and generate checksum file
if: steps.cache.outputs.cache-hit != 'true'
working-directory: ./stage
run: |
tar -xf ./build.tar pihole-FTL
sha1sum pihole-FTL > pihole-FTL.sha1
- name: Remove .git directory
run: rm -fr ./stage/.git
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: binary-${{ matrix.arch }}
path: |
./stage/pihole-FTL
./stage/.version
retention-days: 1
build-package:
concurrency: build-package-${{ github.ref_name || github.run_id }}-${{ matrix.arch }}
needs: [globals, build-core, build-web, build-binary]
runs-on: ubuntu-latest
continue-on-error: ${{ matrix.allow-failure }}
strategy:
fail-fast: false
matrix:
include:
#- arch: aarch64
# entware_arch: aarch64-3.10
# allow-failure: false
#- arch: armv5
# entware_arch: armv5-3.2 # EOS by Entware team
# allow-failure: true
#- arch: armv7
# entware_arch: armv7-2.6 # EOS by Entware team
# allow-failure: true
- arch: armv7
entware_arch: armv7-3.2
allow-failure: false
#- arch: mipsel
# entware_arch: mipselsf-3.4 # Not supported by Pi-hole
# allow-failure: true
#- arch: mips
# entware_arch: mipssf-3.4 # Not supported by Pi-hole
# allow-failure: true
#- arch: amd64
# entware_arch: x64-3.2
# allow-failure: false
#- arch: 386
# entware_arch: x86-2.6 # EOS by Entware team
# allow-failure: false
outputs:
IPK_VERSION: ${{ steps.versions.outputs.IPK }}
CORE_VERSION: ${{ steps.versions.outputs.CORE }}
WEB_VERSION: ${{ steps.versions.outputs.WEB }}
FTL_VERSION: ${{ steps.versions.outputs.FTL }}
steps:
- name: Fail this job
if: ${{ matrix.allow-failure && github.ref_name != 'master' && !startsWith(github.ref, 'refs/tags/') }}
run: exit 1
- name: Checkout own repository
uses: actions/checkout@v4
- name: Download core artifact
uses: actions/download-artifact@v4
with:
name: core
path: ./artifacts/core
- name: Download web artifact
uses: actions/download-artifact@v4
with:
name: web
path: ./artifacts/web
- name: Download binary artifact
uses: actions/download-artifact@v4
with:
name: binary-${{ matrix.arch }}
path: ./artifacts/binary
- name: Add -dev postfix to package name
if: ${{ github.ref_name == 'develop' }}
run: sed '/^Package:/ s/$/-dev/' ./files/CONTROL/control
- name: Build package
run: |
mkdir -pv ./build ./packages
bash ./scripts/build.sh ./build
bash ./scripts/ipk.sh ./build "${{ needs.globals.outputs.VERSION }}" ${{ matrix.entware_arch }}
mv -fv ./*.ipk ./packages
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: ipk-${{ matrix.entware_arch }}
path: ./packages/*
- name: Set versions
id: versions
run: |
echo "IPK=${{ needs.globals.outputs.VERSION }}" >> $GITHUB_OUTPUT
. ./artifacts/core/.version
echo "CORE=$VERSION" >> $GITHUB_OUTPUT
. ./artifacts/web/.version
echo "WEB=$VERSION" >> $GITHUB_OUTPUT
. ./artifacts/binary/.version
echo "FTL=$VERSION" >> $GITHUB_OUTPUT
release:
concurrency: release-${{ github.ref_name || github.run_id }}
needs: [build-package]
if: ${{ startsWith(github.ref, 'refs/tags/') }}
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Download artifacts
uses: actions/download-artifact@v4
with:
pattern: ipk-*
path: ./artifacts
- name: Create changelog file
env:
CORE_VERSION: ${{ needs.build-package.outputs.CORE_VERSION }}
WEB_VERSION: ${{ needs.build-package.outputs.WEB_VERSION }}
FTL_VERSION: ${{ needs.build-package.outputs.FTL_VERSION }}
run: |
CORE_VERSION_OUT="[$CORE_VERSION](https://github.com/pi-hole/pi-hole/releases/tag/$CORE_VERSION)"
WEB_VERSION_OUT="[$WEB_VERSION](https://github.com/pi-hole/web/releases/tag/$WEB_VERSION)"
FTL_VERSION_OUT="[$FTL_VERSION](https://github.com/pi-hole/FTL/releases/tag/$FTL_VERSION)"
[ "$(echo "$CORE_VERSION" | cut -c1)" != "v" ] && CORE_VERSION_OUT="[$CORE_VERSION](https://github.com/pi-hole/pi-hole/commit/$CORE_VERSION)"
[ "$(echo "$WEB_VERSION" | cut -c1)" != "v" ] && WEB_VERSION_OUT="[$WEB_VERSION](https://github.com/pi-hole/web/commit/$WEB_VERSION)"
[ "$(echo "$FTL_VERSION" | cut -c1)" != "v" ] && FTL_VERSION_OUT="[$FTL_VERSION](https://github.com/pi-hole/FTL/commit/$FTL_VERSION)"
echo "Core version: $CORE_VERSION_OUT " >> changelog.md
echo "Web version: $WEB_VERSION_OUT " >> changelog.md
echo "FTL version: $FTL_VERSION_OUT " >> changelog.md
- name: Create or Edit a release
uses: softprops/action-gh-release@v2
with:
files: ./artifacts/*/*.ipk
tag_name: ${{ needs.build-package.outputs.IPK_VERSION }}
body_path: changelog.md
append_body: true
generate_release_notes: true
upload:
concurrency: upload
needs: [build-package]
if: ${{ startsWith(github.ref, 'refs/tags/') || github.ref_name == 'develop' || github.ref_name == 'master' }}
# @TODO when v6 is released master should not trigger this job
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Setup dependencies
run: |
sudo apt-get update
sudo apt-get install rename
- name: Checkout own repository
uses: actions/checkout@v4
with:
fetch-depth: 0
sparse-checkout: /.github/*
sparse-checkout-cone-mode: false
- name: Checkout gh-pages branch
uses: actions/checkout@v4
continue-on-error: true
with:
ref: gh-pages
path: ./gh-pages
- name: Download artifacts
uses: actions/download-artifact@v4
with:
pattern: ipk-*
path: ./artifacts
- name: Collect new packages
run: |
rename 's/ipk-//' ./artifacts/ipk-*/
mkdir -p ./gh-pages
find ./artifacts -mindepth 1 -maxdepth 1 -type d -name "*-*" -exec bash -c '
ARCH=$(basename "$1")
echo "Collecting new packages for $ARCH"
if [ "$(find "$1" -maxdepth 1 -type f -name "*-dev_*.ipk" -print -quit)" ]; then
find "./gh-pages/$ARCH" -maxdepth 2 -type f -name "*-dev_*.ipk" -delete -print
else
find "./gh-pages/$ARCH" -maxdepth 2 -type f \( -name "*.ipk" ! -name "*-dev_*.ipk" \) -delete -print
fi
' bash {} \;
cp -r ./artifacts/* ./gh-pages
- name: Checkout Entware/ipk-html-indexer repository
uses: actions/checkout@v4
with:
repository: Entware/ipk-html-indexer
path: ./ipk-html-indexer
- name: Run ipk-html-indexer
run: |
sudo ln -sv "$(readlink -f ./ipk-html-indexer/mkindex.py)" /usr/local/bin/mkindex.py
sudo ln -sv "$(readlink -f ./ipk-html-indexer/mkhtml.py)" /usr/local/bin/mkhtml.py
find ./gh-pages -mindepth 1 -maxdepth 1 -type d -name "*-*" -exec bash -c '
bash ./ipk-html-indexer/index_feed.sh -h -f "$1"
sed 's#href="/css#href="css#' -i "$1/Packages.html"
cp -frv ./ipk-html-indexer/css "$1"
' bash {} \;
- name: List files
uses: ./.github/actions/list
with:
paths: . ./gh-pages
- name: Create directory listings
uses: ./.github/actions/index
with:
path: ./gh-pages
- name: List files
uses: ./.github/actions/list
with:
paths: . ./gh-pages
- name: Cleanup working directory
run: |
find . -mindepth 1 -maxdepth 1 \( ! -name "gh-pages" -type d -exec rm -frv "{}" \; \) -o \( -type f -exec rm -fv "{}" \; \)
cp -r ./gh-pages/. .
rm -fr ./gh-pages
find . -mindepth 1 -maxdepth 1 -type d ! -name "*-*" -exec rm -frv "{}" \;
- name: Rename gh-pages branch
continue-on-error: true
run: git branch -m gh-pages gh-pages.old
- name: Upload packages
uses: JamesIves/github-pages-deploy-action@v4
with:
branch: gh-pages
folder: .
commit-message: Upload
single-commit: true
force: true
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: upload
path: |
./index.html
./*-*/*