文件
ParlzPackageManger/.github/workflows/release.yml
T
JGZYES 5a7d325f25 i18n: .pjson language-pack system + PMM output standard
- docs/STANDARD.md: unified banner (PMM <ver> (<arch>)), command wording,
  help layout, CHANGELOG and .pjson key-naming conventions.
- src/i18n.c/.h: pmm_tr / pmm_tr_fmt / pmm_lang_load(_active) / set_locale with
  LANG|LC_ALL auto-detect, loading a flattened key->value .pjson from
  ~/.pmm/lang/<locale>.pjson.
- pmm setting lang -l | <locale>: list installed packs; download <locale>.pjson
  from the registry mirror into ~/.pmm/lang/, persist language=<locale> in
  pmm.conf and reload. PmmConfig gains a language field (read from json/ini/conf).
- Banner + version now standardised: PMM 0.3.5 (amd64) (no OS name / brackets).
- web/mirror/lang/{zh-CN,en-US}.pjson built-in packs; web/translate.php lists
  packs (keys + download) and explains community contribution; nav now has a
  翻译 item.
- Makefile/build.bat/release.yml include src/i18n.c.

Verified on WSL: compiles; version/help banner -> 'PMM 0.3.5 (amd64)';
pmm setting lang -l lists the packs dir.
2026-09-04 21:49:02 +08:00

179 行
7.4 KiB
YAML

