From 8797012c2feb29f909edd2f448dced487ed70a5a Mon Sep 17 00:00:00 2001 From: TheAssassin Date: Sun, 24 Mar 2024 17:40:40 +0100 Subject: [PATCH] Release with GitHub actions (#710) The old external download and build server https://download.visicut.org/ is now replaced by GitHub's own features (Actions and Releases) https://github.com/t-oster/VisiCut/releases . (For a while, both will be available in parallel.) - Known limitation: `potrace` no longer included on Windows/Mac --> The "Vectorization" feature in VisiCut no longer works out-of-the-box on these systems. https://github.com/t-oster/VisiCut/issues/717 - New: Linux AppImage (single executable "portable app") - Technical change: GitHub Actions build process no longer depends on VisicutBuilder --- .github/workflows/github-build.yml | 57 ++++++++++++++++++++++++---- distribute/Dockerfile | 16 +++++--- distribute/distribute-docker.sh | 10 ++++- distribute/distribute.sh | 9 +++-- distribute/docker/maven-settings.xml | 4 ++ 5 files changed, 76 insertions(+), 20 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..63c5c624 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,18 +7,59 @@ on: pull_request: branches_ignore: - gh-pages + workflow_dispatch: + jobs: - Build: + distribute: + strategy: + fail-fast: false + + matrix: + target: + - zip + - windows-nsis + - macos-bundle + - linux-appimage + - linux-checkinstall + + name: Distribute ${{ matrix.target }} runs-on: ubuntu-latest - container: 'docker://registry.gitlab.com/t-oster/visicutbuildservice' + steps: - - name: Setup directories - run: mkdir -p /app/build /app/output - - name: Run build - run: /app/build.sh + - 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: | - /app/output/** + 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: | + 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 47ee608b..a7b91691 100644 --- a/distribute/Dockerfile +++ b/distribute/Dockerfile @@ -6,16 +6,20 @@ 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 \ - nsis zip libfuse2 checkinstall makepkg && \ - python3 -m pip install git+https://github.com/TheAssassin/appimagecraft.git#egg=appimagecraft + nsis zip libfuse2 checkinstall makepkg fonts-noto-extra potrace sudo && \ + python3 -m pip install git+https://github.com/TheAssassin/appimagecraft.git@6b36fda#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