Skip to content

fix the name of minimized zip file so it finds it. Also update the up… #347

fix the name of minimized zip file so it finds it. Also update the up…

fix the name of minimized zip file so it finds it. Also update the up… #347

name: automatic-release
on:
push:
branches:
- main
# schedule:
# # * is a special character in YAML so you have to quote this string
# - cron: '0 0 * * 6'
jobs:
l10n:
name: l10n
continue-on-error: true
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v5
- name: Push l10n updates
run: |
git config --global user.name github-actions
git config --global user.email github-actions@github.com
git remote add l10n https://github.com/nvdaaddons/MathCAT
git fetch l10n
git reset l10n/stable addon/doc addon/locale
git commit -m "Update translations" --allow-empty
git pull
git push
zip-rules:
name: zip up the rules directory
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v5
- name: Use matching MathCAT branch if available (fallback to latest)
shell: bash
run: |
# Determine branch/ref for PRs and pushes
if [ -n "${GITHUB_HEAD_REF:-}" ]; then
REF="$GITHUB_HEAD_REF"
else
REF="${GITHUB_REF#refs/heads/}"
fi
echo "Detected ref: $REF"
REMOTE=https://github.com/NSoiffer/MathCAT.git
if git ls-remote --heads "$REMOTE" "$REF" | grep -q "refs/heads/$REF"; then
echo "Using MathCAT branch $REF"
sed -i.bak \
-e "s|mathcat = { path = \"../MathCAT/\" }|mathcat = { git = \"https://github.com/NSoiffer/MathCAT\", branch = \"$REF\" }|" \
-e "s|mathcat = { path = \"../MathCAT/\", features = \[\"include-zip\"\] }|mathcat = { git = \"https://github.com/NSoiffer/MathCAT\", branch = \"$REF\", features = [\"include-zip\"] }|" \
Cargo.toml
else
echo "No matching branch in MathCAT; falling back to latest tag"
VERSION=$(curl -fsSL https://raw.githubusercontent.com/NSoiffer/MathCAT/latest/Cargo.toml \
| sed -n 's/^version = "\(.*\)"/\1/p' | head -n1)
if [ -z "$VERSION" ]; then
echo "Failed to read MathCAT version from latest tag" >&2
exit 1
fi
echo "Syncing package version to MathCAT $VERSION"
sed -i.bak \
-e "/^\[package\]/,/^\[/{s/^version = \".*\"/version = \"$VERSION\"/;}" \
-e 's|mathcat = { path = "../MathCAT/" }|mathcat = { git = "https://github.com/NSoiffer/MathCAT", tag = "latest" }|' \
-e 's|mathcat = { path = "../MathCAT/", features = \["include-zip"\] }|mathcat = { git = "https://github.com/NSoiffer/MathCAT", tag = "latest", features = ["include-zip"] }|' \
Cargo.toml
rm -f Cargo.toml.bak
fi
echo "--- Cargo.toml after sync ---"
cat Cargo.toml
- name: Build Rust Library
run: |
cargo build --target x86_64-unknown-linux-gnu # doesn't need a release build since all that we want is the Rules dir
- name: create rules.zip
uses: thedoctor0/zip-release@0.7.5
with:
type: 'zip'
filename: 'Rules.zip'
directory: 'addon/globalPlugins/MathCAT'
path: 'Rules'
- name: Ensure Rules-minimized.zip exists
run: |
if [ ! -f addon/globalPlugins/MathCAT/Rules-minimized.zip ]; then
cp addon/globalPlugins/MathCAT/Rules.zip addon/globalPlugins/MathCAT/Rules-minimized.zip
echo "Created placeholder Rules-minimized.zip"
else
echo "Rules-minimized.zip already exists"
fi
- name: Upload Rules.zip
uses: actions/upload-artifact@v7
with:
name: 'Rules.zip'
path: 'addon/globalPlugins/MathCAT/Rules.zip'
compression-level: 0
retention-days: 1
- name: Upload Rules-minimized.zip
uses: actions/upload-artifact@v7
with:
name: 'Rules-minimized.zip'
path: 'addon/globalPlugins/MathCAT/Rules-minimized.zip'
compression-level: 0
retention-days: 1
if-no-files-found: ignore
rust-32:
name: Build 32 bit windows pyd file
runs-on: windows-latest # needs to run on windows because of bzip2
steps:
- name: Checkout code
uses: actions/checkout@v5
- name: Use matching MathCAT branch if available (fallback to latest)
shell: bash
run: |
if [ -n "${GITHUB_HEAD_REF:-}" ]; then
REF="$GITHUB_HEAD_REF"
else
REF="${GITHUB_REF#refs/heads/}"
fi
echo "Detected ref: $REF"
REMOTE=https://github.com/NSoiffer/MathCAT.git
if git ls-remote --heads "$REMOTE" "$REF" | grep -q "refs/heads/$REF"; then
echo "Using MathCAT branch $REF"
sed -i.bak \
-e "s|mathcat = { path = \"../MathCAT/\" }|mathcat = { git = \"https://github.com/NSoiffer/MathCAT\", branch = \"$REF\" }|" \
-e "s|mathcat = { path = \"../MathCAT/\", features = \[\"include-zip\"\] }|mathcat = { git = \"https://github.com/NSoiffer/MathCAT\", branch = \"$REF\", features = [\"include-zip\"] }|" \
Cargo.toml
else
echo "No matching branch in MathCAT; falling back to latest tag"
VERSION=$(curl -fsSL https://raw.githubusercontent.com/NSoiffer/MathCAT/latest/Cargo.toml \
| sed -n 's/^version = "\(.*\)"/\1/p' | head -n1)
if [ -z "$VERSION" ]; then
echo "Failed to read MathCAT version from latest tag" >&2
exit 1
fi
echo "Syncing package version to MathCAT $VERSION"
sed -i.bak \
-e "/^\[package\]/,/^\[/{s/^version = \".*\"/version = \"$VERSION\"/;}" \
-e 's|mathcat = { path = "../MathCAT/" }|mathcat = { git = "https://github.com/NSoiffer/MathCAT", tag = "latest" }|' \
-e 's|mathcat = { path = "../MathCAT/", features = \["include-zip"\] }|mathcat = { git = "https://github.com/NSoiffer/MathCAT", tag = "latest", features = ["include-zip"] }|' \
Cargo.toml
rm -f Cargo.toml.bak
fi
echo "--- Cargo.toml after sync ---"
cat Cargo.toml
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: 3.11
architecture: 'x86'
- name: Build Rust Library
run: |
cargo build --target i686-pc-windows-msvc --release
- name: Setup Example dir
run: |
cp target/i686-pc-windows-msvc/release/libmathcat_py.dll Example/libmathcat_py.pyd
mv addon/globalPlugins/MathCAT/Rules Example
- name: test the build
run: |
cd Example
python test.py
- name: create zip file for pyd file -- this allows the name to indicate arch, python version, etc., but unzipped it is correctly named
uses: thedoctor0/zip-release@0.7.5
with:
type: 'zip'
filename: '../libmathcat_py-32-3.11-win.zip'
directory: 'Example'
path: 'libmathcat_py.pyd'
- name: Upload 32 bit pyd file
uses: actions/upload-artifact@v7
with:
name: libmathcat_py-32-3.11-win.zip
path: libmathcat_py-32-3.11-win.zip
compression-level: 0
retention-days: 1
rust-64:
name: Build 64 bit windows pyd file
runs-on: windows-latest # needs to run on windows because of bzip2
steps:
- name: Checkout code
uses: actions/checkout@v5
- name: Use matching MathCAT branch if available (fallback to latest)
shell: bash
run: |
if [ -n "${GITHUB_HEAD_REF:-}" ]; then
REF="$GITHUB_HEAD_REF"
else
REF="${GITHUB_REF#refs/heads/}"
fi
echo "Detected ref: $REF"
REMOTE=https://github.com/NSoiffer/MathCAT.git
if git ls-remote --heads "$REMOTE" "$REF" | grep -q "refs/heads/$REF"; then
echo "Using MathCAT branch $REF"
sed -i.bak \
-e "s|mathcat = { path = \"../MathCAT/\" }|mathcat = { git = \"https://github.com/NSoiffer/MathCAT\", branch = \"$REF\" }|" \
-e "s|mathcat = { path = \"../MathCAT/\", features = \[\"include-zip\"\] }|mathcat = { git = \"https://github.com/NSoiffer/MathCAT\", branch = \"$REF\", features = [\"include-zip\"] }|" \
Cargo.toml
else
echo "No matching branch in MathCAT; falling back to latest tag"
VERSION=$(curl -fsSL https://raw.githubusercontent.com/NSoiffer/MathCAT/latest/Cargo.toml \
| sed -n 's/^version = "\(.*\)"/\1/p' | head -n1)
if [ -z "$VERSION" ]; then
echo "Failed to read MathCAT version from latest tag" >&2
exit 1
fi
echo "Syncing package version to MathCAT $VERSION"
sed -i.bak \
-e "/^\[package\]/,/^\[/{s/^version = \".*\"/version = \"$VERSION\"/;}" \
-e 's|mathcat = { path = "../MathCAT/" }|mathcat = { git = "https://github.com/NSoiffer/MathCAT", tag = "latest" }|' \
-e 's|mathcat = { path = "../MathCAT/", features = \["include-zip"\] }|mathcat = { git = "https://github.com/NSoiffer/MathCAT", tag = "latest", features = ["include-zip"] }|' \
Cargo.toml
rm -f Cargo.toml.bak
fi
echo "--- Cargo.toml after sync ---"
cat Cargo.toml
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: 3.13
architecture: 'x64'
- name: Build Rust Library
run: |
cargo build --target x86_64-pc-windows-msvc --release
- name: Setup Example dir
run: |
cp target/x86_64-pc-windows-msvc/release/libmathcat_py.dll Example/libmathcat_py.pyd
mv addon/globalPlugins/MathCAT/Rules Example
- name: create zip file for pyd file -- this allows the name to indicate arch, python version, etc., but unzipped it is correctly named
uses: thedoctor0/zip-release@0.7.5
with:
type: 'zip'
filename: '../libmathcat_py-64-3.13-win.zip'
directory: 'Example'
path: 'libmathcat_py.pyd'
- name: test the build
run: |
cd Example
python test.py
- name: Upload 64 bit pyd file
uses: actions/upload-artifact@v7
with:
name: libmathcat_py-64-3.13-win.zip
path: libmathcat_py-64-3.13-win.zip
compression-level: 0
retention-days: 1
linux-64:
name: Build linux pyd file (64-bit intel)
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v5
- name: Use matching MathCAT branch if available (fallback to latest)
shell: bash
run: |
if [ -n "${GITHUB_HEAD_REF:-}" ]; then
REF="$GITHUB_HEAD_REF"
else
REF="${GITHUB_REF#refs/heads/}"
fi
echo "Detected ref: $REF"
REMOTE=https://github.com/NSoiffer/MathCAT.git
if git ls-remote --heads "$REMOTE" "$REF" | grep -q "refs/heads/$REF"; then
echo "Using MathCAT branch $REF"
VERSION=$(curl -fsSL https://raw.githubusercontent.com/NSoiffer/MathCAT/$REF/Cargo.toml \
| sed -n 's/^version = "\(.*\)"/\1/p' | head -n1)
if [ -z "$VERSION" ]; then
echo "Failed to read MathCAT version from branch $REF" >&2
exit 1
fi
sed -i.bak \
-e "/^\[package\]/,/^\[/{s/^version = \".*\"/version = \"$VERSION\"/;}" \
-e "s|mathcat = { path = \"../MathCAT/\" }|mathcat = { git = \"https://github.com/NSoiffer/MathCAT\", branch = \"$REF\" }|" \
-e "s|mathcat = { path = \"../MathCAT/\", features = \[\"include-zip\"\] }|mathcat = { git = \"https://github.com/NSoiffer/MathCAT\", branch = \"$REF\", features = [\"include-zip\"] }|" \
Cargo.toml
else
echo "No matching branch in MathCAT; falling back to latest tag"
VERSION=$(curl -fsSL https://raw.githubusercontent.com/NSoiffer/MathCAT/latest/Cargo.toml \
| sed -n 's/^version = "\(.*\)"/\1/p' | head -n1)
if [ -z "$VERSION" ]; then
echo "Failed to read MathCAT version from latest tag" >&2
exit 1
fi
echo "Syncing package version to MathCAT $VERSION"
sed -i.bak \
-e "/^\[package\]/,/^\[/{s/^version = \".*\"/version = \"$VERSION\"/;}" \
-e 's|mathcat = { path = "../MathCAT/" }|mathcat = { git = "https://github.com/NSoiffer/MathCAT", tag = "latest" }|' \
-e 's|mathcat = { path = "../MathCAT/", features = \["include-zip"\] }|mathcat = { git = "https://github.com/NSoiffer/MathCAT", tag = "latest", features = ["include-zip"] }|' \
Cargo.toml
rm -f Cargo.toml.bak
fi
echo "--- Cargo.toml after sync ---"
cat Cargo.toml
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: 3.13
architecture: 'x64'
- name: Build Rust Library
run: |
cargo build --target x86_64-unknown-linux-gnu --release
- name: Setup Example dir
run: |
# don't know why it is "liblib...". For consistancy with other versions, it is renamed.
cp target/x86_64-unknown-linux-gnu/release/liblibmathcat_py.so Example/libmathcat_py.so
cp -r addon/globalPlugins/MathCAT/Rules Example
- name: test build
run: |
cd Example
python test.py
- name: create zip file for pyd file -- this allows the name to indicate arch, python version, etc., but unzipped it is correctly named
uses: thedoctor0/zip-release@0.7.5
with:
type: 'zip'
filename: '../libmathcat_py-64-3.13-linux.zip'
directory: 'Example'
path: 'libmathcat_py.so'
- name: Upload 64 bit pyd file
uses: actions/upload-artifact@v7
with:
name: libmathcat_py-64-3.13-linux.zip
path: libmathcat_py-64-3.13-linux.zip
compression-level: 0
retention-days: 1
build-64-bit-addon:
name: build-64-bit-addon
continue-on-error: false
needs: [l10n, zip-rules, rust-64]
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v5
# download the 64 build
- name: Download 64 bit build
uses: actions/download-artifact@v8
with:
name: libmathcat_py-64-3.13-win.zip
# download the Rules dir (not part of checkout)
- name: Download 64 bit build
uses: actions/download-artifact@v8
with:
name: Rules.zip
- name: Download Rules-minimized.zip
uses: actions/download-artifact@v8
with:
name: Rules-minimized.zip
if-no-files-found: ignore
# put things where they belong
- name: Set up addons dir
run: |
unzip libmathcat_py-64-3.13-win.zip
mv libmathcat_py.pyd Rules.zip addon/globalPlugins/MathCAT
cd addon/globalPlugins/MathCAT
sed 's/^import wx\.xrc/# import wx.xrc/' --in-place MathCATgui.py # fix wx file
unzip Rules.zip
rm Rules.zip
# build the addon
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: 3.13 # needed for scons
- name: Install scons dependencies
run: |
pip install scons markdown
sudo apt update
sudo apt install gettext
- name: Sync addon version from MathCAT (prefer matching branch)
shell: bash
run: |
if [ -n "${GITHUB_HEAD_REF:-}" ]; then
REF="$GITHUB_HEAD_REF"
else
REF="${GITHUB_REF#refs/heads/}"
fi
echo "Detected ref: $REF"
REMOTE=https://github.com/NSoiffer/MathCAT.git
if git ls-remote --heads "$REMOTE" "$REF" | grep -q "refs/heads/$REF"; then
echo "Using MathCAT branch $REF to get version"
VERSION=$(curl -fsSL https://raw.githubusercontent.com/NSoiffer/MathCAT/$REF/Cargo.toml \
| sed -n 's/^version = "\(.*\)"/\1/p' | head -n1)
else
echo "No matching branch in MathCAT; using latest tag"
VERSION=$(curl -fsSL https://raw.githubusercontent.com/NSoiffer/MathCAT/latest/Cargo.toml \
| sed -n 's/^version = "\(.*\)"/\1/p' | head -n1)
fi
if [ -z "$VERSION" ]; then
echo "Failed to read MathCAT version" >&2
exit 1
fi
echo "Syncing addon_version to MathCAT $VERSION"
sed -i "s/\"addon_version\": \"[^\"]*\"/\"addon_version\": \"$VERSION\"/" buildVars.py
- name: Run scons to build .addon file
run: |
scons
- name: Rename addon for 64-bit
run: |
for f in *.nvda-addon; do
mv "$f" "${f%.nvda-addon}-64.nvda-addon"
done
ls -l *.nvda-addon
- name: Upload the addon
uses: actions/upload-artifact@v7
with:
name: addon-64
path: "*.nvda-addon"
compression-level: 0
retention-days: 1
build-32-bit-addon:
name: build-32-bit-addon
continue-on-error: false
needs: [l10n, zip-rules, rust-32]
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v5
# download the 32 build
- name: Download 32 bit build
uses: actions/download-artifact@v8
with:
name: libmathcat_py-32-3.11-win.zip
# download the Rules dir (not part of checkout)
- name: Download 32 bit build
uses: actions/download-artifact@v8
with:
name: Rules.zip
- name: Download Rules-minimized.zip
uses: actions/download-artifact@v8
with:
name: Rules-minimized.zip
if-no-files-found: ignore
# put things where they belong
- name: Set up addons dir
run: |
unzip libmathcat_py-32-3.11-win.zip
mv libmathcat_py.pyd Rules.zip addon/globalPlugins/MathCAT
cd addon/globalPlugins/MathCAT
sed 's/^import wx\.xrc/# import wx.xrc/' --in-place MathCATgui.py # fix wx file
unzip Rules.zip
rm Rules.zip
# build the addon
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: 3.11 # needed for scons
- name: Install scons dependencies
run: |
pip install scons markdown
sudo apt update
sudo apt install gettext
- name: Sync addon version from MathCAT (prefer matching branch)
shell: bash
run: |
if [ -n "${GITHUB_HEAD_REF:-}" ]; then
REF="$GITHUB_HEAD_REF"
else
REF="${GITHUB_REF#refs/heads/}"
fi
echo "Detected ref: $REF"
REMOTE=https://github.com/NSoiffer/MathCAT.git
if git ls-remote --heads "$REMOTE" "$REF" | grep -q "refs/heads/$REF"; then
echo "Using MathCAT branch $REF to get version"
VERSION=$(curl -fsSL https://raw.githubusercontent.com/NSoiffer/MathCAT/$REF/Cargo.toml \
| sed -n 's/^version = "\(.*\)"/\1/p' | head -n1)
else
echo "No matching branch in MathCAT; using latest tag"
VERSION=$(curl -fsSL https://raw.githubusercontent.com/NSoiffer/MathCAT/latest/Cargo.toml \
| sed -n 's/^version = "\(.*\)"/\1/p' | head -n1)
fi
if [ -z "$VERSION" ]; then
echo "Failed to read MathCAT version" >&2
exit 1
fi
echo "Syncing addon_version to MathCAT $VERSION"
sed -i "s/\"addon_version\": \"[^\"]*\"/\"addon_version\": \"$VERSION\"/" buildVars.py
- name: Update NVDA Version Constraints
run: |
# Adjust the version numbers for the old 32 bit NVDA version
sed -i 's/"addon_name": "MathCAT"/"addon_name": "MathCAT-for-NVDA2025"/' buildVars.py
sed -i 's/"addon_summary": _("MathCAT:/"addon_summary": _("MathCAT-for-NVDA2025:/' buildVars.py
sed -i 's/"addon_minimumNVDAVersion": "[^"]*"/"addon_minimumNVDAVersion": "2025.1"/' buildVars.py
sed -i 's/"addon_lastTestedNVDAVersion": "[^"]*"/"addon_lastTestedNVDAVersion": "2025.3"/' buildVars.py
cat buildVars.py
- name: Run scons to build .addon file
run: |
scons
- name: Rename addon for 32-bit
run: |
for f in *.nvda-addon; do
mv "$f" "${f%.nvda-addon}-32.nvda-addon"
done
ls -l *.nvda-addon
- name: Upload the addon
uses: actions/upload-artifact@v7
with:
name: addon-32
path: "*.nvda-addon"
compression-level: 0
retention-days: 1
pre-release:
name: Pre Release
continue-on-error: false
needs: [zip-rules, rust-32, rust-64, linux-64, build-32-bit-addon, build-64-bit-addon]
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v5
# download the previous build artifacts and put them in their proper places
- name: Download Rules.zip
uses: actions/download-artifact@v8
with:
name: Rules.zip
- name: Download Rules-minimized.zip
uses: actions/download-artifact@v8
with:
name: Rules-minimized.zip
if-no-files-found: ignore
- name: Download 32 bit build
uses: actions/download-artifact@v8
with:
name: libmathcat_py-32-3.11-win.zip
- name: Download 64 bit build
uses: actions/download-artifact@v8
with:
name: libmathcat_py-64-3.13-win.zip
- name: Download 64 bit linux build
uses: actions/download-artifact@v8
with:
name: libmathcat_py-64-3.13-linux.zip
- name: Download 64-bit addon
uses: actions/download-artifact@v8
with:
name: addon-64
- name: Download 32-bit addon
uses: actions/download-artifact@v8
with:
name: addon-32
- name: Consolidate addon files
run: |
mv addon-64/*.nvda-addon . 2>/dev/null || true
mv addon-32/*.nvda-addon . 2>/dev/null || true
- name: Get MathCAT version for release title
id: mathcat-version
shell: bash
run: |
if [ -n "${GITHUB_HEAD_REF:-}" ]; then
REF="$GITHUB_HEAD_REF"
else
REF="${GITHUB_REF#refs/heads/}"
fi
echo "Detected ref: $REF"
REMOTE=https://github.com/NSoiffer/MathCAT.git
if git ls-remote --heads "$REMOTE" "$REF" | grep -q "refs/heads/$REF"; then
echo "Using MathCAT branch $REF to get version"
VERSION=$(curl -fsSL https://raw.githubusercontent.com/NSoiffer/MathCAT/$REF/Cargo.toml \
| sed -n 's/^version = "\(.*\)"/\1/p' | head -n1)
else
echo "No matching branch in MathCAT; using latest tag"
VERSION=$(curl -fsSL https://raw.githubusercontent.com/NSoiffer/MathCAT/latest/Cargo.toml \
| sed -n 's/^version = "\(.*\)"/\1/p' | head -n1)
fi
if [ -z "$VERSION" ]; then
echo "Failed to read MathCAT version" >&2
exit 1
fi
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
# put the files into the release
- name: Automatic release
uses: marvinpinto/action-automatic-releases@latest
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
automatic_release_tag: latest
prerelease: true
title: Development Build (using version ${{ steps.mathcat-version.outputs.version }})
files: |
*.nvda-addon
libmathcat_py-32-3.11-win.zip
libmathcat_py-64-3.13-win.zip
libmathcat_py-64-3.13-linux.zip
Rules.zip
Rules-minimized.zip