From 8448ec7b61ebd2902d2a364fe4de2be5dd767ab5 Mon Sep 17 00:00:00 2001 From: Veronica Berglyd Olsen <1619840+vkbo@users.noreply.github.com> Date: Sun, 12 Feb 2023 23:27:15 +0100 Subject: [PATCH] Add AppImage to build workflow --- .github/workflows/build.yml | 65 ++++++++++++++++++++++++++++++------- setup.py | 12 ++++--- 2 files changed, 61 insertions(+), 16 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 69179670..76035171 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -20,13 +20,13 @@ jobs: - name: Checkout Source uses: actions/checkout@v3 - - name: Run Build Commands + - name: Build Assets run: python setup.py qtlrelease sample manual - name: Upload Artifacts uses: actions/upload-artifact@v3 with: - name: nw-assets-${{ github.sha }} + name: nw-assets path: | novelwriter/assets/sample.zip novelwriter/assets/manual.pdf @@ -34,6 +34,49 @@ jobs: if-no-files-found: error retention-days: 1 + buildLinux: + needs: buildAssets + runs-on: ubuntu-latest + env: + LINUX_TAG: "manylinux_2_28_x86_64" + PY_VER: "3.10" + steps: + - name: Python Setup + uses: actions/setup-python@v4 + with: + python-version: 3 + architecture: x64 + + - name: Install Packages (pip) + run: pip install python-appimage + + - name: Checkout Source + uses: actions/checkout@v3 + + - name: Get Version + shell: bash + run: | + NW_VER=$(python setup.py version) + echo "novelWriter Version: $NW_VER" + echo "VERSION=$NW_VER" >> $GITHUB_ENV + + - name: Download Artifacts + uses: actions/download-artifact@v3 + with: + name: nw-assets + path: novelwriter/assets + + - name: Build AppImage + run: python setup.py build-appimage --linux-tag {{env.LINUX_TAG}} --python-version {{env.PY_VER}} + + - name: Upload Artifacts + uses: actions/upload-artifact@v3 + with: + name: novelWriter-{{env.VERSION}}-py{{env.PY_VER}}-{{env.LINUX_TAG}}.AppImage + path: dist_appimage/novelWriter-{{env.VERSION}}-py{{env.PY_VER}}-{{env.LINUX_TAG}}.AppImage + if-no-files-found: error + retention-days: 1 + buildMac: needs: buildAssets strategy: @@ -46,21 +89,20 @@ jobs: - name: Get Version shell: bash run: | - NW_VERSION=`awk '/^__version__/{print substr($NF,2,length($NF)-2)}' novelwriter/__init__.py` - echo "novelWriter Version: $NW_VERSION" - echo "VERSION=$NW_VERSION" >> $GITHUB_ENV + NW_VER=$(python setup.py version) + echo "novelWriter Version: $NW_VER" + echo "VERSION=$NW_VER" >> $GITHUB_ENV - - name: Download Artifact + - name: Download Artifacts uses: actions/download-artifact@v3 with: - name: nw-assets-${{ github.sha }} + name: nw-assets path: novelwriter/assets - - name: Build - run: | - ./setup/macos/build.sh + - name: Build App Bundle + run: ./setup/macos/build.sh - - name: Upload ZIP + - name: Upload App Zip uses: actions/upload-artifact@v3 with: name: novelWriter-${{ env.VERSION }}-macos.app.zip @@ -72,4 +114,5 @@ jobs: with: name: novelWriter-${{ env.VERSION }}-macos.dmg path: dist_macos/novelWriter-${{ env.VERSION }}-macos.dmg + if-no-files-found: error retention-days: 1 diff --git a/setup.py b/setup.py index b54f3797..51fa65ae 100755 --- a/setup.py +++ b/setup.py @@ -42,7 +42,7 @@ OS_DARWIN = 3 # Utilities # =============================================================================================== # -def extractVersion(): +def extractVersion(beQuiet=False): """Extract the novelWriter version number without having to import anything else from the main package. """ @@ -67,7 +67,8 @@ def extractVersion(): print("Could not read file: %s" % initFile) print(str(exc)) - print("novelWriter version: %s (%s) at %s" % (numVers, hexVers, relDate)) + if not beQuiet: + print("novelWriter version: %s (%s) at %s" % (numVers, hexVers, relDate)) return numVers, hexVers, relDate @@ -935,7 +936,7 @@ def makeForLaunchpad(doSign=False, isFirst=False, isSnapshot=False): ## def makeAppImage(sysArgs): - """Build an Appimage + """Build an Appimage. """ import glob import argparse @@ -1882,6 +1883,7 @@ if __name__ == "__main__": "", " help Print the help message.", " pip Install all package dependencies for novelWriter using pip.", + " version Print the novelWriter version.", " build-clean Will attempt to delete 'build' and 'dist' folders.", "", "Additional Builds:", @@ -1939,8 +1941,8 @@ if __name__ == "__main__": if "version" in sys.argv: sys.argv.remove("version") - print("Checking source version info ...") - extractVersion() + numVers, _, _ = extractVersion(beQuiet=True) + print(numVers, end=None) sys.exit(0) if "pip" in sys.argv: