From 439426adf11fc4fd9becc9b7c2b679bb45739bbf Mon Sep 17 00:00:00 2001 From: TheAssassin Date: Tue, 5 Mar 2024 03:19:24 +0100 Subject: [PATCH 1/9] Release binaries with GitHub actions --- .github/workflows/github-build.yml | 63 ++++++++++++++++++++++++++-- distribute/Dockerfile | 9 ++-- distribute/distribute-docker.sh | 10 ++++- distribute/distribute.sh | 9 ++-- distribute/docker/maven-settings.xml | 4 ++ 5 files changed, 82 insertions(+), 13 deletions(-) create mode 100644 distribute/docker/maven-settings.xml diff --git a/.github/workflows/github-build.yml b/.github/workflows/github-build.yml index eda26529..0dff4323 100644 --- a/.github/workflows/github-build.yml +++ b/.github/workflows/github-build.yml @@ -1,5 +1,5 @@ name: Build -run-name: ${{ github.actor }} builds using docker. The output is currently ignored + on: push: branches_ignore: @@ -7,10 +7,12 @@ on: pull_request: branches_ignore: - gh-pages + workflow_dispatch: + jobs: - Build: + build: runs-on: ubuntu-latest - container: 'docker://registry.gitlab.com/t-oster/visicutbuildservice' + container: 'registry.gitlab.com/t-oster/visicutbuildservice' steps: - name: Setup directories run: mkdir -p /app/build /app/output @@ -22,3 +24,58 @@ jobs: name: output binaries path: | /app/output/** + + distribute: + strategy: + fail-fast: false + + matrix: + target: + - zip + - windows-nsis + - macos-bundle + - linux-appimage + - linux-checkinstall + + name: Distribute ${{ matrix.target }} + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + with: + submodules: "recursive" + fetch-depth: 0 + + - name: Build distribution + run: | + # we use a separate directory called output to "collect" all the build artifacts + # this makes uploading the artifacts a *lot* easier + mkdir output + pushd output + bash ../distribute/distribute-docker.sh ${{ matrix.target }} + + - name: Archive built files + uses: actions/upload-artifact@v3 + with: + name: output binaries + path: | + output/* + + upload: + name: Create release and upload artifacts + needs: + - distribute + runs-on: ubuntu-20.04 + steps: + - name: Download artifacts + uses: actions/download-artifact@v2 + - name: Inspect directory after downloading artifacts + run: ls -alFR + - name: Create release and upload artifacts + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + url="$(curl -s https://api.github.com/repos/TheAssassin/pyuploadtool/releases/latest | grep browser_download_url | grep AppImage | cut -d'"' -f4)" + wget "$url" + chmod +x pyuploadtool-x86_64.AppImage + ./pyuploadtool-x86_64.AppImage "output binaries"/*.* diff --git a/distribute/Dockerfile b/distribute/Dockerfile index 47ee608b..bb6cbb80 100644 --- a/distribute/Dockerfile +++ b/distribute/Dockerfile @@ -12,10 +12,11 @@ RUN apt-get update && \ nsis zip libfuse2 checkinstall makepkg && \ python3 -m pip install git+https://github.com/TheAssassin/appimagecraft.git#egg=appimagecraft -# create fake home directory so that maven can create a ~/.m2 directory -RUN mkdir /fakehome && \ - chmod 777 /fakehome -ENV HOME=/fakehome +# we don't have a defined $HOME, but we need Maven to write the libLaserCut artifact somewhere +COPY docker/maven-settings.xml /usr/share/maven/conf/settings.xml # we shouldn't expect FUSE to work within Docker ENV APPIMAGE_EXTRACT_AND_RUN=1 + +VOLUME /visicut +RUN git config --global --add safe.directory /visicut diff --git a/distribute/distribute-docker.sh b/distribute/distribute-docker.sh index 9516949b..d27e2d63 100755 --- a/distribute/distribute-docker.sh +++ b/distribute/distribute-docker.sh @@ -9,19 +9,25 @@ image_name="visicut-distribution" docker build -t "$image_name" -f "$distribute_dir"/Dockerfile "$distribute_dir" +extra_args=() +if [[ -t 0 ]]; then + extra_args+=("-t") +fi + # mount current working directory as /cwd so that the resulting artifacts show up in it # also mount distribute/'s parent directory so that distribute.sh has access to all the necessary files # the reason is that we cannot predict where this script is called from but want to avoid any difference in executing # this script instead of distribute.sh directly docker run \ + "${extra_args[@]}" \ --rm \ -e BUILD \ -e TMPDIR=/ramdisk \ - -it \ + -i \ -w /cwd \ -v "$PWD":/cwd \ -v "$distribute_dir/..":/visicut \ --user "$(id -u)" \ --tmpfs "/ramdisk:uid=$(id -u),gid=$(id -g),exec" \ "$image_name" \ - /visicut/distribute/distribute.sh "$@" \ No newline at end of file + /visicut/distribute/distribute.sh "$@" diff --git a/distribute/distribute.sh b/distribute/distribute.sh index c26f3db8..4cc44acd 100755 --- a/distribute/distribute.sh +++ b/distribute/distribute.sh @@ -69,9 +69,9 @@ export VERSION if [ "${NO_BUILD:-}" == "" ]; then log "Building VisiCut JAR" # TODO: make out-of-source builds possible - pushd "$project_root_dir" - make clean jar - popd + pushd "$project_root_dir" + make clean jar + popd fi # we "ab"use the deployment directory to create the "visicut directory" @@ -143,7 +143,8 @@ for target in "$@"; do # need to copy the NSIS files to the build dir, since relative paths are relative to the config directory cp -Rv "$distribute_dir"/windows "$build_dir"/windows-launcher pushd windows-launcher - makensis launcher.nsi + # force charset to UTF8, otherwise the combined license file will cause conversion errors ("unable to convert to codepage 0") + makensis -INPUTCHARSET UTF8 launcher.nsi popd mv -v windows-launcher/VisiCut.exe visicut/ rm -rf windows-launcher/ diff --git a/distribute/docker/maven-settings.xml b/distribute/docker/maven-settings.xml new file mode 100644 index 00000000..3afeb71d --- /dev/null +++ b/distribute/docker/maven-settings.xml @@ -0,0 +1,4 @@ + + /tmp/.m2/repository + \ No newline at end of file From 83dfc761f0e33122f73a0a237f231af40cdfd6ac Mon Sep 17 00:00:00 2001 From: TheAssassin Date: Tue, 5 Mar 2024 02:50:35 +0100 Subject: [PATCH 2/9] Temporarily disable license inclusion --- distribute/windows/installer.nsi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/distribute/windows/installer.nsi b/distribute/windows/installer.nsi index ed0bf4f5..f6a4099a 100644 --- a/distribute/windows/installer.nsi +++ b/distribute/windows/installer.nsi @@ -33,7 +33,7 @@ ;Pages ; License page - !insertmacro MUI_PAGE_LICENSE "license-with-jre.txt" +; !insertmacro MUI_PAGE_LICENSE "license-with-jre.txt" !insertmacro MUI_PAGE_INSTFILES !define MUI_INSTFILESPAGE_FINISHHEADER_TEXT "Installation complete" !define MUI_PAGE_HEADER_TEXT "Installing" From f0b9522e86237ac6d81e48117d6aa71cba04119e Mon Sep 17 00:00:00 2001 From: TheAssassin Date: Mon, 11 Mar 2024 20:01:55 +0100 Subject: [PATCH 3/9] fixup! Release binaries with GitHub actions --- distribute/distribute-docker.sh | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/distribute/distribute-docker.sh b/distribute/distribute-docker.sh index d27e2d63..21042029 100755 --- a/distribute/distribute-docker.sh +++ b/distribute/distribute-docker.sh @@ -5,15 +5,15 @@ set -euxo pipefail # make it easier to work from the script distribute_dir="$(readlink -f "$(dirname "${BASH_SOURCE[0]}")")" -image_name="visicut-distribution" - -docker build -t "$image_name" -f "$distribute_dir"/Dockerfile "$distribute_dir" - extra_args=() if [[ -t 0 ]]; then extra_args+=("-t") fi +# we use VisicutBuilder to ensure compatibility with it +# for instance, it provides a specific NSIS version which is the only one the project can be built with +image_name="registry.gitlab.com/t-oster/visicutbuildservice" + # mount current working directory as /cwd so that the resulting artifacts show up in it # also mount distribute/'s parent directory so that distribute.sh has access to all the necessary files # the reason is that we cannot predict where this script is called from but want to avoid any difference in executing @@ -29,5 +29,6 @@ docker run \ -v "$distribute_dir/..":/visicut \ --user "$(id -u)" \ --tmpfs "/ramdisk:uid=$(id -u),gid=$(id -g),exec" \ + --entrypoint bash \ "$image_name" \ /visicut/distribute/distribute.sh "$@" From 8c14c998d5f55d60e572ea5cb2848d34fdd0f381 Mon Sep 17 00:00:00 2001 From: TheAssassin Date: Mon, 11 Mar 2024 20:02:00 +0100 Subject: [PATCH 4/9] Revert "Temporarily disable license inclusion" This reverts commit 83dfc761f0e33122f73a0a237f231af40cdfd6ac. --- distribute/windows/installer.nsi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/distribute/windows/installer.nsi b/distribute/windows/installer.nsi index f6a4099a..ed0bf4f5 100644 --- a/distribute/windows/installer.nsi +++ b/distribute/windows/installer.nsi @@ -33,7 +33,7 @@ ;Pages ; License page -; !insertmacro MUI_PAGE_LICENSE "license-with-jre.txt" + !insertmacro MUI_PAGE_LICENSE "license-with-jre.txt" !insertmacro MUI_PAGE_INSTFILES !define MUI_INSTFILESPAGE_FINISHHEADER_TEXT "Installation complete" !define MUI_PAGE_HEADER_TEXT "Installing" From 785d1e52863c5820dff69e8c3c08c02deb33c441 Mon Sep 17 00:00:00 2001 From: TheAssassin Date: Mon, 11 Mar 2024 20:50:05 +0100 Subject: [PATCH 5/9] Revert "fixup! Release binaries with GitHub actions" This reverts commit f0b9522e86237ac6d81e48117d6aa71cba04119e. --- distribute/distribute-docker.sh | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/distribute/distribute-docker.sh b/distribute/distribute-docker.sh index 21042029..d27e2d63 100755 --- a/distribute/distribute-docker.sh +++ b/distribute/distribute-docker.sh @@ -5,15 +5,15 @@ set -euxo pipefail # make it easier to work from the script distribute_dir="$(readlink -f "$(dirname "${BASH_SOURCE[0]}")")" +image_name="visicut-distribution" + +docker build -t "$image_name" -f "$distribute_dir"/Dockerfile "$distribute_dir" + extra_args=() if [[ -t 0 ]]; then extra_args+=("-t") fi -# we use VisicutBuilder to ensure compatibility with it -# for instance, it provides a specific NSIS version which is the only one the project can be built with -image_name="registry.gitlab.com/t-oster/visicutbuildservice" - # mount current working directory as /cwd so that the resulting artifacts show up in it # also mount distribute/'s parent directory so that distribute.sh has access to all the necessary files # the reason is that we cannot predict where this script is called from but want to avoid any difference in executing @@ -29,6 +29,5 @@ docker run \ -v "$distribute_dir/..":/visicut \ --user "$(id -u)" \ --tmpfs "/ramdisk:uid=$(id -u),gid=$(id -g),exec" \ - --entrypoint bash \ "$image_name" \ /visicut/distribute/distribute.sh "$@" From 5bba83ff669b313b1e8f548ed8350b98a147e50a Mon Sep 17 00:00:00 2001 From: TheAssassin Date: Mon, 11 Mar 2024 20:56:21 +0100 Subject: [PATCH 6/9] Fix NSIS language bug --- distribute/Dockerfile | 3 +++ 1 file changed, 3 insertions(+) diff --git a/distribute/Dockerfile b/distribute/Dockerfile index bb6cbb80..4d4eb201 100644 --- a/distribute/Dockerfile +++ b/distribute/Dockerfile @@ -6,6 +6,9 @@ SHELL ["bash", "-x", "-c"] ENV DEBIAN_FRONTEND=noninteractive +# workaround nsis bug: https://sourceforge.net/p/nsis/bugs/1180/ +ENV LANG C.UTF-8 + # note: don't build with OpenJDK > 16, as this is the runtime we ship RUN apt-get update && \ apt-get install -y openjdk-11-jdk git wget shellcheck bash make maven python3-minimal python3-pip \ From 278b230f32b3daa533cf12bf7131c0d40f7780e9 Mon Sep 17 00:00:00 2001 From: TheAssassin Date: Mon, 11 Mar 2024 20:56:38 +0100 Subject: [PATCH 7/9] Add remaining packages from VisicutBuilder --- distribute/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/distribute/Dockerfile b/distribute/Dockerfile index 4d4eb201..f7568ac2 100644 --- a/distribute/Dockerfile +++ b/distribute/Dockerfile @@ -12,7 +12,7 @@ ENV LANG C.UTF-8 # note: don't build with OpenJDK > 16, as this is the runtime we ship RUN apt-get update && \ apt-get install -y openjdk-11-jdk git wget shellcheck bash make maven python3-minimal python3-pip \ - nsis zip libfuse2 checkinstall makepkg && \ + nsis zip libfuse2 checkinstall makepkg fonts-noto-extra potrace sudo && \ python3 -m pip install git+https://github.com/TheAssassin/appimagecraft.git#egg=appimagecraft # we don't have a defined $HOME, but we need Maven to write the libLaserCut artifact somewhere From 04d0bcd80f455e411e4909152657b240016b9adf Mon Sep 17 00:00:00 2001 From: TheAssassin Date: Tue, 12 Mar 2024 19:28:06 +0100 Subject: [PATCH 8/9] Drop obsolete build step --- .github/workflows/github-build.yml | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/.github/workflows/github-build.yml b/.github/workflows/github-build.yml index 0dff4323..f90149d0 100644 --- a/.github/workflows/github-build.yml +++ b/.github/workflows/github-build.yml @@ -10,21 +10,6 @@ on: workflow_dispatch: jobs: - build: - runs-on: ubuntu-latest - container: 'registry.gitlab.com/t-oster/visicutbuildservice' - steps: - - name: Setup directories - run: mkdir -p /app/build /app/output - - name: Run build - run: /app/build.sh - - name: Archive built files - uses: actions/upload-artifact@v3 - with: - name: output binaries - path: | - /app/output/** - distribute: strategy: fail-fast: false From e9407dba91babea7130100f4ec2eee803aa8408a Mon Sep 17 00:00:00 2001 From: TheAssassin Date: Tue, 12 Mar 2024 19:28:20 +0100 Subject: [PATCH 9/9] Pin versions of appimagecraft and pyuploadtool --- .github/workflows/github-build.yml | 3 +-- distribute/Dockerfile | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/workflows/github-build.yml b/.github/workflows/github-build.yml index f90149d0..63c5c624 100644 --- a/.github/workflows/github-build.yml +++ b/.github/workflows/github-build.yml @@ -60,7 +60,6 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | - url="$(curl -s https://api.github.com/repos/TheAssassin/pyuploadtool/releases/latest | grep browser_download_url | grep AppImage | cut -d'"' -f4)" - wget "$url" + wget https://github.com/TheAssassin/pyuploadtool/releases/download/20231223-1/pyuploadtool-x86_64.AppImage chmod +x pyuploadtool-x86_64.AppImage ./pyuploadtool-x86_64.AppImage "output binaries"/*.* diff --git a/distribute/Dockerfile b/distribute/Dockerfile index f7568ac2..a7b91691 100644 --- a/distribute/Dockerfile +++ b/distribute/Dockerfile @@ -13,7 +13,7 @@ ENV LANG C.UTF-8 RUN apt-get update && \ apt-get install -y openjdk-11-jdk git wget shellcheck bash make maven python3-minimal python3-pip \ nsis zip libfuse2 checkinstall makepkg fonts-noto-extra potrace sudo && \ - python3 -m pip install git+https://github.com/TheAssassin/appimagecraft.git#egg=appimagecraft + python3 -m pip install git+https://github.com/TheAssassin/appimagecraft.git@6b36fda#egg=appimagecraft # we don't have a defined $HOME, but we need Maven to write the libLaserCut artifact somewhere COPY docker/maven-settings.xml /usr/share/maven/conf/settings.xml