name: build
on:
push:
tags:
- 'v*'
workflow_dispatch:
inputs:
version:
description: 'Version to build (defaults to dev)'
required: false
default: dev
permissions:
contents: write
jobs:
build:
strategy:
fail-fast: false
matrix:
include:
- target: windows-amd64
cc: x86_64-w64-mingw32-gcc
ext: .exe
pkg: mingw-w64
- target: linux-amd64
cc: gcc
ext: ''
pkg: ''
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install toolchain
if: ${{ matrix.pkg != '' }}
run: |
sudo apt-get update
sudo apt-get install -y ${{ matrix.pkg }}
- name: Build pmm
run: |
mkdir -p out
VER=${{ github.ref_type == 'tag' && github.ref_name || (github.event.inputs.version != '' && github.event.inputs.version || 'dev') }}
VER=${VER#v}
${{ matrix.cc }} -O2 -Wall -static -std=c11 -D_FORTIFY_SOURCE=0 -U_FORTIFY_SOURCE -DPMM_VERSION=\"$VER\" -o out/pmm${{ matrix.ext }} \
src/main.c src/json.c src/ini.c src/pmm.c src/http.c src/repo.c src/install.c \
src/sha256.c src/sha1.c src/mirrors.c src/pdm.c src/out.c src/i18n.c
- name: Package installers
run: |
sudo apt-get update >/dev/null 2>&1
sudo apt-get install -y zip dpkg-dev xxd rpm zstd imagemagick >/dev/null 2>&1 || true
VER=${{ github.ref_type == 'tag' && github.ref_name || (github.event.inputs.version != '' && github.event.inputs.version || 'dev') }}
VER=${VER#v}
# -- install.sh helper (uploaded to the release, also served at /install.sh)
cp web/install.sh out/install.sh
# -- Windows: ZIP
if [ -f out/pmm.exe ]; then
( cd out && zip -q "pmm-${VER}-windows-amd64.zip" pmm.exe )
fi
# -- Linux: .deb
if [ -f out/pmm ]; then
rm -rf pkg && mkdir -p pkg/DEBIAN pkg/usr/local/bin
cp out/pmm pkg/usr/local/bin/pmm
SIZE=$(du -k pkg/usr/local/bin/pmm | cut -f1)
DEBVER="$VER"
case "$DEBVER" in [0-9]*) ;; *) DEBVER="0.0.0-dev" ;; esac # dpkg needs a digit-leading version
{
echo "Package: pmm"
echo "Version: $DEBVER"
echo "Section: devel"
echo "Priority: optional"
echo "Architecture: amd64"
echo "Maintainer: PMM <packages@pmm.dev>"
echo "Installed-Size: $SIZE"
echo "Description: ParlzPackageManager (PMM) - cross-platform C package manager"
echo " A cross-platform (Windows/Linux/macOS) package manager written in C, with"
echo " apt-style multi-mirror (mirror.ini), git release installs, .pdm packages"
echo " and SHA-256/SHA-1 verification."
} > pkg/DEBIAN/control
( cd pkg/usr/local/bin && md5sum pmm ) | sed 's# pmm# usr/local/bin/pmm#' > pkg/DEBIAN/md5sums
dpkg-deb --build -Zgzip --root-owner-group pkg "out/pmm_${VER}_amd64.deb"
rm -rf pkg
# -- Linux: .rpm
mkdir -p rpms/{BUILD,RPMS,SOURCES,SPECS}
cp out/pmm rpms/SOURCES/pmm
{
echo "Name: pmm"
echo "Version: $VER"
echo "Release: 1"
echo "Summary: ParlzPackageManager (PMM) - cross-platform C package manager"
echo "License: GPL-3.0"
echo "BuildArch: x86_64"
echo ""
echo "%description"
echo "A cross-platform (Windows/Linux/macOS) package manager written in C,"
echo "with apt-style multi-mirror, git release installs and .pdm packages."
echo "%install"
echo "mkdir -p %{buildroot}/usr/local/bin"
echo "install -m 0755 %{_sourcedir}/pmm %{buildroot}/usr/local/bin/pmm"
echo "%files"
echo "/usr/local/bin/pmm"
} > rpms/SPECS/pmm.spec
rpmbuild -bb --define "_topdir $PWD/rpms" --define "_sourcedir $PWD/rpms/SOURCES" rpms/SPECS/pmm.spec
find rpms -name '*.rpm' -exec mv {} out/ \;
rm -rf rpms
# -- Alpine .apk (gzip'd tar: .PKGINFO + usr/bin/pmm)
rm -rf apk && mkdir -p apk/usr/bin
cp out/pmm apk/usr/bin/pmm
{
echo "pkgname = pmm"
echo "pkgver = $VER"
echo "pkgdesc = ParlzPackageManager (PMM) - cross-platform C package manager"
echo "url = https://pmm.parlz.com"
echo "arch = x86_64"
echo "license = GPL-3.0"
echo "size = $(stat -c%s out/pmm)"
} > apk/.PKGINFO
( cd apk && tar -czf "../out/pmm-${VER}.apk" .PKGINFO usr )
rm -rf apk
# -- Arch .pkg.tar.zst (tar zstd: .PKGINFO + usr/bin/pmm)
rm -rf pk && mkdir -p pk/usr/bin
cp out/pmm pk/usr/bin/pmm
{
echo "pkgname = pmm"
echo "pkgver = $VER-1"
echo "pkgdesc = ParlzPackageManager (PMM)"
echo "url = https://pmm.parlz.com"
echo "arch = x86_64"
echo "license = GPL-3.0"
} > pk/.PKGINFO
( cd pk && tar --use-compress-program=zstd -cf "../out/pmm-${VER}-1-x86_64.pkg.tar.zst" .PKGINFO usr )
rm -rf pk
# -- AppImage (single-file): AppDir + appimagetool
rm -rf AppDir && mkdir -p AppDir/usr/bin AppDir/usr/share/applications AppDir/usr/share/icons/hicolor/256x256/apps
cp out/pmm AppDir/usr/bin/pmm
printf '#!/bin/sh\nSELF=$(readlink -f "$0"); APPDIR=$(dirname "$SELF")\nexec "$APPDIR/usr/bin/pmm" "$@"\n' > AppDir/AppRun
chmod +x AppDir/AppRun
printf '[Desktop Entry]\nName=PMM\nExec=pmm\nType=Application\nIcon=pmm\nCategories=Development;\n' > AppDir/usr/share/applications/pmm.desktop
if command -v convert >/dev/null 2>&1; then
convert -size 256x256 xc:"#111111" -fill white -pointsize 90 -gravity center -annotate 0 "pmm" \
AppDir/usr/share/icons/hicolor/256x256/apps/pmm.png 2>/dev/null || true
fi
if [ ! -s AppDir/usr/share/icons/hicolor/256x256/apps/pmm.png ]; then
printf 'iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNk+M8AAAMBAQDJ/aLvAAAAAElFTkSuQmCC' | base64 -d > AppDir/usr/share/icons/hicolor/256x256/apps/pmm.png 2>/dev/null || true
fi
if [ ! -x /tmp/appimagetool ]; then
curl -fsSL -o /tmp/appimagetool https://github.com/AppImage/appimagetool/releases/download/continuous/appimagetool-x86_64.AppImage 2>/dev/null || true
chmod +x /tmp/appimagetool 2>/dev/null || true
fi
if [ -x /tmp/appimagetool ]; then
( cd AppDir && /tmp/appimagetool --appimage-extract-and-run -n . "../out/pmm-${VER}-x86_64.AppImage" 2>/dev/null ) || true
fi
rm -rf AppDir
fi
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.target }}
path: out/*
if-no-files-found: error
- name: Release (tagged)
if: startsWith(github.ref, 'refs/tags/')
uses: softprops/action-gh-release@v2
with:
files: out/*
generate_release_notes: true
name: PMM ${{ github.ref_name }}