diff --git a/.github/workflows/build-push-tagged-appimage.yml b/.github/workflows/build-push-tagged-appimage.yml new file mode 100644 index 0000000..cf2951a --- /dev/null +++ b/.github/workflows/build-push-tagged-appimage.yml @@ -0,0 +1,67 @@ +name: build-push-tagged + +on: + push: + tags: + - '*.*.*' + +env: + # Use docker.io for Docker Hub if empty + REGISTRY: ghcr.io + # github.repository as / + IMAGE_NAME: ${{ github.repository }} + + +jobs: + build: + + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + + steps: + # TO get the tag name + - name: Get the tag name + run: echo "TAG=${GITHUB_REF/refs\/tags\//}" >> $GITHUB_ENV + - name: Checkout repository + uses: actions/checkout@v2 + + # Login against a Docker registry except on PR + # https://github.com/docker/login-action + - name: Log into registry ${{ env.REGISTRY }} + if: github.event_name != 'pull_request' + uses: docker/login-action@28218f9b04b4f3f62068d7b6ce6ca5b26e35336c + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + # Extract metadata (tags, labels) for Docker + # https://github.com/docker/metadata-action + - name: Extract Docker metadata + id: meta + uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38 + with: + # list of Docker images to use as base name for tags + images: | + ghcr.io/13hannes11/gtk4-rs-docker + # generate Docker tags based on the following events/attributes + flavor: | + latest=auto + prefix=appimage_,onlatest=true + tags: + type=semver,pattern={{version}} + type=semver,pattern={{major}}.{{minor}} + type=semver,pattern={{major}} + + # Build and push Docker image with Buildx (don't push on PR) + # https://github.com/docker/build-push-action + - name: Build and push Docker image + uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc + with: + context: appimage + push: ${{ github.event_name != 'pull_request' }} + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + diff --git a/README.md b/README.md index 34a577b..17ced47 100644 --- a/README.md +++ b/README.md @@ -6,16 +6,21 @@ This repository contains the build instructions for a rust libadwaita gtk app. A To build the image go to the main repository and run: - ### BaseImage ``` docker build base -t gtk4-rs-docker ``` +### AppImage + +``` +docker build appimage -t gtk4-rs-docker +``` + ## Compiling the example application -To compile the example application use docker-compose (note your system needs `libadwaita` to run the example application): +To compile the example application use docker-compose (note your system needs `libadwaita` to run the example application unless you build the AppImage): ``` docker-compose up diff --git a/adwaita-demo/.gitignore b/adwaita-demo/.gitignore index ea8c4bf..b6b1b07 100644 --- a/adwaita-demo/.gitignore +++ b/adwaita-demo/.gitignore @@ -1 +1,4 @@ /target +/libs +*.AppImage +*.png diff --git a/adwaita-demo/Cargo.toml b/adwaita-demo/Cargo.toml index c6f76dd..7cd33f7 100644 --- a/adwaita-demo/Cargo.toml +++ b/adwaita-demo/Cargo.toml @@ -6,3 +6,11 @@ edition = "2021" [dependencies] adw = { version = "0.1", package = "libadwaita" } gtk = { version = "0.4", package = "gtk4" } + +[package.metadata.appimage] +auto_link = true +auto_link_exclude_list = [ + "libc.so*", + "libdl.so*", + "libpthread.so*", +] diff --git a/appimage/Dockerfile b/appimage/Dockerfile new file mode 100644 index 0000000..92a159a --- /dev/null +++ b/appimage/Dockerfile @@ -0,0 +1,30 @@ +FROM fedora:latest + +ENV RUST_VERSION=1.58.1 +RUN dnf install gtk4-devel gcc libadwaita-devel -y + +RUN curl https://sh.rustup.rs -sSf | sh -s -- -y +RUN . ~/.cargo/env +RUN ls $HOME/.cargo/env +ENV PATH=/root/.cargo/bin:$PATH +RUN rustup install ${RUST_VERSION} + + +ENV APPIMAGE_VERSION=13 +ENV APPIMAGE_EXTRACT_AND_RUN=1 + +RUN cargo install cargo-appimage + +RUN dnf install wget -y + +RUN wget https://github.com/AppImage/AppImageKit/releases/download/$APPIMAGE_VERSION/appimagetool-x86_64.AppImage +RUN chmod +x appimagetool-x86_64.AppImage +RUN ./appimagetool-x86_64.AppImage --appimage-extract +RUN ls +RUN ln -nfs /squashfs-root/usr/bin/appimagetool /usr/bin/appimagetool + +RUN dnf install file desktop-file-utils appstream -y + +WORKDIR /mnt + +CMD ["/bin/bash"] diff --git a/appimage/docker-compose.yml b/appimage/docker-compose.yml new file mode 100644 index 0000000..3a40583 --- /dev/null +++ b/appimage/docker-compose.yml @@ -0,0 +1,7 @@ +version: "3" +services: + rust-gtk-appimage: + build: . + volumes: + - ../adwaita-demo:/mnt:z + command: /bin/bash -c "cargo appimage"