Linux #748
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: Linux | |
on: | |
workflow_call: | |
workflow_dispatch: | |
env: | |
REGISTRY: ghcr.io | |
jobs: | |
deb: | |
name: deb (${{ matrix.build-type }}, Qt 6, ${{ matrix.image }}) | |
runs-on: ubuntu-latest | |
permissions: | |
contents: read | |
packages: write | |
strategy: | |
fail-fast: false | |
matrix: | |
include: | |
- image: ubuntu-22_04 | |
build-script: ubuntu_deb_entrypoint.sh | |
build-type: release | |
- image: ubuntu-23_10 | |
build-script: ubuntu_deb_entrypoint.sh | |
build-type: release | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
with: | |
submodules: recursive | |
- name: Check if Dockerfile or build script has been modified | |
id: docker_image | |
run: | | |
set -ex | |
git remote add upstream https://github.com/nuttyartist/notes.git | |
git fetch --unshallow upstream master | |
# NOTE: The following should give us the previous commit hash of the base branch, but that will | |
# only work reliably for 'push' and pull_request events. For workflow_dispatch events, we | |
# have to fallback to the default branch ('master'), until a better solution is found... | |
previous_ref=${{ github.event.pull_request.base.sha || github.event.before || 'upstream/master' }} | |
if ! git diff --compact-summary --exit-code "${previous_ref}" -- 'Dockerfiles/${{ matrix.image }}' 'Dockerfiles/${{ matrix.build-script }}' | |
then | |
needs_rebuild=true | |
elif ! docker pull '${{ env.REGISTRY }}/nuttyartist/notes:${{ matrix.image }}' | |
then | |
needs_rebuild=true | |
else | |
needs_rebuild=false | |
fi | |
echo "needs_rebuild=${needs_rebuild}" >> "${GITHUB_OUTPUT}" | |
- name: Build and tag Docker image | |
if: steps.docker_image.outputs.needs_rebuild == 'true' | |
run: docker build -f 'Dockerfiles/${{ matrix.image }}' -t '${{ env.REGISTRY }}/nuttyartist/notes:${{ matrix.image }}' . | |
- name: Setup GCC problem matcher | |
uses: ammaraskar/gcc-problem-matcher@0.3.0 | |
- name: Build, package and lint | |
id: build | |
run: docker run --rm -v "${GITHUB_OUTPUT}:/GITHUB_OUTPUT" -v "$(pwd):/src" -t '${{ env.REGISTRY }}/nuttyartist/notes:${{ matrix.image }}' -t ${{ matrix.build-type }} ${{ github.ref_type == 'tag' && '-n' || ' ' }} | |
- name: Upload deb package | |
uses: actions/upload-artifact@v4 | |
with: | |
if-no-files-found: error | |
name: ${{ steps.build.outputs.deb_name }}-qt6-${{ steps.build.outputs.distro_name }}-${{ matrix.build-type }} | |
path: ${{ steps.build.outputs.deb_path }} | |
- name: Login to GitHub Container Registry | |
if: ${{ steps.docker_image.outputs.needs_rebuild == 'true' && github.repository == 'nuttyartist/notes' && github.event_name != 'pull_request' && github.ref_name == 'master' }} | |
uses: docker/login-action@v3 | |
with: | |
registry: ${{ env.REGISTRY }} | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Extract metadata (tags, labels) for Docker | |
if: ${{ steps.docker_image.outputs.needs_rebuild == 'true' && github.repository == 'nuttyartist/notes' && github.event_name != 'pull_request' && github.ref_name == 'master' }} | |
id: meta | |
uses: docker/metadata-action@v5 | |
with: | |
images: ${{ env.REGISTRY }}/nuttyartist/notes:${{ matrix.image }} | |
- name: Build and push Docker image | |
if: ${{ steps.docker_image.outputs.needs_rebuild == 'true' && github.repository == 'nuttyartist/notes' && github.event_name != 'pull_request' && github.ref_name == 'master' }} | |
uses: docker/build-push-action@v6 | |
env: | |
DOCKER_BUILD_SUMMARY: false | |
with: | |
file: Dockerfiles/${{ matrix.image }} | |
push: true | |
tags: ${{ env.REGISTRY }}/nuttyartist/notes:${{ matrix.image }} | |
rpm: | |
name: rpm (${{ matrix.build-type }}, Qt 6, ${{ matrix.image }}) | |
runs-on: ubuntu-latest | |
strategy: | |
fail-fast: false | |
matrix: | |
include: | |
# Fedora's release cycle: https://endoflife.date/fedora | |
- image: fedora-38 | |
build-script: rpm_entrypoint.sh | |
build-type: release | |
# openSUSE's release cycle: https://endoflife.date/opensuse | |
- image: opensuse-15_5 | |
build-script: rpm_entrypoint.sh | |
build-type: release | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
with: | |
submodules: recursive | |
- name: Check if Dockerfile or build script has been modified | |
id: docker_image | |
run: | | |
set -ex | |
git remote add upstream https://github.com/nuttyartist/notes.git | |
git fetch --unshallow upstream master | |
# NOTE: The following should give us the previous commit hash of the base branch, but that will | |
# only work reliably for 'push' and pull_request events. For workflow_dispatch events, we | |
# have to fallback to the default branch ('master'), until a better solution is found... | |
previous_ref=${{ github.event.pull_request.base.sha || github.event.before || 'upstream/master' }} | |
if ! git diff --compact-summary --exit-code "${previous_ref}" -- 'Dockerfiles/${{ matrix.image }}' 'Dockerfiles/${{ matrix.build-script }}' | |
then | |
needs_rebuild=true | |
elif ! docker pull '${{ env.REGISTRY }}/nuttyartist/notes:${{ matrix.image }}' | |
then | |
needs_rebuild=true | |
else | |
needs_rebuild=false | |
fi | |
echo "needs_rebuild=${needs_rebuild}" >> "${GITHUB_OUTPUT}" | |
- name: Build and tag Docker image | |
if: steps.docker_image.outputs.needs_rebuild == 'true' | |
run: docker build -f 'Dockerfiles/${{ matrix.image }}' -t '${{ env.REGISTRY }}/nuttyartist/notes:${{ matrix.image }}' . | |
- name: Setup GCC problem matcher | |
uses: ammaraskar/gcc-problem-matcher@0.3.0 | |
- name: Build, package and lint | |
id: build | |
run: docker run --rm -v "${GITHUB_OUTPUT}:/GITHUB_OUTPUT" -v "$(pwd):/src" -t '${{ env.REGISTRY }}/nuttyartist/notes:${{ matrix.image }}' -t ${{ matrix.build-type }} ${{ github.ref_type == 'tag' && '-n' || ' ' }} | |
- name: Upload rpm package | |
uses: actions/upload-artifact@v4 | |
with: | |
if-no-files-found: error | |
name: ${{ steps.build.outputs.rpm_name }}-qt6-${{ steps.build.outputs.distro_name }}-${{ matrix.build-type }} | |
path: ${{ steps.build.outputs.rpm_path }} | |
- name: Login to GitHub Container Registry | |
if: ${{ steps.docker_image.outputs.needs_rebuild == 'true' && github.repository == 'nuttyartist/notes' && github.event_name != 'pull_request' && github.ref_name == 'master' }} | |
uses: docker/login-action@v3 | |
with: | |
registry: ${{ env.REGISTRY }} | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Extract metadata (tags, labels) for Docker | |
if: ${{ steps.docker_image.outputs.needs_rebuild == 'true' && github.repository == 'nuttyartist/notes' && github.event_name != 'pull_request' && github.ref_name == 'master' }} | |
id: meta | |
uses: docker/metadata-action@v5 | |
with: | |
images: ${{ env.REGISTRY }}/nuttyartist/notes:${{ matrix.image }} | |
- name: Build and push Docker image | |
if: ${{ steps.docker_image.outputs.needs_rebuild == 'true' && github.repository == 'nuttyartist/notes' && github.event_name != 'pull_request' && github.ref_name == 'master' }} | |
uses: docker/build-push-action@v6 | |
env: | |
DOCKER_BUILD_SUMMARY: false | |
with: | |
file: Dockerfiles/${{ matrix.image }} | |
push: true | |
tags: ${{ env.REGISTRY }}/nuttyartist/notes:${{ matrix.image }} | |
appimage: | |
name: AppImage (${{ matrix.build-type }}, Qt 6, ${{ matrix.image }}) | |
runs-on: ubuntu-latest | |
strategy: | |
fail-fast: false | |
matrix: | |
include: | |
- image: appimage-qt6 | |
build-script: appimage_entrypoint.sh | |
build-type: release | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
with: | |
submodules: recursive | |
- name: Check if Dockerfile or build script has been modified | |
id: docker_image | |
run: | | |
set -ex | |
git remote add upstream https://github.com/nuttyartist/notes.git | |
git fetch --unshallow upstream master | |
# NOTE: The following should give us the previous commit hash of the base branch, but that will | |
# only work reliably for 'push' and pull_request events. For workflow_dispatch events, we | |
# have to fallback to the default branch ('master'), until a better solution is found... | |
previous_ref=${{ github.event.pull_request.base.sha || github.event.before || 'upstream/master' }} | |
if ! git diff --compact-summary --exit-code "${previous_ref}" -- 'Dockerfiles/${{ matrix.image }}' 'Dockerfiles/${{ matrix.build-script }}' | |
then | |
needs_rebuild=true | |
elif ! docker pull '${{ env.REGISTRY }}/nuttyartist/notes:${{ matrix.image }}' | |
then | |
needs_rebuild=true | |
else | |
needs_rebuild=false | |
fi | |
echo "needs_rebuild=${needs_rebuild}" >> "${GITHUB_OUTPUT}" | |
- name: Build and tag Docker image | |
if: steps.docker_image.outputs.needs_rebuild == 'true' | |
run: docker build -f 'Dockerfiles/${{ matrix.image }}' -t '${{ env.REGISTRY }}/nuttyartist/notes:${{ matrix.image }}' . | |
- name: Setup GCC problem matcher | |
uses: ammaraskar/gcc-problem-matcher@0.3.0 | |
- name: Build, package and lint | |
id: build | |
run: docker run --rm -v "${GITHUB_OUTPUT}:/GITHUB_OUTPUT" -v "$(pwd):/src" -t '${{ env.REGISTRY }}/nuttyartist/notes:${{ matrix.image }}' -t ${{ matrix.build-type }} ${{ github.ref_type == 'tag' && '-n' || ' ' }} | |
- name: (FIXME) Run qmllint | |
run: docker run --rm -v "$(pwd):/src" --entrypoint '' -t '${{ env.REGISTRY }}/nuttyartist/notes:${{ matrix.image }}' cmake --build build --target all_qmllint || true | |
- name: Upload AppImage artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
if-no-files-found: error | |
name: ${{ steps.build.outputs.artifact_name }}-${{ runner.os }}-${{ matrix.build-type }} | |
path: ${{ steps.build.outputs.appimage_path }} | |
- name: Login to GitHub Container Registry | |
if: ${{ steps.docker_image.outputs.needs_rebuild == 'true' && github.repository == 'nuttyartist/notes' && github.event_name != 'pull_request' && github.ref_name == 'master' }} | |
uses: docker/login-action@v3 | |
with: | |
registry: ${{ env.REGISTRY }} | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Extract metadata (tags, labels) for Docker | |
if: ${{ steps.docker_image.outputs.needs_rebuild == 'true' && github.repository == 'nuttyartist/notes' && github.event_name != 'pull_request' && github.ref_name == 'master' }} | |
id: meta | |
uses: docker/metadata-action@v5 | |
with: | |
images: ${{ env.REGISTRY }}/nuttyartist/notes:${{ matrix.image }} | |
- name: Build and push Docker image | |
if: ${{ steps.docker_image.outputs.needs_rebuild == 'true' && github.repository == 'nuttyartist/notes' && github.event_name != 'pull_request' && github.ref_name == 'master' }} | |
uses: docker/build-push-action@v6 | |
env: | |
DOCKER_BUILD_SUMMARY: false | |
with: | |
file: Dockerfiles/${{ matrix.image }} | |
push: true | |
tags: ${{ env.REGISTRY }}/nuttyartist/notes:${{ matrix.image }} | |
snap: | |
name: snap | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
with: | |
submodules: recursive | |
- name: Install snapcraft | |
run: | | |
sudo snap install snapcraft --classic | |
- name: Set up LXD | |
run: | | |
sudo usermod -a -G lxd "${USER}" | |
sudo lxd init --auto | |
sudo iptables -P FORWARD ACCEPT | |
- name: Build | |
run: | | |
sg lxd -c 'snap run snapcraft -v' | |
- name: Grab snap package name | |
id: snap | |
shell: bash | |
run: | | |
set -x | |
if ! path=$(find . -maxdepth 1 -name '*.snap' -print -quit) | |
then | |
echo 'Fatal: Unable to find snap package' | |
exit 1 | |
fi | |
echo "name=$(basename "${path%.*}")" >> "${GITHUB_OUTPUT}" | |
echo "path=${path}" >> "${GITHUB_OUTPUT}" | |
- name: Upload snap package | |
uses: actions/upload-artifact@v4 | |
with: | |
if-no-files-found: error | |
name: ${{ steps.snap.outputs.name }}.snap | |
path: ${{ steps.snap.outputs.path }} |