Skip to content

Commit

Permalink
Automatically package Windows & Mac release on push (#201)
Browse files Browse the repository at this point in the history
  • Loading branch information
graphemecluster authored Dec 15, 2024
1 parent 2014519 commit dd2d361
Show file tree
Hide file tree
Showing 17 changed files with 307 additions and 347 deletions.
65 changes: 0 additions & 65 deletions .ci/backup.travis.yml

This file was deleted.

38 changes: 0 additions & 38 deletions .ci/build_android.sh

This file was deleted.

20 changes: 0 additions & 20 deletions .ci/build_linux.sh

This file was deleted.

24 changes: 0 additions & 24 deletions .ci/build_windows.sh

This file was deleted.

5 changes: 0 additions & 5 deletions .ci/config.txt

This file was deleted.

3 changes: 0 additions & 3 deletions .ci/default.custom.yaml

This file was deleted.

21 changes: 0 additions & 21 deletions .ci/ibus-install-template.sh

This file was deleted.

18 changes: 18 additions & 0 deletions .ci/install-schema.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/bin/bash
curl -fsSL https://git.io/rime-install | bash -s -- prelude essay cantonese emoji-cantonese cangjie stroke luna-pinyin CanCLID/rime-loengfan lotem/rime-octagram-data lotem/rime-octagram-data@hant

if [ -n "$rime_dir" ]; then
pushd "$rime_dir"
perl -0777 -i -pe 's/\nschema_list:\n.*?\n\n/
installed_from: rime-cantonese
schema_list:
- schema: jyut6ping3
- schema: cangjie5
- schema: stroke
- schema: luna_pinyin
/s; s/page_size: [0-9]+/page_size: 8/' default.yaml
rm emoji_cantonese_suggestion.yaml
popd
fi
19 changes: 0 additions & 19 deletions .ci/mac-install-template.sh

This file was deleted.

53 changes: 53 additions & 0 deletions .ci/package-mac.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
#!/bin/bash
if [ -z "$SQUIRREL_VERSION" ]; then
echo 'Error: Please specify the Squirrel version to package in the SQUIRREL_VERSION variable' >&2
exit 1
fi
if [ -z "$SCHEMA_DIR" ]; then
echo 'Error: Please specify the path to the schema directory in the SCHEMA_DIR variable' >&2
exit 1
fi
if [ -z "$APPLE_DEVELOPER_NAME" ] || [ -z "$APPLE_DEVELOPER_TEAM_ID" ] || [ -z "$APPLE_CONNECT_USERNAME" ] || [ -z "$APPLE_CONNECT_PASSWORD" ]; then
echo 'Error: Please specify the APPLE_DEVELOPER_NAME, APPLE_DEVELOPER_TEAM_ID, APPLE_CONNECT_USERNAME, and APPLE_CONNECT_PASSWORD variables for code resigning and notarization' >&2
exit 1
fi
set -e

# Modify the package with the solution from https://stackoverflow.com/a/11299907
# First, download the package and extract it
wget https://github.com/rime/squirrel/releases/download/${SQUIRREL_VERSION}/Squirrel-${SQUIRREL_VERSION}.pkg
pkgutil --expand Squirrel-${SQUIRREL_VERSION}.pkg package
pushd package

# Extract the application
tar -xzf Payload
pushd Squirrel.app/Contents

# Remove all default rime schemas but keep opencc data and app config
# Then, download the latest schemas we need and amend the `default.yaml`
GLOBIGNORE=SharedSupport/squirrel.yaml
rm SharedSupport/*.*
cp -rf "$SCHEMA_DIR/"* SharedSupport
popd

# Resign the application
codesign --sign "Developer ID Application: $APPLE_DEVELOPER_NAME ($APPLE_DEVELOPER_TEAM_ID)" --timestamp --deep --force --options runtime --preserve-metadata=identifier,entitlements Squirrel.app

# Compress back the application
find Squirrel.app | cpio -o | gzip -c > Payload
mkbom Squirrel.app Bom
rm -rf Squirrel.app
popd

# Finally, compress back the package
mkdir output
pkgutil --flatten package output/Squirrel.pkg
cd output

# Resign the package
pkg_path=Squirrel-${SQUIRREL_VERSION}-rime-cantonese.pkg
productsign --sign "Developer ID Installer: $APPLE_DEVELOPER_NAME ($APPLE_DEVELOPER_TEAM_ID)" Squirrel.pkg "$pkg_path"

# Notarize the package
xcrun notarytool submit "$pkg_path" --apple-id "$APPLE_CONNECT_USERNAME" --password "$APPLE_CONNECT_PASSWORD" --team-id "$APPLE_DEVELOPER_TEAM_ID" --wait
xcrun stapler staple "$pkg_path"
53 changes: 53 additions & 0 deletions .ci/package-windows.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
#!/bin/bash
if [ -z "$WEASEL_VERSION" ]; then
echo 'Error: Please specify the Weasel version to package in the WEASEL_VERSION variable' >&2
exit 1
fi
if [ -z "$SCHEMA_DIR" ]; then
echo 'Error: Please specify the path to the schema directory in the SCHEMA_DIR variable' >&2
exit 1
fi
if ! [ -x "$(command -v makensis.exe)" ]; then
echo 'Error: Please specify the path to makensis.exe in the PATH' >&2
exit 1
fi
set -e

# First, download the executable and extract it
wget https://github.com/rime/weasel/releases/download/${WEASEL_VERSION}/weasel-${WEASEL_VERSION}.0-installer.exe --no-check-certificate
7z x weasel-${WEASEL_VERSION}.0-installer.exe -aou -ooutput
cd output

# List all files with name ending with `_1`, compare the content of these files and the files with the same names but does not end with `_1` whether these binaries is 32-bit or 64-bit
# Then, move the ones that are 32-bit to the `Win32` folder and remove `_1` from the name of all the files
mkdir Win32
for file in *_1.*; do
extension="${file##*.}"
base_file="${file%_1.*}.$extension"
if [[ $(file "$base_file") != *"x86-64"* ]]; then
mv "$base_file" "Win32/$base_file"
fi
if [[ $(file "$file") == *"x86-64"* ]]; then
mv "$file" "$base_file"
else
mv "$file" "Win32/$base_file"
fi
done

# Remove all default rime schemas but keep opencc data, preview images and app config
# Then, download the latest schemas we need and amend the `default.yaml`
GLOBIGNORE=data/weasel.yaml
rm data/*.*
cp -rf "$SCHEMA_DIR/"* data

# Finally, rebuild the installer
mkdir ../resource
wget https://raw.githubusercontent.com/rime/weasel/refs/tags/${WEASEL_VERSION}/resource/weasel.ico -P ../resource
wget https://raw.githubusercontent.com/rime/weasel/refs/tags/${WEASEL_VERSION}/output/install.nsi
mkdir archives
makensis.exe //DWEASEL_VERSION=$WEASEL_VERSION //DPRODUCT_VERSION=$WEASEL_VERSION install.nsi

# Rename the installer
for file in archives/*.exe; do
mv "$file" "${file/installer/rime-cantonese}"
done
41 changes: 0 additions & 41 deletions .ci/uniqsort.sh

This file was deleted.

Loading

0 comments on commit dd2d361

Please sign in to comment.