init
This commit is contained in:
69
.gitea/workflows/ci.yml
Normal file
69
.gitea/workflows/ci.yml
Normal file
@@ -0,0 +1,69 @@
|
||||
name: CI
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
branches: [main]
|
||||
|
||||
jobs:
|
||||
check:
|
||||
runs-on: linux-amd64
|
||||
container:
|
||||
image: rust:1-bookworm
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Cache cargo registry and build
|
||||
uses: actions/cache@v3
|
||||
with:
|
||||
path: |
|
||||
~/.cargo/registry
|
||||
~/.cargo/git
|
||||
target
|
||||
key: cargo-ci-${{ hashFiles('**/Cargo.lock') }}
|
||||
|
||||
- name: Check formatting
|
||||
run: rustup component add rustfmt && cargo fmt --check
|
||||
|
||||
- name: Clippy
|
||||
run: rustup component add clippy && cargo clippy -- -D warnings
|
||||
|
||||
- name: Test rustitch
|
||||
run: cargo test -p rustitch
|
||||
|
||||
- name: Test stitch-peek
|
||||
run: cargo test -p stitch-peek
|
||||
|
||||
- name: Build
|
||||
run: cargo build --release
|
||||
|
||||
version-check:
|
||||
runs-on: linux-amd64
|
||||
container:
|
||||
image: rust:1-bookworm
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Verify version was bumped
|
||||
run: |
|
||||
PR_VERSION=$(grep -m1 '^version' stitch-peek/Cargo.toml | sed 's/.*"\(.*\)"/\1/')
|
||||
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"
|
||||
echo "Main version: $MAIN_VERSION"
|
||||
|
||||
if [ "$PR_VERSION" = "$MAIN_VERSION" ]; then
|
||||
echo "::error::Version in stitch-peek/Cargo.toml ($PR_VERSION) was not bumped. Please update the version before merging."
|
||||
exit 1
|
||||
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"
|
||||
95
.gitea/workflows/release.yml
Normal file
95
.gitea/workflows/release.yml
Normal file
@@ -0,0 +1,95 @@
|
||||
name: Release
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [main]
|
||||
|
||||
jobs:
|
||||
build-deb:
|
||||
runs-on: linux-amd64
|
||||
container:
|
||||
image: rust:1-bookworm
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Cache cargo registry and build
|
||||
uses: actions/cache@v3
|
||||
with:
|
||||
path: |
|
||||
~/.cargo/registry
|
||||
~/.cargo/git
|
||||
target
|
||||
key: cargo-release-${{ hashFiles('**/Cargo.lock') }}
|
||||
|
||||
- name: Install packaging tools
|
||||
run: apt-get update && apt-get install -y dpkg-dev
|
||||
|
||||
- name: Extract version
|
||||
id: version
|
||||
run: |
|
||||
VERSION=$(grep -m1 '^version' stitch-peek/Cargo.toml | sed 's/.*"\(.*\)"/\1/')
|
||||
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
|
||||
echo "Building version $VERSION"
|
||||
|
||||
- name: Build release binary
|
||||
run: cargo build --release -p stitch-peek
|
||||
|
||||
- name: Run tests
|
||||
run: cargo test --release
|
||||
|
||||
- name: Package .deb
|
||||
env:
|
||||
VERSION: ${{ steps.version.outputs.version }}
|
||||
run: |
|
||||
PKG="stitch-peek_${VERSION}_amd64"
|
||||
|
||||
mkdir -p "${PKG}/DEBIAN"
|
||||
mkdir -p "${PKG}/usr/bin"
|
||||
mkdir -p "${PKG}/usr/share/thumbnailers"
|
||||
mkdir -p "${PKG}/usr/share/mime/packages"
|
||||
|
||||
cp target/release/stitch-peek "${PKG}/usr/bin/"
|
||||
strip "${PKG}/usr/bin/stitch-peek"
|
||||
cp data/stitch-peek.thumbnailer "${PKG}/usr/share/thumbnailers/"
|
||||
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' \
|
||||
"Package: stitch-peek" \
|
||||
"Version: ${VERSION}" \
|
||||
"Section: graphics" \
|
||||
"Priority: optional" \
|
||||
"Architecture: amd64" \
|
||||
"Depends: shared-mime-info" \
|
||||
"Maintainer: stitch-peek contributors" \
|
||||
"Description: Nautilus thumbnail generator for PES embroidery files" \
|
||||
" stitch-peek generates thumbnails for Brother PES embroidery files," \
|
||||
" allowing GNOME/Nautilus to display preview images in the file manager." \
|
||||
> "${PKG}/DEBIAN/control"
|
||||
|
||||
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"
|
||||
chmod 755 "${PKG}/DEBIAN/postinst"
|
||||
|
||||
cp "${PKG}/DEBIAN/postinst" "${PKG}/DEBIAN/postrm"
|
||||
chmod 755 "${PKG}/DEBIAN/postrm"
|
||||
|
||||
dpkg-deb --build "${PKG}"
|
||||
echo "Built: ${PKG}.deb"
|
||||
|
||||
- name: Create git tag
|
||||
env:
|
||||
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
|
||||
uses: actions/gitea-release@v1
|
||||
with:
|
||||
token: ${{ secrets.RELEASE_TOKEN }}
|
||||
tag_name: v${{ steps.version.outputs.version }}
|
||||
title: v${{ steps.version.outputs.version }}
|
||||
files: stitch-peek_${{ steps.version.outputs.version }}_amd64.deb
|
||||
Reference in New Issue
Block a user