Skip to content

fix build error

fix build error #10

Workflow file for this run

name: Release App
on:
push:
tags:
- "app-v*.*.*"
workflow_dispatch:
inputs:
dry-run:
description: "Dry run (don't actually publish)"
required: false
type: boolean
default: false
jobs:
release:
name: Build and Publish App
runs-on: ubuntu-latest
permissions:
contents: write
id-token: write
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Extract version from tag
id: version
run: |
if [[ "${{ github.event_name }}" == "push" ]]; then
# Extract version from tag (app-v1.2.3 -> 1.2.3)
VERSION="${GITHUB_REF#refs/tags/app-v}"
else
# For manual trigger, read from package.json
VERSION=$(jq -r .version packages/app/package.json)
fi
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "Extracted version: $VERSION"
- name: Verify version matches package.json
run: |
PKG_VERSION=$(jq -r .version packages/app/package.json)
TAG_VERSION="${{ steps.version.outputs.version }}"
if [[ "$PKG_VERSION" != "$TAG_VERSION" ]]; then
echo "Error: Tag version ($TAG_VERSION) does not match package.json version ($PKG_VERSION)"
echo "The tag must match the committed version. Ensure you've merged the Version Packages PR first."
exit 1
fi
echo "Version verified: $PKG_VERSION"
- name: Setup Bun
uses: oven-sh/setup-bun@v2
with:
bun-version: latest
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: "20"
registry-url: "https://registry.npmjs.org"
- name: Install dependencies
run: bun install
- name: Build core (workspace dependency)
run: bun run build
working-directory: packages/core
- name: Build SDK (workspace dependency)
run: bun run build
working-directory: packages/sdk/js
- name: Build all platform binaries
run: bun run build:all
working-directory: packages/app
- name: Create archives and checksums
id: archives
run: |
cd packages/app/dist
VERSION="${{ steps.version.outputs.version }}"
# Create archives directory
mkdir -p archives
# Create archives for each platform
for platform_dir in app-*; do
if [[ -d "$platform_dir" ]]; then
platform="${platform_dir#app-}"
if [[ "$platform" == *"windows"* ]]; then
# ZIP for Windows
archive_name="treq-${VERSION}-${platform}.zip"
(cd "$platform_dir" && zip -r "../archives/$archive_name" .)
else
# tar.gz for Linux/macOS
archive_name="treq-${VERSION}-${platform}.tar.gz"
tar -czf "archives/$archive_name" -C "$platform_dir" .
fi
echo "Created: $archive_name"
fi
done
# Generate SHA256 checksums
cd archives
sha256sum * > SHA256SUMS.txt
cat SHA256SUMS.txt
echo "archives_dir=packages/app/dist/archives" >> $GITHUB_OUTPUT
- name: Generate changelog
id: changelog
run: |
VERSION="${{ steps.version.outputs.version }}"
# Find previous app tag
PREV_TAG=$(git tag --list "app-v*" --sort=-v:refname | grep -v "app-v${VERSION}" | head -1 || echo "")
if [[ -n "$PREV_TAG" ]]; then
echo "Generating changelog from $PREV_TAG to app-v${VERSION}"
CHANGELOG=$(git log --pretty=format:"- %s (%h)" "$PREV_TAG"..HEAD -- packages/app)
else
echo "No previous tag found, generating full changelog"
CHANGELOG=$(git log --pretty=format:"- %s (%h)" -- packages/app | head -20)
fi
# Write changelog to file for multiline handling
echo "$CHANGELOG" > /tmp/changelog.txt
# Create release body
cat > /tmp/release_body.md << 'BODY_EOF'
## Installation
### curl (recommended)
```bash
curl -fsSL https://t-req.io/install | bash
```
### npm
```bash
npm install -g @t-req/app
```
### Manual download
Download the appropriate archive for your platform from the assets below.
## Changes
BODY_EOF
echo "$CHANGELOG" >> /tmp/release_body.md
echo "Generated release body"
- name: Create draft release
if: ${{ github.event_name == 'push' || !inputs.dry-run }}
id: create_release
run: |
VERSION="${{ steps.version.outputs.version }}"
gh release create "app-v${VERSION}" \
--title "App v${VERSION}" \
--notes-file /tmp/release_body.md \
--draft
echo "Created draft release app-v${VERSION}"
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Upload release assets
if: ${{ github.event_name == 'push' || !inputs.dry-run }}
run: |
VERSION="${{ steps.version.outputs.version }}"
gh release upload "app-v${VERSION}" \
packages/app/dist/archives/*.tar.gz \
packages/app/dist/archives/*.zip \
packages/app/dist/archives/SHA256SUMS.txt
echo "Uploaded release assets"
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Publish to npm
if: ${{ github.event_name == 'push' || !inputs.dry-run }}
run: bun run script/publish.ts --skip-build
working-directory: packages/app
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Finalize release
if: ${{ github.event_name == 'push' || !inputs.dry-run }}
run: |
VERSION="${{ steps.version.outputs.version }}"
gh release edit "app-v${VERSION}" --draft=false
echo "Finalized release app-v${VERSION}"
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Dry run summary
if: ${{ github.event_name == 'workflow_dispatch' && inputs.dry-run }}
run: |
VERSION="${{ steps.version.outputs.version }}"
echo "=== DRY RUN SUMMARY ==="
echo "Version: $VERSION"
echo ""
echo "Archives that would be created:"
ls -la packages/app/dist/archives/
echo ""
echo "Checksums:"
cat packages/app/dist/archives/SHA256SUMS.txt
echo ""
echo "Release body:"
cat /tmp/release_body.md
echo ""
echo "[dry-run] Would create GitHub release app-v${VERSION}"
echo "[dry-run] Would publish to npm"