version: support -DPMM_VERSION injection; workflow builds with tag version (fix pmm -v always 0.1.0)

这个提交包含在:
JGZYES
2026-08-31 22:10:34 +08:00
父节点 ad2c834c7b
当前提交 4cab1dfce9
修改 2 个文件,包含 10 行新增2 行删除
+3 -1
查看文件
@@ -36,7 +36,9 @@ jobs:
- name: Build pmm - name: Build pmm
run: | run: |
mkdir -p out mkdir -p out
${{ matrix.cc }} -O2 -Wall -static -std=c11 -o out/pmm${{ matrix.ext }} \ VER=${{ github.ref_type == 'tag' && github.ref_name || 'dev' }}
VER=${VER#v}
${{ matrix.cc }} -O2 -Wall -static -std=c11 -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/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/sha256.c src/sha1.c src/mirrors.c src/pdm.c
+7 -1
查看文件
@@ -13,6 +13,10 @@ void pmm_add_to_path(void);
* clears back to the user-home default. Persisted across runs. */ * clears back to the user-home default. Persisted across runs. */
void pmm_set_install_drive(const char *letter); void pmm_set_install_drive(const char *letter);
/* Set the install location to an exact absolute path (e.g. "D:\apps\pmm" or
* "/opt/pmm"). Config/cache/bin/root all live under it. Empty clears back. */
void pmm_set_install_path(const char *path);
/* File-association record written to the per-user registry on install. */ /* File-association record written to the per-user registry on install. */
typedef struct { typedef struct {
const char *progid; /* e.g. "Node.JSFile" */ const char *progid; /* e.g. "Node.JSFile" */
@@ -41,7 +45,9 @@ void pmm_reg_uninstall_clear(const char *pkg);
void pmm_set_self_path(const char *argv0); void pmm_set_self_path(const char *argv0);
const char *pmm_self_path(void); const char *pmm_self_path(void);
#define PMM_VERSION "0.1.0" #ifndef PMM_VERSION
#define PMM_VERSION "0.1.0" /* overridden at build time with -DPMM_VERSION="..." */
#endif
typedef enum { OS_WINDOWS, OS_LINUX, OS_MACOS, OS_UNKNOWN } PmmOS; typedef enum { OS_WINDOWS, OS_LINUX, OS_MACOS, OS_UNKNOWN } PmmOS;