Skip to content

Commit

Permalink
appimage: Use linuxdeploy-build-helper-container (remove focal build-…
Browse files Browse the repository at this point in the history
…env) (#202)

* remove focal stuff

* distribute platform builds across multiple runners
  • Loading branch information
andy5995 committed Feb 12, 2024
1 parent 228e335 commit d527e12
Show file tree
Hide file tree
Showing 7 changed files with 330 additions and 252 deletions.
110 changes: 48 additions & 62 deletions .github/workflows/appimage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,100 +5,86 @@ concurrency:

on:
workflow_dispatch:
inputs:
version:
description: 'version number'
required: true
type: string
schedule:
- cron: '30 09 * * 5'
pull_request:
branches: master
paths:
- '**/appimage.yml'
- '**/*appimage*'
- '**/AppRun'

env:
VERSION: ${{ inputs.version }}

jobs:
build-x86_64:
runs-on: ubuntu-22.04
container: andy5995/netpanzer-build-env:focal
env:
ARCH: x86_64
WORKSPACE: ${{ github.workspace }}
build-appimage:
runs-on: ubuntu-latest
strategy:
matrix:
platform:
- linux/amd64
- linux/arm64
- linux/arm/v7
steps:
- uses: actions/checkout@v4
- name: Set version
run: |
VERSION="$(echo ${GITHUB_SHA} | head -c 7)-$(date +%y%m%d%H%M)"
echo "VERSION=${VERSION}" >> $GITHUB_ENV
- name: Prepare AppImage
run: |
export -p
support/appimage/make-appimage.sh
- name: Release AppImage
if: ${{ github.ref == 'refs/heads/master' }}
uses: ncipollo/release-action@v1
with:
allowUpdates: true
artifactErrorsFailBuild: true
name: NetPanzer Weekly AppImage (Unstable)
prerelease: true
draft: false
artifacts: "${{ env.WORKSPACE }}/support/NetPanz*.AppImage*"
token: ${{ secrets.GITHUB_TOKEN }}
omitBody: true
omitBodyDuringUpdate: true
omitNameDuringUpdate: true
tag: appimage-weekly
removeArtifacts: true
# If run from cron and not by dispatch, the version won't be set...
if [ -z "$VERSION" ]; then
VERSION="$(echo ${GITHUB_SHA} | head -c 7)-$(date +%y%m%d%H%M)"
echo "VERSION=${VERSION}" >> $GITHUB_ENV
fi
- if: ${{ github.ref != 'refs/heads/master' }}
name: Upload Artifacts
uses: actions/upload-artifact@v4
with:
name: netpanzer_appimage_${{ env.ARCH }}
path: ${{ github.workspace }}/support/NetPanz*.AppImage*
- name: Checkout
uses: actions/checkout@v4

build-aarch64:
runs-on: ubuntu-22.04
env:
ARCH: aarch64
WORKSPACE: ${{ github.workspace }}
steps:
- uses: actions/checkout@v4
- name: Set up QEMU
- if: ${{ ! contains(matrix.platform, 'amd64') }}
uses: docker/setup-qemu-action@v3
with:
platforms: 'arm64'

- name: Set version
- name: Build AppImage
run: |
export UID
echo $UID
VERSION="$(echo ${GITHUB_SHA} | head -c 7)-$(date +%y%m%d%H%M)"
echo "VERSION=${VERSION}" >> $GITHUB_ENV
docker run -t \
--platform=${{ matrix.platform }} \
--rm \
-e HOSTUID=$(id -u) \
-e VERSION \
-v $GITHUB_WORKSPACE:/workspace \
-w /workspace andy5995/linuxdeploy:latest support/appimage/make-appimage.sh
# Docs for this container are at
# https://github.com/andy5995/linuxdeploy-build-helper-container
- name: Run in Docker
- name: Create sha256sum
run: |
VERSION="$VERSION" support/appimage/prep-appimage.sh
IMAGE_FILENAME=$(basename `find out/*AppImage`)
echo "IMAGE_FILENAME=$IMAGE_FILENAME" >> $GITHUB_ENV
cd out
sha256sum "$IMAGE_FILENAME" > "$IMAGE_FILENAME.sha256sum"
- name: Release AppImage
if: ${{ github.ref == 'refs/heads/master' }}
- if: ${{ github.ref == 'refs/heads/master' }}
name: Release AppImage
uses: ncipollo/release-action@v1
with:
allowUpdates: true
artifactErrorsFailBuild: true
name: NetPanzer Weekly AppImage (Unstable)
prerelease: true
draft: false
artifacts: "${{ env.WORKSPACE }}/support/NetPanz*.AppImage*"
artifacts: ./out/*
token: ${{ secrets.GITHUB_TOKEN }}
omitBody: true
omitBodyDuringUpdate: true
omitNameDuringUpdate: true
tag: appimage-weekly
removeArtifacts: false
removeArtifacts: ${{ matrix.platform == 'linux/amd64' }}

- if: ${{ github.ref != 'refs/heads/master' }}
name: Upload Artifacts
name: Upload AppImage
uses: actions/upload-artifact@v4
with:
name: netpanzer_appimage_${{ env.ARCH }}
path: ${{ github.workspace }}/support/NetPanz*.AppImage*
name: ${{ env.IMAGE_FILENAME }}
path: ./out/*
if-no-files-found: error
112 changes: 94 additions & 18 deletions .github/workflows/docker-build-env.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,44 +8,120 @@ on:
- '**docker-build-env.yml'
workflow_dispatch:
schedule:
- cron: '30 11 20 * *'
- cron: '30 11 20 */3 *'


env:
REGISTRY_IMAGE: andy5995/netpanzer

jobs:
docker:
name: NP-build-env_${{ matrix.tag }}
build-env:
runs-on: ubuntu-latest
name: ${{ matrix.platform }}-dep-image
strategy:
fail-fast: false
matrix:
tag: [jammy, focal]
runs-on: ubuntu-latest
platform:
- linux/amd64
- linux/arm64
- linux/arm/v7

fail-fast: true
steps:
-
name: Prepare
run: |
platform=${{ matrix.platform }}
echo "PLATFORM_PAIR=${platform//\//-}" >> $GITHUB_ENV
-
name: Checkout
uses: actions/checkout@v4
with:
submodules: true
-
name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY_IMAGE }}

