3 Commits

Author SHA1 Message Date
nvrl 27b97a69a7 fixed tooling in ci
CI / Lint and Test (pull_request) Successful in 36s
CI / Version Check (pull_request) Failing after 3s
2026-03-30 00:32:24 +02:00
nvrl e98ff143a1 cargo fmt
CI / Lint and Test (pull_request) Successful in 37s
CI / Version Check (pull_request) Failing after 3s
2026-03-30 00:30:51 +02:00
nvrl ecc7ef519f fixed workflow
CI / Lint and Test (pull_request) Failing after 53s
CI / Version Check (pull_request) Failing after 3s
2026-03-30 00:29:38 +02:00
5 changed files with 158 additions and 146 deletions
+29 -35
View File
@@ -2,30 +2,29 @@ name: CI
on: on:
pull_request: pull_request:
branches: [main] branches:
- main
jobs: jobs:
check: check:
runs-on: linux-amd64 name: Lint and Test
container: runs-on: ubuntu-latest
image: rust:1-bookworm
steps: steps:
- uses: actions/checkout@v4 - name: Checkout code
uses: actions/checkout@v4
- name: Cache cargo registry and build - name: Install Rust
uses: actions/cache@v3 uses: actions-rust-lang/setup-rust-toolchain@v1
with: with:
path: | toolchain: stable
~/.cargo/registry components: rustfmt, clippy
~/.cargo/git cache: false
target
key: cargo-ci-${{ hashFiles('**/Cargo.lock') }}
- name: Check formatting - name: Check formatting
run: rustup component add rustfmt && cargo fmt --check run: cargo fmt --check
- name: Clippy - name: Clippy
run: rustup component add clippy && cargo clippy -- -D warnings run: cargo clippy -- -D warnings
- name: Test rustitch - name: Test rustitch
run: cargo test -p rustitch run: cargo test -p rustitch
@@ -37,33 +36,28 @@ jobs:
run: cargo build --release run: cargo build --release
version-check: version-check:
runs-on: linux-amd64 name: Version Check
container: runs-on: ubuntu-latest
image: rust:1-bookworm
steps: steps:
- uses: actions/checkout@v4 - name: Checkout repository
uses: actions/checkout@v4
with: with:
fetch-depth: 0 fetch-depth: 0
- name: Verify version was bumped - name: Compare versions
shell: bash
run: | run: |
PR_VERSION=$(grep -m1 '^version' stitch-peek/Cargo.toml | sed 's/.*"\(.*\)"/\1/') NEW_VERSION=$(grep -m1 '^version =' stitch-peek/Cargo.toml | cut -d '"' -f 2)
git fetch origin main
MAIN_VERSION=$(git show origin/main:stitch-peek/Cargo.toml | grep -m1 '^version' | sed 's/.*"\(.*\)"/\1/')
echo "PR version: $PR_VERSION" git fetch origin ${{ github.base_ref }}
echo "Main version: $MAIN_VERSION" OLD_VERSION=$(git show origin/${{ github.base_ref }}:stitch-peek/Cargo.toml | grep -m1 '^version =' | cut -d '"' -f 2)
if [ "$PR_VERSION" = "$MAIN_VERSION" ]; then echo "Old version (main): $OLD_VERSION"
echo "::error::Version in stitch-peek/Cargo.toml ($PR_VERSION) was not bumped. Please update the version before merging." echo "New version (PR): $NEW_VERSION"
if [ "$NEW_VERSION" = "$OLD_VERSION" ]; then
echo "Error: stitch-peek/Cargo.toml version has not been updated in this PR!"
exit 1 exit 1
else
echo "Success: Version updated from $OLD_VERSION to $NEW_VERSION"
fi fi
# Ensure the new version is actually newer (basic semver compare)
printf '%s\n%s' "$MAIN_VERSION" "$PR_VERSION" | sort -V | tail -1 | grep -qx "$PR_VERSION"
if [ $? -ne 0 ]; then
echo "::error::PR version ($PR_VERSION) is not newer than main ($MAIN_VERSION)."
exit 1
fi
echo "Version bump verified: $MAIN_VERSION -> $PR_VERSION"
+61 -39
View File
@@ -2,44 +2,67 @@ name: Release
on: on:
push: push:
branches: [main] branches:
- main
tags:
- 'v*'
jobs: jobs:
build-deb: build:
runs-on: linux-amd64 name: Build and Release
container: runs-on: ubuntu-latest
image: rust:1-bookworm
steps: steps:
- uses: actions/checkout@v4 - name: Checkout code
uses: actions/checkout@v4
- name: Cache cargo registry and build - name: Install Rust
uses: actions/cache@v3 uses: actions-rust-lang/setup-rust-toolchain@v1
with: with:
path: | toolchain: stable
~/.cargo/registry cache: false
~/.cargo/git
target
key: cargo-release-${{ hashFiles('**/Cargo.lock') }}
- name: Install packaging tools - name: Install packaging tools
run: apt-get update && apt-get install -y dpkg-dev run: apt-get update && apt-get install -y dpkg-dev
- name: Extract version - name: Get Version
id: version id: get_version
run: | run: |
VERSION=$(grep -m1 '^version' stitch-peek/Cargo.toml | sed 's/.*"\(.*\)"/\1/') VERSION=$(grep -m1 '^version =' stitch-peek/Cargo.toml | cut -d '"' -f 2)
echo "version=$VERSION" >> "$GITHUB_OUTPUT" echo "VERSION=$VERSION" >> $GITHUB_OUTPUT
echo "Building version $VERSION" if [[ "${{ github.ref }}" == refs/tags/v* ]]; then
echo "TAG=${{ github.ref_name }}" >> $GITHUB_OUTPUT
else
echo "TAG=v$VERSION" >> $GITHUB_OUTPUT
fi
- name: Build release binary - name: Check if Release Exists
id: check_release
shell: bash
run: |
HTTP_STATUS=$(curl -s -o /dev/null -w "%{http_code}" \
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
"${{ github.server_url }}/api/v1/repos/${{ github.repository }}/releases/tags/${{ steps.get_version.outputs.TAG }}")
if [ "$HTTP_STATUS" = "200" ]; then
echo "EXISTS=true" >> $GITHUB_OUTPUT
echo "Release already exists for tag ${{ steps.get_version.outputs.TAG }}. Skipping."
else
echo "EXISTS=false" >> $GITHUB_OUTPUT
fi
- name: Build
if: steps.check_release.outputs.EXISTS == 'false'
run: cargo build --release -p stitch-peek run: cargo build --release -p stitch-peek
- name: Run tests - name: Test
run: cargo test --release if: steps.check_release.outputs.EXISTS == 'false'
run: cargo test
- name: Package .deb - name: Package .deb
if: steps.check_release.outputs.EXISTS == 'false'
env: env:
VERSION: ${{ steps.version.outputs.version }} VERSION: ${{ steps.get_version.outputs.VERSION }}
TAG: ${{ steps.get_version.outputs.TAG }}
run: | run: |
PKG="stitch-peek_${VERSION}_amd64" PKG="stitch-peek_${VERSION}_amd64"
@@ -53,7 +76,6 @@ jobs:
cp data/stitch-peek.thumbnailer "${PKG}/usr/share/thumbnailers/" cp data/stitch-peek.thumbnailer "${PKG}/usr/share/thumbnailers/"
cp data/pes.xml "${PKG}/usr/share/mime/packages/" cp data/pes.xml "${PKG}/usr/share/mime/packages/"
# Control file -- fields must start at column 0, continuation lines start with a space
printf '%s\n' \ printf '%s\n' \
"Package: stitch-peek" \ "Package: stitch-peek" \
"Version: ${VERSION}" \ "Version: ${VERSION}" \
@@ -70,26 +92,26 @@ jobs:
printf '#!/bin/sh\nset -e\nif command -v update-mime-database >/dev/null 2>&1; then\n update-mime-database /usr/share/mime\nfi\n' \ printf '#!/bin/sh\nset -e\nif command -v update-mime-database >/dev/null 2>&1; then\n update-mime-database /usr/share/mime\nfi\n' \
> "${PKG}/DEBIAN/postinst" > "${PKG}/DEBIAN/postinst"
chmod 755 "${PKG}/DEBIAN/postinst" chmod 755 "${PKG}/DEBIAN/postinst"
cp "${PKG}/DEBIAN/postinst" "${PKG}/DEBIAN/postrm" cp "${PKG}/DEBIAN/postinst" "${PKG}/DEBIAN/postrm"
chmod 755 "${PKG}/DEBIAN/postrm" chmod 755 "${PKG}/DEBIAN/postrm"
dpkg-deb --build "${PKG}" dpkg-deb --build "${PKG}"
echo "Built: ${PKG}.deb"
- name: Create git tag mv "${PKG}.deb" "stitch-peek-${TAG}-amd64.deb"
env: echo "Built: stitch-peek-${TAG}-amd64.deb"
VERSION: ${{ steps.version.outputs.version }}
run: |
git config user.name "Gitea CI"
git config user.email "ci@noreply.localhost"
git tag -a "v${VERSION}" -m "Release v${VERSION}"
git push origin "v${VERSION}"
- name: Create release - name: Create Release and Upload Asset
uses: actions/gitea-release@v1 if: steps.check_release.outputs.EXISTS == 'false'
uses: https://github.com/softprops/action-gh-release@v1
with: with:
token: ${{ secrets.RELEASE_TOKEN }} tag_name: ${{ steps.get_version.outputs.TAG }}
tag_name: v${{ steps.version.outputs.version }} name: Release ${{ steps.get_version.outputs.TAG }}
title: v${{ steps.version.outputs.version }} body: |
files: stitch-peek_${{ steps.version.outputs.version }}_amd64.deb Automated release for version ${{ steps.get_version.outputs.VERSION }}
Commit: ${{ github.sha }}
Branch: ${{ github.ref_name }}
files: stitch-peek-${{ steps.get_version.outputs.TAG }}-amd64.deb
draft: false
prerelease: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+65 -65
View File
@@ -1,69 +1,69 @@
/// Brother PEC thread color palette (65 entries). /// Brother PEC thread color palette (65 entries).
/// Index 0 is a fallback; indices 164 correspond to standard Brother thread colors. /// Index 0 is a fallback; indices 164 correspond to standard Brother thread colors.
pub const PEC_PALETTE: [(u8, u8, u8); 65] = [ pub const PEC_PALETTE: [(u8, u8, u8); 65] = [
(0, 0, 0), // 0: Unknown (0, 0, 0), // 0: Unknown
(14, 31, 124), // 1: Prussian Blue (14, 31, 124), // 1: Prussian Blue
(10, 85, 163), // 2: Blue (10, 85, 163), // 2: Blue
(0, 135, 119), // 3: Teal Green (0, 135, 119), // 3: Teal Green
(75, 107, 175), // 4: Cornflower Blue (75, 107, 175), // 4: Cornflower Blue
(237, 23, 31), // 5: Red (237, 23, 31), // 5: Red
(209, 92, 0), // 6: Reddish Brown (209, 92, 0), // 6: Reddish Brown
(145, 54, 151), // 7: Magenta (145, 54, 151), // 7: Magenta
(228, 154, 203), // 8: Light Lilac (228, 154, 203), // 8: Light Lilac
(145, 95, 172), // 9: Lilac (145, 95, 172), // 9: Lilac
(158, 214, 125), // 10: Mint Green (158, 214, 125), // 10: Mint Green
(232, 169, 0), // 11: Deep Gold (232, 169, 0), // 11: Deep Gold
(254, 186, 53), // 12: Orange (254, 186, 53), // 12: Orange
(255, 255, 0), // 13: Yellow (255, 255, 0), // 13: Yellow
(112, 188, 31), // 14: Lime Green (112, 188, 31), // 14: Lime Green
(186, 152, 0), // 15: Brass (186, 152, 0), // 15: Brass
(168, 168, 168), // 16: Silver (168, 168, 168), // 16: Silver
(125, 111, 0), // 17: Russet Brown (125, 111, 0), // 17: Russet Brown
(255, 255, 179), // 18: Cream Brown (255, 255, 179), // 18: Cream Brown
(79, 85, 86), // 19: Pewter (79, 85, 86), // 19: Pewter
(0, 0, 0), // 20: Black (0, 0, 0), // 20: Black
(11, 61, 145), // 21: Ultramarine (11, 61, 145), // 21: Ultramarine
(119, 1, 118), // 22: Royal Purple (119, 1, 118), // 22: Royal Purple
(41, 49, 51), // 23: Dark Gray (41, 49, 51), // 23: Dark Gray
(42, 19, 1), // 24: Dark Brown (42, 19, 1), // 24: Dark Brown
(246, 74, 138), // 25: Deep Rose (246, 74, 138), // 25: Deep Rose
(178, 118, 36), // 26: Light Brown (178, 118, 36), // 26: Light Brown
(252, 187, 197), // 27: Salmon Pink (252, 187, 197), // 27: Salmon Pink
(254, 55, 15), // 28: Vermilion (254, 55, 15), // 28: Vermilion
(240, 240, 240), // 29: White (240, 240, 240), // 29: White
(106, 28, 138), // 30: Violet (106, 28, 138), // 30: Violet
(168, 221, 196), // 31: Seacrest (168, 221, 196), // 31: Seacrest
(37, 132, 187), // 32: Sky Blue (37, 132, 187), // 32: Sky Blue
(254, 179, 67), // 33: Pumpkin (254, 179, 67), // 33: Pumpkin
(255, 243, 107), // 34: Cream Yellow (255, 243, 107), // 34: Cream Yellow
(208, 166, 96), // 35: Khaki (208, 166, 96), // 35: Khaki
(209, 84, 0), // 36: Clay Brown (209, 84, 0), // 36: Clay Brown
(102, 186, 73), // 37: Leaf Green (102, 186, 73), // 37: Leaf Green
(19, 74, 70), // 38: Peacock Blue (19, 74, 70), // 38: Peacock Blue
(135, 135, 135), // 39: Gray (135, 135, 135), // 39: Gray
(216, 204, 198), // 40: Warm Gray (216, 204, 198), // 40: Warm Gray
(67, 86, 7), // 41: Dark Olive (67, 86, 7), // 41: Dark Olive
(253, 217, 222), // 42: Flesh Pink (253, 217, 222), // 42: Flesh Pink
(249, 147, 188), // 43: Pink (249, 147, 188), // 43: Pink
(0, 56, 34), // 44: Deep Green (0, 56, 34), // 44: Deep Green
(178, 175, 212), // 45: Lavender (178, 175, 212), // 45: Lavender
(104, 106, 176), // 46: Wisteria Violet (104, 106, 176), // 46: Wisteria Violet
(239, 227, 185), // 47: Beige (239, 227, 185), // 47: Beige
(247, 56, 102), // 48: Carmine (247, 56, 102), // 48: Carmine
(181, 75, 100), // 49: Amber Red (181, 75, 100), // 49: Amber Red
(19, 43, 26), // 50: Olive Green (19, 43, 26), // 50: Olive Green
(199, 1, 86), // 51: Dark Fuchsia (199, 1, 86), // 51: Dark Fuchsia
(254, 158, 50), // 52: Tangerine (254, 158, 50), // 52: Tangerine
(168, 222, 235), // 53: Light Blue (168, 222, 235), // 53: Light Blue
(0, 103, 62), // 54: Emerald Green (0, 103, 62), // 54: Emerald Green
(78, 41, 144), // 55: Purple (78, 41, 144), // 55: Purple
(47, 126, 32), // 56: Moss Green (47, 126, 32), // 56: Moss Green
(255, 204, 204), // 57: Flesh Pink (255, 204, 204), // 57: Flesh Pink
(255, 217, 17), // 58: Harvest Gold (255, 217, 17), // 58: Harvest Gold
(9, 91, 166), // 59: Electric Blue (9, 91, 166), // 59: Electric Blue
(240, 249, 112), // 60: Lemon Yellow (240, 249, 112), // 60: Lemon Yellow
(227, 243, 91), // 61: Fresh Green (227, 243, 91), // 61: Fresh Green
(255, 153, 0), // 62: Orange (255, 153, 0), // 62: Orange
(255, 240, 141), // 63: Cream Yellow (255, 240, 141), // 63: Cream Yellow
(255, 200, 200), // 64: Applique (255, 200, 200), // 64: Applique
]; ];
+1 -5
View File
@@ -173,11 +173,7 @@ fn decode_coordinate(data: &[u8], pos: usize) -> Result<(i16, u8, usize), Error>
Ok((value, flags, 2)) Ok((value, flags, 2))
} else { } else {
// 7-bit encoding (1 byte) // 7-bit encoding (1 byte)
let value = if b > 0x3F { let value = if b > 0x3F { b as i16 - 0x80 } else { b as i16 };
b as i16 - 0x80
} else {
b as i16
};
Ok((value, 0, 1)) Ok((value, 0, 1))
} }
} }
+2 -2
View File
@@ -24,8 +24,8 @@ fn main() -> Result<()> {
let data = fs::read(&args.input) let data = fs::read(&args.input)
.with_context(|| format!("failed to read {}", args.input.display()))?; .with_context(|| format!("failed to read {}", args.input.display()))?;
let png = rustitch::thumbnail(&data, args.size) let png =
.with_context(|| "failed to generate thumbnail")?; rustitch::thumbnail(&data, args.size).with_context(|| "failed to generate thumbnail")?;
fs::write(&args.output, &png) fs::write(&args.output, &png)
.with_context(|| format!("failed to write {}", args.output.display()))?; .with_context(|| format!("failed to write {}", args.output.display()))?;