|
| 1 | +name: Build and package TiddlyDesktop |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - master |
| 7 | + tags: |
| 8 | + - 'v[0-9]+.[0-9]+.[0-9]+' |
| 9 | + pull_request: |
| 10 | + branches: |
| 11 | + - master |
| 12 | + |
| 13 | +jobs: |
| 14 | + build-and-package: |
| 15 | + strategy: |
| 16 | + matrix: |
| 17 | + include: |
| 18 | + - platform: linux |
| 19 | + arch: x64 |
| 20 | + ext: tar.gz |
| 21 | + platform-for-pkg: linux64 |
| 22 | + runs-on: ubuntu-latest |
| 23 | + - platform: linux |
| 24 | + arch: ia32 |
| 25 | + ext: tar.gz |
| 26 | + platform-for-pkg: linux32 |
| 27 | + runs-on: ubuntu-latest |
| 28 | + - platform: win |
| 29 | + arch: x64 |
| 30 | + ext: zip |
| 31 | + platform-for-pkg: win64 |
| 32 | + runs-on: ubuntu-latest |
| 33 | + - platform: win |
| 34 | + arch: ia32 |
| 35 | + ext: zip |
| 36 | + platform-for-pkg: win32 |
| 37 | + runs-on: ubuntu-latest |
| 38 | + - platform: osx |
| 39 | + arch: x64 |
| 40 | + ext: zip |
| 41 | + platform-for-pkg: mac64 |
| 42 | + runs-on: macos-latest |
| 43 | + - platform: osx |
| 44 | + arch: arm64 |
| 45 | + ext: zip |
| 46 | + platform-for-pkg: macapplesilicon |
| 47 | + runs-on: macos-latest |
| 48 | + runs-on: ${{ matrix.runs-on }} |
| 49 | + name: "Build ${{ matrix.platform-for-pkg }}" |
| 50 | + steps: |
| 51 | + - name: "💾 Checking out repository code..." |
| 52 | + uses: actions/checkout@v4 |
| 53 | + - name: "🔭 Looking up TiddlyDesktop version..." |
| 54 | + id: td-version |
| 55 | + run: | |
| 56 | + TD_VERSION=$(bin/get-version-number) |
| 57 | + echo "TiddlyDesktop version: $TD_VERSION" |
| 58 | + echo "version=$TD_VERSION" >> "$GITHUB_OUTPUT" |
| 59 | + - name: "🧮 Calculating nw.js version..." |
| 60 | + id: calc-version |
| 61 | + run: | |
| 62 | + NWJS_VERSION=$(<nwjs-version.txt) |
| 63 | + [ -n "$NWJS_VERSION" ] && echo "nw.js version: $NWJS_VERSION" || echo "No nwjs-version.txt file found!" |
| 64 | + [ -n "$NWJS_VERSION" ] && echo "nwjs-version=$NWJS_VERSION" >> "$GITHUB_OUTPUT" |
| 65 | + - name: "🗃️ Setting up caching for nw.js..." |
| 66 | + id: nwjs-cache |
| 67 | + uses: actions/cache@v4 |
| 68 | + with: |
| 69 | + path: nwjs |
| 70 | + key: nwjs-${{ matrix.platform }}-${{ matrix.arch }}-${{ steps.calc-version.outputs.nwjs-version }} |
| 71 | + - name: "🛝 Downloading nw.js..." |
| 72 | + if: ${{ steps.nwjs-cache.outputs.cache-hit != 'true' }} |
| 73 | + run: ./download-nwjs.sh |
| 74 | + env: |
| 75 | + NWJS_VERSION: ${{ steps.calc-version.outputs.nwjs-version }} |
| 76 | + PLATFORM: ${{ matrix.platform }} |
| 77 | + ARCH: ${{ matrix.arch }} |
| 78 | + EXT: ${{ matrix.ext }} |
| 79 | + - name: "🛠️ Building TiddlyDesktop..." |
| 80 | + run: ./bld.sh |
| 81 | + env: |
| 82 | + NWJS_VERSION: ${{ steps.calc-version.outputs.nwjs-version }} |
| 83 | + PLATFORM: ${{ matrix.platform }} |
| 84 | + ARCH: ${{ matrix.arch }} |
| 85 | + - name: "📦 Packaging TiddlyDesktop..." |
| 86 | + run: ./package.sh |
| 87 | + env: |
| 88 | + PLATFORM: ${{ matrix.platform }} |
| 89 | + ARCH: ${{ matrix.arch }} |
| 90 | + - name: "📤 Uploading packages..." |
| 91 | + uses: actions/upload-artifact@v4 |
| 92 | + with: |
| 93 | + name: tiddlydesktop-${{ matrix.platform-for-pkg }}-v${{ steps.td-version.outputs.version }}.zip |
| 94 | + path: output/tiddlydesktop-${{ matrix.platform-for-pkg }}-v${{ steps.td-version.outputs.version }}.zip |
| 95 | + outputs: |
| 96 | + td-version: ${{ steps.td-version.outputs.version }} |
| 97 | + |
| 98 | + release: |
| 99 | + # Run only if a tag was pushed (tag filter in workflow guarantees the only tags we'll see are ones that look like v1.2.3) |
| 100 | + if: ${{ startsWith(github.ref, 'refs/tags/') }} |
| 101 | + # Run only after build-and-package job completes |
| 102 | + needs: build-and-package |
| 103 | + # This job does *not* have a matrix so it runs only a single copy |
| 104 | + runs-on: ubuntu-latest |
| 105 | + steps: |
| 106 | + - name: "📥 Downloading packages..." |
| 107 | + uses: actions/download-artifact@v4 |
| 108 | + with: |
| 109 | + # merge-multiple: true means that all built files will end up in the workspace directory |
| 110 | + # If it was false, they would all be given their own separate directories, which is not convenient for the release step |
| 111 | + merge-multiple: true |
| 112 | + - name: "🚀 Creating release..." |
| 113 | + uses: softprops/action-gh-release@v1 |
| 114 | + with: |
| 115 | + draft: true |
| 116 | + files: | |
| 117 | + tiddlydesktop-*-v${{ needs.build-and-package.outputs.td-version }}.zip |
0 commit comments