mirror of
https://github.com/langbot-app/LangBot.git
synced 2026-09-12 04:47:14 +00:00
Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 02a71c9548 |
@@ -2,6 +2,11 @@ name: Build and Publish to PyPI
|
|||||||
|
|
||||||
on:
|
on:
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
|
inputs:
|
||||||
|
source_ref:
|
||||||
|
description: 'Existing release tag to publish (for example v4.10.11)'
|
||||||
|
required: true
|
||||||
|
type: string
|
||||||
release:
|
release:
|
||||||
types: [published]
|
types: [published]
|
||||||
|
|
||||||
@@ -11,13 +16,39 @@ jobs:
|
|||||||
permissions:
|
permissions:
|
||||||
contents: read
|
contents: read
|
||||||
id-token: write # Required for trusted publishing to PyPI
|
id-token: write # Required for trusted publishing to PyPI
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout code
|
- name: Checkout code
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
with:
|
with:
|
||||||
|
ref: ${{ inputs.source_ref || github.sha }}
|
||||||
|
fetch-depth: 0
|
||||||
persist-credentials: false
|
persist-credentials: false
|
||||||
|
|
||||||
|
- name: Validate release source and version
|
||||||
|
env:
|
||||||
|
RELEASE_TAG: ${{ inputs.source_ref || github.event.release.tag_name }}
|
||||||
|
run: |
|
||||||
|
python3 - <<'PY'
|
||||||
|
import os
|
||||||
|
import re
|
||||||
|
import subprocess
|
||||||
|
import tomllib
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
|
tag = os.environ['RELEASE_TAG']
|
||||||
|
if not re.fullmatch(r'v[0-9]+\.[0-9]+\.[0-9]+', tag):
|
||||||
|
raise SystemExit('source_ref must be an existing release tag: vX.Y.Z')
|
||||||
|
def revision(ref):
|
||||||
|
return subprocess.check_output(['git', 'rev-parse', '--verify', ref], text=True).strip()
|
||||||
|
if revision('HEAD') != revision(f'refs/tags/{tag}^{{}}'):
|
||||||
|
raise SystemExit('Checked-out commit does not match the release tag')
|
||||||
|
version = tomllib.loads(Path('pyproject.toml').read_text())['project']['version']
|
||||||
|
if version != tag[1:]:
|
||||||
|
raise SystemExit(f'Package version {version} does not match tag {tag}')
|
||||||
|
print(f'Validated {tag} at {revision("HEAD")} (package {version})')
|
||||||
|
PY
|
||||||
|
|
||||||
- name: Set up Node.js
|
- name: Set up Node.js
|
||||||
uses: actions/setup-node@v4
|
uses: actions/setup-node@v4
|
||||||
with:
|
with:
|
||||||
@@ -26,9 +57,9 @@ jobs:
|
|||||||
- name: Build frontend
|
- name: Build frontend
|
||||||
run: |
|
run: |
|
||||||
cd web
|
cd web
|
||||||
npm install -g pnpm
|
# Match the archive/Docker npm path; npm ci rejects older tags' stale npm lockfiles.
|
||||||
pnpm install
|
npm install --include=optional
|
||||||
pnpm build
|
npm run build
|
||||||
mkdir -p ../src/langbot/web/dist
|
mkdir -p ../src/langbot/web/dist
|
||||||
cp -r dist ../src/langbot/web/
|
cp -r dist ../src/langbot/web/
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user