- if: ${{ matrix.platform != 'linux/amd64' }}
name: Set up QEMU
uses: docker/setup-qemu-action@v3
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
-
name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.UNCLE_ANDY_DOCKERHUB_USERNAME }}
username: andy5995
password: ${{ secrets.UNCLE_ANDY_DOCKERHUB_ACCESS_TOKEN }}
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

-
name: Build and push
name: Build and push by digest
id: build
uses: docker/build-push-action@v5
with:
build-args: CODENAME=${{ matrix.tag }}
context: ./support/docker
file: ./support/docker/Dockerfile-build-env
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ secrets.UNCLE_ANDY_DOCKERHUB_USERNAME }}/netpanzer-build-env:${{ matrix.tag }}
cache-from: type=registry,ref=${{ secrets.UNCLE_ANDY_DOCKERHUB_USERNAME }}/netpanzer-build-env:buildcache
cache-to: type=registry,ref=${{ secrets.UNCLE_ANDY_DOCKERHUB_USERNAME }}/netpanzer-build-env:buildcache,mode=max
platforms: ${{ matrix.platform }}
labels: ${{ steps.meta.outputs.labels }}
outputs: type=image,name=${{ env.REGISTRY_IMAGE }},push-by-digest=true,name-canonical=true,push=true
-
name: Export digest
run: |
mkdir -p /tmp/digests
digest="${{ steps.build.outputs.digest }}"
touch "/tmp/digests/${digest#sha256:}"
-
name: Upload digest
uses: actions/upload-artifact@v4
with:
name: digests-${{ env.PLATFORM_PAIR }}
path: /tmp/digests/*
if-no-files-found: error
retention-days: 1

# The merge job is needed to complete the job above. # When publishing a
# multi-platform image distributed across multiple runners, it's not as #
# straightforward as just using a matrix
# https://docs.docker.com/build/ci/github-actions/multi-platform/
merge:
runs-on: ubuntu-latest
needs:
- build-env
steps:
-
name: Download digests
uses: actions/download-artifact@v4
with:
path: /tmp/digests
pattern: digests-*
merge-multiple: true
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
-
name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY_IMAGE }}
tags: |
type=raw,value=build-env-jammy-latest
type=raw,value=build-env-latest
-
name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: andy5995
password: ${{ secrets.UNCLE_ANDY_DOCKERHUB_ACCESS_TOKEN }}
-
name: Create manifest list and push
working-directory: /tmp/digests
run: |
docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \
$(printf '${{ env.REGISTRY_IMAGE }}@sha256:%s ' *)
-
name: Inspect image
run: |
docker buildx imagetools inspect ${{ env.REGISTRY_IMAGE }}:${{ steps.meta.outputs.version }}
Loading

0 comments on commit d527e12

Please sign in to comment.