Build and Upload #17
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 and Upload | |
on: | |
create: | |
tags: | |
- '^\d{4}\.\d{2}\.\d{2}-\d+$' | |
#schedule: | |
# - cron: '0 0 * * 1' # @TODO would probably be better to have a separate workflow for automatic updates when possible | |
workflow_dispatch: | |
env: | |
REF_CORE: development-v6 # commit hash or tag | |
REF_WEB: development-v6 # commit hash or tag | |
REF_FTL: development-v6 # commit hash or tag | |
jobs: | |
set-version: | |
concurrency: set-version | |
runs-on: ubuntu-latest | |
outputs: | |
version: ${{ steps.version.outputs.OUTPUT }} | |
steps: | |
- name: Use tag name | |
if: ${{ startsWith(github.ref, 'refs/tags/') }} | |
run: echo "$GITHUB_REF_NAME" > .version | |
- name: Generate version string | |
id: version | |
run: | | |
[ -f .version ] && "OUTPUT=$(cat .version)" >> $GITHUB_OUTPUT || \ | |
echo "OUTPUT=dev-$(date +%Y.%m.%d)-$(date +%H%M%S)" >> $GITHUB_OUTPUT | |
build-core: | |
concurrency: build-core-${{ github.ref_name || github.run_id }} | |
runs-on: ubuntu-latest | |
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: ${{ env.REF_CORE }} | |
path: ./stage | |
- name: Cache result | |
id: cache | |
uses: ./.github/actions/cache | |
with: | |
key_prefix: core- | |
patches_prefix: core | |
- name: List files (initial state) | |
if: steps.cache.outputs.cache-hit != 'true' | |
uses: ./.github/actions/list | |
with: | |
paths: . ./stage | |
- name: Apply patches | |
if: steps.cache.outputs.cache-hit != 'true' | |
uses: ./.github/actions/patch | |
with: | |
patches_prefix: core | |
- name: Remove .git directory | |
if: steps.cache.outputs.cache-hit != 'true' | |
run: rm -fr ./stage/.git | |
- name: Upload artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: core | |
path: ./stage/* | |
retention-days: 7 | |
build-web: | |
concurrency: build-web-${{ github.ref_name || github.run_id }} | |
runs-on: ubuntu-latest | |
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: ${{ env.REF_WEB }} | |
path: ./stage | |
- name: Cache result | |
id: cache | |
uses: ./.github/actions/cache | |
with: | |
key_prefix: web- | |
patches_prefix: web | |
- name: List files (initial state) | |
if: steps.cache.outputs.cache-hit != 'true' | |
uses: ./.github/actions/list | |
with: | |
paths: . ./stage | |
- name: Apply patches | |
if: steps.cache.outputs.cache-hit != 'true' | |
uses: ./.github/actions/patch | |
with: | |
patches_prefix: web | |
- name: Remove .git directory | |
if: steps.cache.outputs.cache-hit != 'true' | |
run: rm -fr ./stage/.git | |
- name: Upload artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: web | |
path: ./stage/* | |
retention-days: 7 | |
build-binary: | |
concurrency: build-binary-${{ github.ref_name || github.run_id }}-${{ matrix.arch }} | |
runs-on: ubuntu-latest | |
continue-on-error: ${{ matrix.allow-failure }} | |
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/') && github.event_name != 'schedule' }} | |
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: ${{ env.REF_FTL }} | |
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: List files (initial state) | |
if: steps.cache.outputs.cache-hit != 'true' | |
uses: ./.github/actions/list | |
with: | |
paths: . ./stage | |
- name: Apply patches | |
if: steps.cache.outputs.cache-hit != 'true' | |
uses: ./.github/actions/patch | |
with: | |
patches_prefix: FTL | |
- 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: Upload artifact | |
# if: steps.cache.outputs.cache-hit != 'true' | |
# uses: actions/upload-artifact@v4 | |
# with: | |
# name: build-${{ matrix.arch }} | |
# path: ./stage/build.tar | |
# retention-days: 7 | |
- 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: List files (after build) | |
if: steps.cache.outputs.cache-hit != 'true' | |
uses: ./.github/actions/list | |
with: | |
paths: ./stage | |
- name: Remove .git directory | |
if: steps.cache.outputs.cache-hit != 'true' | |
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: 7 | |
build-package: | |
concurrency: build-package-${{ github.ref_name || github.run_id }}-${{ matrix.arch }} | |
needs: [set-version, 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 | |
steps: | |
- name: Fail this job | |
if: ${{ matrix.allow-failure && github.ref_name != 'master' && !startsWith(github.ref, 'refs/tags/') && github.event_name != 'schedule' }} | |
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: List files (initial state) | |
uses: ./.github/actions/list | |
with: | |
paths: . ./artifacts ./artifacts/core ./artifacts/web ./artifacts/binary | |
- name: Build package | |
run: | | |
mkdir -pv ./build ./packages | |
bash ./scripts/build.sh ./build | |
bash ./scripts/ipk.sh ./build "${{ needs.set-version.outputs.version }}" ${{ matrix.entware_arch }} | |
mv -fv ./*.ipk ./packages | |
- 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 | |
bash ./ipk-html-indexer/index_feed.sh -h -f ./packages | |
sed 's#href="/css#href="css#' -i ./packages/Packages.html | |
cp -frv ./ipk-html-indexer/css ./packages | |
- name: List files (after build) | |
uses: ./.github/actions/list | |
with: | |
paths: ./packages | |
- name: Upload artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: ipk-${{ matrix.entware_arch }} | |
path: ./packages/* | |
upload: | |
concurrency: upload | |
needs: build-package | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write | |
steps: | |
- name: Setup dependencies | |
run: | | |
sudo apt-get update | |
sudo apt-get install rename | |
- name: Checkout gh-pages branch | |
uses: actions/checkout@v4 | |
continue-on-error: true | |
with: | |
ref: gh-pages | |
- name: Rename gh-pages branch | |
run: git branch -m gh-pages gh-pages.old | |
continue-on-error: true | |
- name: Download artifacts | |
uses: actions/download-artifact@v4 | |
with: | |
pattern: ipk-* | |
path: ./artifacts | |
- name: Correct directory names | |
run: rename 's/ipk-//' ./artifacts/ipk-*/ | |
- name: Create a release | |
uses: softprops/action-gh-release@v2 | |
if: ${{ startsWith(github.ref, 'refs/tags/') }} | |
with: | |
files: ./artifacts/*/*.ipk | |
draft: true | |
# @TODO Draft probably not needed anymore after v6 releases | |
- name: Collect new packages | |
run: | | |
find . -maxdepth 1 -type d -name "*-*" -exec sh -c '[ -d "./artifacts/$(basename {})" ] && rm -frv {}' \; | |
mv -v ./artifacts/* . | |
rmdir -v ./artifacts | |
- name: Create index.html | |
run: | | |
rm -f ./index.html | |
find . -maxdepth 1 -type d -not -name ".git" -not -name "." -exec sh -c 'echo "<a href=\"$(basename {})/Packages.html\">$(basename {})</a><br>" >> index.html' \; | |
- name: List files | |
run: ls -aAl | |
- name: Upload packages | |
uses: JamesIves/github-pages-deploy-action@v4 | |
if: ${{ startsWith(github.ref, 'refs/tags/') || github.ref_name == 'master' || github.event_name == 'schedule' }} | |
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 | |
./*-*/* |