Skip to content

Commit

Permalink
Add GitHub Actions workflow to build TiddlyDesktop (#289)
Browse files Browse the repository at this point in the history
* Add GitHub Actions workflow to build TiddlyDesktop

* Build in parallel so it takes one-sixth as long

* Add release workflow

Creates draft releases so they can be edited (adding release notes, for
example) before they become visible to the public.
rmunn authored Mar 2, 2024
1 parent 8a0c4e0 commit a7d492e
Showing 5 changed files with 258 additions and 13 deletions.
117 changes: 117 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
name: Build and package TiddlyDesktop

on:
push:
branches:
- master
tags:
- 'v[0-9]+.[0-9]+.[0-9]+'
pull_request:
branches:
- master

jobs:
build-and-package:
strategy:
matrix:
include:
- platform: linux
arch: x64
ext: tar.gz
platform-for-pkg: linux64
runs-on: ubuntu-latest
- platform: linux
arch: ia32
ext: tar.gz
platform-for-pkg: linux32
runs-on: ubuntu-latest
- platform: win
arch: x64
ext: zip
platform-for-pkg: win64
runs-on: ubuntu-latest
- platform: win
arch: ia32
ext: zip
platform-for-pkg: win32
runs-on: ubuntu-latest
- platform: osx
arch: x64
ext: zip
platform-for-pkg: mac64
runs-on: macos-latest
- platform: osx
arch: arm64
ext: zip
platform-for-pkg: macapplesilicon
runs-on: macos-latest
runs-on: ${{ matrix.runs-on }}
name: "Build ${{ matrix.platform-for-pkg }}"
steps:
- name: "💾 Checking out repository code..."
uses: actions/checkout@v4
- name: "🔭 Looking up TiddlyDesktop version..."
id: td-version
run: |
TD_VERSION=$(bin/get-version-number)
echo "TiddlyDesktop version: $TD_VERSION"
echo "version=$TD_VERSION" >> "$GITHUB_OUTPUT"
- name: "🧮 Calculating nw.js version..."
id: calc-version
run: |
NWJS_VERSION=$(<nwjs-version.txt)
[ -n "$NWJS_VERSION" ] && echo "nw.js version: $NWJS_VERSION" || echo "No nwjs-version.txt file found!"
[ -n "$NWJS_VERSION" ] && echo "nwjs-version=$NWJS_VERSION" >> "$GITHUB_OUTPUT"
- name: "🗃️ Setting up caching for nw.js..."
id: nwjs-cache
uses: actions/cache@v4
with:
path: nwjs
key: nwjs-${{ matrix.platform }}-${{ matrix.arch }}-${{ steps.calc-version.outputs.nwjs-version }}
- name: "🛝 Downloading nw.js..."
if: ${{ steps.nwjs-cache.outputs.cache-hit != 'true' }}
run: ./download-nwjs.sh
env:
NWJS_VERSION: ${{ steps.calc-version.outputs.nwjs-version }}
PLATFORM: ${{ matrix.platform }}
ARCH: ${{ matrix.arch }}
EXT: ${{ matrix.ext }}
- name: "🛠️ Building TiddlyDesktop..."
run: ./bld.sh
env:
NWJS_VERSION: ${{ steps.calc-version.outputs.nwjs-version }}
PLATFORM: ${{ matrix.platform }}
ARCH: ${{ matrix.arch }}
- name: "📦 Packaging TiddlyDesktop..."
run: ./package.sh
env:
PLATFORM: ${{ matrix.platform }}
ARCH: ${{ matrix.arch }}
- name: "📤 Uploading packages..."
uses: actions/upload-artifact@v4
with:
name: tiddlydesktop-${{ matrix.platform-for-pkg }}-v${{ steps.td-version.outputs.version }}.zip
path: output/tiddlydesktop-${{ matrix.platform-for-pkg }}-v${{ steps.td-version.outputs.version }}.zip
outputs:
td-version: ${{ steps.td-version.outputs.version }}

release:
# 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)
if: ${{ startsWith(github.ref, 'refs/tags/') }}
# Run only after build-and-package job completes
needs: build-and-package
# This job does *not* have a matrix so it runs only a single copy
runs-on: ubuntu-latest
steps:
- name: "📥 Downloading packages..."
uses: actions/download-artifact@v4
with:
# merge-multiple: true means that all built files will end up in the workspace directory
# If it was false, they would all be given their own separate directories, which is not convenient for the release step
merge-multiple: true
- name: "🚀 Creating release..."
uses: softprops/action-gh-release@v1
with:
draft: true
files: |
tiddlydesktop-*-v${{ needs.build-and-package.outputs.td-version }}.zip
68 changes: 62 additions & 6 deletions bld.sh
Original file line number Diff line number Diff line change
@@ -35,9 +35,20 @@ mkdir -p output/linux64/TiddlyDesktop-linux64-v$(./bin/get-version-number)

# For each platform, copy the stock nw.js binaries overlaying the "source" directory (and icons and plist for the Mac)

# Calculate nw.js version

if [ $# -gt 0 ]; then
NWJS_VERSION=$1
elif [ -z "$NWJS_VERSION" ]; then
NWJS_VERSION=0.77.0
fi

# Build function definitions (which will be called at the end of the script)

# OS X 64-bit App
build_mac64() {

cp -RH nwjs/nwjs-sdk-v0.77.0-osx-x64/nwjs.app output/mac64/TiddlyDesktop-mac64-v$(./bin/get-version-number)/TiddlyDesktop.app
cp -RH nwjs/nwjs-sdk-v${NWJS_VERSION}-osx-x64/nwjs.app output/mac64/TiddlyDesktop-mac64-v$(./bin/get-version-number)/TiddlyDesktop.app
cp -RH source output/mac64/TiddlyDesktop-mac64-v$(./bin/get-version-number)/TiddlyDesktop.app/Contents/Resources/app.nw
cp icons/app.icns output/mac64/TiddlyDesktop-mac64-v$(./bin/get-version-number)/TiddlyDesktop.app/Contents/Resources/nw.icns
cp Info.plist output/mac64/TiddlyDesktop-mac64-v$(./bin/get-version-number)/TiddlyDesktop.app/Contents/Info.plist
@@ -47,9 +58,12 @@ do
cp "./strings/InfoPlist.strings" "$f/InfoPlist.strings"
done

}

# OS X Apple Silicon App
build_macapplesilicon() {

cp -RH nwjs/nwjs-sdk-v0.77.0-osx-arm64/nwjs.app output/macapplesilicon/TiddlyDesktop-macapplesilicon-v$(./bin/get-version-number)/TiddlyDesktop.app
cp -RH nwjs/nwjs-sdk-v${NWJS_VERSION}-osx-arm64/nwjs.app output/macapplesilicon/TiddlyDesktop-macapplesilicon-v$(./bin/get-version-number)/TiddlyDesktop.app
cp -RH source output/macapplesilicon/TiddlyDesktop-macapplesilicon-v$(./bin/get-version-number)/TiddlyDesktop.app/Contents/Resources/app.nw
cp icons/app.icns output/macapplesilicon/TiddlyDesktop-macapplesilicon-v$(./bin/get-version-number)/TiddlyDesktop.app/Contents/Resources/nw.icns
cp Info.plist output/macapplesilicon/TiddlyDesktop-macapplesilicon-v$(./bin/get-version-number)/TiddlyDesktop.app/Contents/Info.plist
@@ -61,18 +75,60 @@ done

xattr -c output/macapplesilicon/TiddlyDesktop-macapplesilicon-v$(./bin/get-version-number)/TiddlyDesktop.app

}

# Windows 64-bit App
cp -RH nwjs/nwjs-sdk-v0.77.0-win-x64/* output/win64/TiddlyDesktop-win64-v$(./bin/get-version-number)
build_win64() {
cp -RH nwjs/nwjs-sdk-v${NWJS_VERSION}-win-x64/* output/win64/TiddlyDesktop-win64-v$(./bin/get-version-number)
cp -RH source/* output/win64/TiddlyDesktop-win64-v$(./bin/get-version-number)
}

# # Windows 32-bit App
cp -RH nwjs/nwjs-sdk-v0.77.0-win-ia32/* output/win32/TiddlyDesktop-win32-v$(./bin/get-version-number)
build_win32() {
cp -RH nwjs/nwjs-sdk-v${NWJS_VERSION}-win-ia32/* output/win32/TiddlyDesktop-win32-v$(./bin/get-version-number)
cp -RH source/* output/win32/TiddlyDesktop-win32-v$(./bin/get-version-number)
}

# # Linux 64-bit App
cp -RH nwjs/nwjs-sdk-v0.77.0-linux-x64/* output/linux64/TiddlyDesktop-linux64-v$(./bin/get-version-number)
build_linux64() {
cp -RH nwjs/nwjs-sdk-v${NWJS_VERSION}-linux-x64/* output/linux64/TiddlyDesktop-linux64-v$(./bin/get-version-number)
cp -RH source/* output/linux64/TiddlyDesktop-linux64-v$(./bin/get-version-number)
}

# # Linux 32-bit App
cp -RH nwjs/nwjs-sdk-v0.77.0-linux-ia32/* output/linux32/TiddlyDesktop-linux32-v$(./bin/get-version-number)
build_linux32() {
cp -RH nwjs/nwjs-sdk-v${NWJS_VERSION}-linux-ia32/* output/linux32/TiddlyDesktop-linux32-v$(./bin/get-version-number)
cp -RH source/* output/linux32/TiddlyDesktop-linux32-v$(./bin/get-version-number)
}

if [ "$CI" = "true" ]; then
# Running in GitHub Actions, where each platform builds as a separate step, in parallel, with PLATFORM and ARCH variables supplied by the GitHub Actions script
case "$PLATFORM-$ARCH" in
osx-x64)
build_mac64
;;
osx-arm64)
build_macapplesilicon
;;
win-ia32)
build_win32
;;
win-x64)
build_win64
;;
linux-ia32)
build_linux32
;;
linux-x64)
build_linux64
;;
esac
else
# Running at the command line, where each platfom builds one at a time in sequence
build_mac64
build_macapplesilicon
build_win32
build_win64
build_linux32
build_linux64
fi
33 changes: 27 additions & 6 deletions download-nwjs.sh
Original file line number Diff line number Diff line change
@@ -4,18 +4,39 @@

[[ -d ./nwjs ]] || mkdir ./nwjs || exit 1

# Set default nw.js version if not specified in environment variable or parameter

if [ $# -gt 0 ]; then
NWJS_VERSION=$1
elif [ -z "$NWJS_VERSION" ]; then
NWJS_VERSION=0.77.0
fi

# Download nw.js

curl --output 'nwjs/nwjs-sdk-v0.77.0-win-x64.zip' 'https://dl.nwjs.io/v0.77.0/nwjs-sdk-v0.77.0-win-x64.zip' || exit 1
curl --output 'nwjs/nwjs-sdk-v0.77.0-win-ia32.zip' 'https://dl.nwjs.io/v0.77.0/nwjs-sdk-v0.77.0-win-ia32.zip' || exit 1
curl --output 'nwjs/nwjs-sdk-v0.77.0-linux-x64.tar.gz' 'https://dl.nwjs.io/v0.77.0/nwjs-sdk-v0.77.0-linux-x64.tar.gz' || exit 1
curl --output 'nwjs/nwjs-sdk-v0.77.0-linux-ia32.tar.gz' 'https://dl.nwjs.io/v0.77.0/nwjs-sdk-v0.77.0-linux-ia32.tar.gz' || exit 1
curl --output 'nwjs/nwjs-sdk-v0.77.0-osx-x64.zip' 'https://dl.nwjs.io/v0.77.0/nwjs-sdk-v0.77.0-osx-x64.zip' || exit 1
curl --output 'nwjs/nwjs-sdk-v0.77.0-osx-arm64.zip' 'https://dl.nwjs.io/v0.77.0/nwjs-sdk-v0.77.0-osx-arm64.zip' || exit 1
if [ "$CI" = "true" ]; then
# Running in GitHub Actions, where each platform builds as a separate step, in parallel, with PLATFORM and ARCH and EXT variables supplied by the GitHub Actions script
curl --output "nwjs/nwjs-sdk-v${NWJS_VERSION}-${PLATFORM}-${ARCH}.${EXT}" "https://dl.nwjs.io/v${NWJS_VERSION}/nwjs-sdk-v${NWJS_VERSION}-${PLATFORM}-${ARCH}.${EXT}" || exit 1
else
# Running at the command line, where each platfom builds one at a time in sequence
curl --output "nwjs/nwjs-sdk-v${NWJS_VERSION}-win-x64.zip" "https://dl.nwjs.io/v${NWJS_VERSION}/nwjs-sdk-v${NWJS_VERSION}-win-x64.zip" || exit 1
curl --output "nwjs/nwjs-sdk-v${NWJS_VERSION}-win-ia32.zip" "https://dl.nwjs.io/v${NWJS_VERSION}/nwjs-sdk-v${NWJS_VERSION}-win-ia32.zip" || exit 1
curl --output "nwjs/nwjs-sdk-v${NWJS_VERSION}-linux-x64.tar.gz" "https://dl.nwjs.io/v${NWJS_VERSION}/nwjs-sdk-v${NWJS_VERSION}-linux-x64.tar.gz" || exit 1
curl --output "nwjs/nwjs-sdk-v${NWJS_VERSION}-linux-ia32.tar.gz" "https://dl.nwjs.io/v${NWJS_VERSION}/nwjs-sdk-v${NWJS_VERSION}-linux-ia32.tar.gz" || exit 1
curl --output "nwjs/nwjs-sdk-v${NWJS_VERSION}-osx-x64.zip" "https://dl.nwjs.io/v${NWJS_VERSION}/nwjs-sdk-v${NWJS_VERSION}-osx-x64.zip" || exit 1
curl --output "nwjs/nwjs-sdk-v${NWJS_VERSION}-osx-arm64.zip" "https://dl.nwjs.io/v${NWJS_VERSION}/nwjs-sdk-v${NWJS_VERSION}-osx-arm64.zip" || exit 1
fi

pushd nwjs

if [ ".$EXT" = ".tar.gz" ]; then
ls *.gz | xargs -n 1 tar -xvzf || exit 1
elif [ ".$EXT" = ".zip" ]; then
ls *.zip | xargs -n 1 unzip || exit 1
else
# Running at command line, not in GitHub Actions
ls *.gz | xargs -n 1 tar -xvzf || exit 1
ls *.zip | xargs -n 1 unzip || exit 1
fi

popd
1 change: 1 addition & 0 deletions nwjs-version.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0.77.0
52 changes: 51 additions & 1 deletion package.sh
Original file line number Diff line number Diff line change
@@ -7,22 +7,72 @@
VERSION=$(./bin/get-version-number)

# Zip them up
package_win32() {
pushd ./output/win32
zip -r "../tiddlydesktop-win32-v$VERSION.zip" *
popd
}

package_win64() {
pushd ./output/win64
zip -r "../tiddlydesktop-win64-v$VERSION.zip" *
popd
}

package_mac64() {
pushd ./output/mac64
zip --symlinks -r "../tiddlydesktop-mac64-v$VERSION.zip" *
popd
}

package_macapplesilicon() {
pushd ./output/macapplesilicon
sudo xattr -rc "./TiddlyDesktop-macapplesilicon-v$VERSION/TiddlyDesktop.app" && sudo codesign --force --deep --sign - "./TiddlyDesktop-macapplesilicon-v$VERSION/TiddlyDesktop.app"
sudo xattr -rc "./TiddlyDesktop-macapplesilicon-v$VERSION/TiddlyDesktop.app" -a sudo codesign --force --deep --sign - "./TiddlyDesktop-macapplesilicon-v$VERSION/TiddlyDesktop.app"
zip --symlinks -r "../tiddlydesktop-macapplesilicon-v$VERSION.zip" *
popd
}

package_linux32() {
pushd ./output/linux32
zip -r "../tiddlydesktop-linux32-v$VERSION.zip" *
popd
}

package_linux64() {
pushd ./output/linux64
zip -r "../tiddlydesktop-linux64-v$VERSION.zip" *
popd
}


if [ "$CI" = "true" ]; then
# Running in GitHub Actions, where each platform builds as a separate step, in parallel, with PLATFORM and ARCH variables supplied by the GitHub Actions script
case "$PLATFORM-$ARCH" in
osx-x64)
package_mac64
;;
osx-arm64)
package_macapplesilicon
;;
win-ia32)
package_win32
;;
win-x64)
package_win64
;;
linux-ia32)
package_linux32
;;
linux-x64)
package_linux64
;;
esac
else
# Running at the command line, where each platfom builds one at a time in sequence
package_mac64
package_macapplesilicon
package_win32
package_win64
package_linux32
package_linux64
fi

0 comments on commit a7d492e

Please sign in to comment.