-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
493 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,143 @@ | ||
on: | ||
push: | ||
pull_request: | ||
workflow_dispatch: | ||
|
||
name: CI | ||
|
||
env: | ||
GTK_VERSION: 4.14.4 | ||
IMAGE_NAME: ${{ github.repository }}-gtk-4.14.4 | ||
IMAGE_TAG: ${{ github.ref_name }} | ||
|
||
jobs: | ||
build-linux-appimage: | ||
permissions: | ||
contents: read | ||
|
||
needs: create-docker-image | ||
|
||
name: Build Linux AppImage | ||
runs-on: ubuntu-latest | ||
|
||
container: | ||
image: ghcr.io/${{ needs.create-docker-image.outputs.NAME }}:${{ needs.create-docker-image.outputs.TAG }} | ||
credentials: | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.DOCKER_REGISTRY_TOKEN }} | ||
|
||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v4 | ||
|
||
- name: Workaround issues when GitHub does not respect the HOME env var | ||
run: | | ||
# GitHub Actions only supports containers running as root | ||
# see: https://github.com/actions/checkout/issues/1014 | ||
mv /home/runner/.cargo $HOME | ||
mv /home/runner/.nvm $HOME | ||
mv /home/runner/.rustup $HOME | ||
- uses: Swatinem/rust-cache@v2 | ||
|
||
- name: Install toolchain | ||
run: | | ||
rustup toolchain install stable | ||
rustup default stable | ||
- name: Build packetry binary | ||
run: | | ||
cargo build --release | ||
- name: Test under XVFB (Linux) | ||
run: | | ||
xvfb-run cargo test | ||
if: runner.os == 'Linux' | ||
|
||
- name: Run build appimage action (Linux) | ||
uses: ./appimage/ | ||
with: | ||
executable: ./target/release/packetry | ||
icon-file: ./appimage/dist/icon.png | ||
desktop-file: ./appimage/dist/packetry.desktop | ||
|
||
- name: Upload AppImage binary (Linux) | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: Linux AppImage binary | ||
path: packetry-x86_64.AppImage | ||
if-no-files-found: error | ||
|
||
|
||
create-docker-image: | ||
permissions: | ||
contents: read | ||
packages: write | ||
attestations: write | ||
id-token: write | ||
|
||
name: Create Docker image | ||
runs-on: ubuntu-latest | ||
outputs: | ||
NAME: ${{ env.IMAGE_NAME }} | ||
TAG: ${{ env.IMAGE_TAG }} | ||
|
||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v4 | ||
|
||
- name: Escape image tag | ||
run: | | ||
echo "IMAGE_TAG=$(echo ${{ env.IMAGE_TAG }} | sed -e 's/\//-/g')" >> $GITHUB_ENV | ||
- name: Check if Dockerfile has changed | ||
uses: dorny/paths-filter@v3 | ||
id: changed | ||
with: | ||
base: ${{ github.ref_name }} | ||
filters: | | ||
dockerfile: | ||
- "appimage/docker/**" | ||
- name: Check if Docker image exists | ||
id: exists | ||
shell: bash | ||
run: | | ||
declare -a HEADERS=( | ||
'-H' "Accept: application/vnd.oci.image.manifest.v1+json" | ||
'-H' "Accept: application/vnd.oci.image.index.v1+json" | ||
'-H' "Authorization: Bearer $(echo ${{ secrets.DOCKER_REGISTRY_TOKEN }} | base64)" | ||
) | ||
RESULT=$(curl "${HEADERS[@]}" https://ghcr.io/v2/${IMAGE_NAME}/manifests/${IMAGE_TAG}) | ||
echo 'dockerimage<<EOF' >> $GITHUB_OUTPUT | ||
echo ${RESULT} | jq 'has("manifests")' >> $GITHUB_OUTPUT | ||
echo 'EOF' >> $GITHUB_OUTPUT | ||
- name: Log in to the Container registry | ||
if: ${{ steps.changed.outputs.dockerfile == 'true' || steps.exists.outputs.dockerimage == 'false' }} | ||
uses: docker/login-action@v3 | ||
with: | ||
registry: ghcr.io | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.DOCKER_REGISTRY_TOKEN }} | ||
|
||
- name: Set up Docker Buildx | ||
if: ${{ steps.changed.outputs.dockerfile == 'true' || steps.exists.outputs.dockerimage == 'false' }} | ||
uses: docker/setup-buildx-action@v3 | ||
|
||
- name: Build and push Docker image | ||
if: ${{ steps.changed.outputs.dockerfile == 'true' || steps.exists.outputs.dockerimage == 'false' }} | ||
id: push | ||
uses: docker/build-push-action@v6 | ||
with: | ||
context: appimage/docker/ | ||
push: true | ||
tags: ghcr.io/${{ env.IMAGE_NAME }}:${{ env.IMAGE_TAG }} | ||
|
||
- name: Generate artifact attestation | ||
if: ${{ steps.changed.outputs.dockerfile == 'true' || steps.exists.outputs.dockerimage == 'false' }} | ||
uses: actions/attest-build-provenance@v1 | ||
with: | ||
subject-name: ghcr.io/${{ env.IMAGE_NAME }} | ||
subject-digest: ${{ steps.push.outputs.digest }} | ||
push-to-registry: true |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
name: "AppImage" | ||
description: "Builds a Linux AppImage on Debian 10 (Buster)" | ||
inputs: | ||
executable: | ||
description: "Executable file" | ||
required: true | ||
icon-file: | ||
description: "Icon file to use for Executable" | ||
required: true | ||
desktop-file: | ||
description: "Desktop file to use for Executable" | ||
required: true | ||
|
||
|
||
runs: | ||
using: composite | ||
|
||
steps: | ||
- name: Build packetry-x86_64.AppDir (Linux) | ||
shell: bash | ||
run: | | ||
DEPLOY_GTK_VERSION=4 linuxdeploy-x86_64.AppImage \ | ||
--appimage-extract-and-run \ | ||
--appdir packetry.AppDir \ | ||
--executable=${{ inputs.executable }} \ | ||
--icon-file ${{ inputs.icon-file }} \ | ||
--plugin gtk \ | ||
--desktop-file ${{ inputs.desktop-file }} | ||
- name: Shrink packetry-x86_64.AppDir (Linux) | ||
shell: bash | ||
run: | | ||
# cd to AppDir lib directory | ||
cd $GITHUB_WORKSPACE/packetry.AppDir/usr/lib | ||
# fix symlinks | ||
rm libgdk_pixbuf-2.0.so | ||
rm libgdk_pixbuf-2.0.so.0 | ||
ln -s libgdk_pixbuf-2.0.so.0.4200.11 libgdk_pixbuf-2.0.so | ||
ln -s libgdk_pixbuf-2.0.so.0.4200.11 libgdk_pixbuf-2.0.so.0 | ||
rm libgio-2.0.so | ||
rm libgio-2.0.so.0 | ||
ln -s libgio-2.0.so.0.7600.0 libgio-2.0.so | ||
ln -s libgio-2.0.so.0.7600.0 libgio-2.0.so.0 | ||
rm libgobject-2.0.so | ||
rm libgobject-2.0.so.0 | ||
ln -s libgobject-2.0.so.0.7600.0 libgobject-2.0.so | ||
ln -s libgobject-2.0.so.0.7600.0 libgobject-2.0.so.0 | ||
rm libpango-1.0.so | ||
rm libpango-1.0.so.0 | ||
ln -s libpango-1.0.so.0.5400.0 libpango-1.0.so | ||
ln -s libpango-1.0.so.0.5400.0 libpango-1.0.so.0 | ||
rm libpangocairo-1.0.so | ||
rm libpangocairo-1.0.so.0 | ||
ln -s libpangocairo-1.0.so.0.5400.0 libpangocairo-1.0.so | ||
ln -s libpangocairo-1.0.so.0.5400.0 libpangocairo-1.0.so.0 | ||
rm libpangoft2-1.0.so | ||
rm libpangoft2-1.0.so.0 | ||
ln -s libpangoft2-1.0.so.0.5400.0 libpangoft2-1.0.so | ||
ln -s libpangoft2-1.0.so.0.5400.0 libpangoft2-1.0.so.0 | ||
# remove some libraries we don't need | ||
rm libX* | ||
rm libblkid* | ||
rm libbsd* | ||
rm libcroco* | ||
rm libicu* | ||
rm libpixbufloader* | ||
rm libpixman* | ||
rm librsvg* | ||
rm libxcb-render* | ||
rm libxml* | ||
rm libzstd* | ||
# add some libraries we do need | ||
# | ||
# NB: $GTK4 is defined by the Dockerfile | ||
cp $GTK4/lib/x86_64-linux-gnu/libharfbuzz-gobject.so.0.40000.0 . | ||
ln -s libharfbuzz-gobject.so.0.40000.0 libharfbuzz-gobject.so.0 | ||
ln -s libharfbuzz-gobject.so.0.40000.0 libharfbuzz-gobject.so | ||
cp $GTK4/lib/x86_64-linux-gnu/libharfbuzz-icu.so.0.40000.0 . | ||
ln -s libharfbuzz-icu.so.0.40000.0 libharfbuzz-icu.so.0 | ||
ln -s libharfbuzz-icu.so.0.40000.0 libharfbuzz-icu.so | ||
cp $GTK4/lib/x86_64-linux-gnu/libharfbuzz.so.0.40000.0 . | ||
ln -s libharfbuzz.so.0.40000.0 libharfbuzz.so.0 | ||
ln -s libharfbuzz.so.0.40000.0 libharfbuzz.so | ||
cp $GTK4/lib/x86_64-linux-gnu/libharfbuzz-subset.so.0.40000.0 . | ||
ln -s libharfbuzz-subset.so.0.40000.0 libharfbuzz-subset.so.0 | ||
ln -s libharfbuzz-subset.so.0.40000.0 libharfbuzz-subset.so | ||
# strip all libraries | ||
strip lib*.so.* | ||
# return to workspace directory | ||
cd $GITHUB_WORKSPACE | ||
- name: Build packetry-x86_64.AppImage (Linux) | ||
shell: bash | ||
run: | | ||
appimagetool-x86_64.AppImage \ | ||
--appimage-extract-and-run \ | ||
packetry.AppDir/ |
Oops, something went wrong.