feat: complete migration to Deno with automated releases
- Remove old Node.js infrastructure (package.json, tsconfig.json, bin/nupst launcher, setup.sh) - Update install.sh to download pre-compiled binaries from Gitea releases - Add Gitea Actions CI/CD workflows: - ci.yml: Type checking, linting, and build verification - release.yml: Automated binary compilation and release on tags - Update .gitignore for Deno-focused project structure - Binary-based distribution requires no dependencies or build steps
This commit is contained in:
174
.gitea/workflows/README.md
Normal file
174
.gitea/workflows/README.md
Normal file
@@ -0,0 +1,174 @@
|
||||
# Gitea Actions Workflows
|
||||
|
||||
This directory contains automated workflows for NUPST's CI/CD pipeline.
|
||||
|
||||
## Workflows
|
||||
|
||||
### CI Workflow (`ci.yml`)
|
||||
|
||||
**Triggers:**
|
||||
- Push to `main` branch
|
||||
- Push to `migration/**` branches
|
||||
- Pull requests to `main`
|
||||
|
||||
**Jobs:**
|
||||
|
||||
1. **Type Check & Lint**
|
||||
- Runs `deno check` for TypeScript validation
|
||||
- Runs `deno lint` (continues on error)
|
||||
- Runs `deno fmt --check` (continues on error)
|
||||
|
||||
2. **Build Test (Current Platform)**
|
||||
- Compiles for Linux x86_64 (host platform)
|
||||
- Tests binary execution (`--version` and `help`)
|
||||
|
||||
3. **Build All Platforms** (Main/Tags only)
|
||||
- Compiles all 5 platform binaries
|
||||
- Uploads as artifacts (30-day retention)
|
||||
- Only runs on `main` branch or tags
|
||||
|
||||
### Release Workflow (`release.yml`)
|
||||
|
||||
**Triggers:**
|
||||
- Push tags matching `v*` (e.g., `v4.0.0`)
|
||||
|
||||
**Jobs:**
|
||||
|
||||
1. **Version Verification**
|
||||
- Extracts version from tag
|
||||
- Verifies `deno.json` version matches tag
|
||||
- Fails if mismatch detected
|
||||
|
||||
2. **Compilation**
|
||||
- Compiles binaries for all 5 platforms:
|
||||
- `nupst-linux-x64` (Linux x86_64)
|
||||
- `nupst-linux-arm64` (Linux ARM64)
|
||||
- `nupst-macos-x64` (macOS Intel)
|
||||
- `nupst-macos-arm64` (macOS Apple Silicon)
|
||||
- `nupst-windows-x64.exe` (Windows x64)
|
||||
|
||||
3. **Checksums**
|
||||
- Generates SHA256 checksums for all binaries
|
||||
- Creates `SHA256SUMS.txt`
|
||||
|
||||
4. **Release Creation**
|
||||
- Creates Gitea release with tag
|
||||
- Extracts release notes from CHANGELOG.md (if exists)
|
||||
- Uploads all binaries + checksums as release assets
|
||||
|
||||
## Creating a Release
|
||||
|
||||
### Prerequisites
|
||||
|
||||
1. Update version in `deno.json`:
|
||||
```json
|
||||
{
|
||||
"version": "4.0.0"
|
||||
}
|
||||
```
|
||||
|
||||
2. Update `CHANGELOG.md` with release notes (optional but recommended)
|
||||
|
||||
3. Commit all changes:
|
||||
```bash
|
||||
git add .
|
||||
git commit -m "chore: bump version to 4.0.0"
|
||||
```
|
||||
|
||||
### Release Process
|
||||
|
||||
1. Create and push a tag matching the version:
|
||||
```bash
|
||||
git tag v4.0.0
|
||||
git push origin v4.0.0
|
||||
```
|
||||
|
||||
2. Gitea Actions will automatically:
|
||||
- Verify version consistency
|
||||
- Compile all platform binaries
|
||||
- Generate checksums
|
||||
- Create release with binaries attached
|
||||
|
||||
3. Monitor the workflow:
|
||||
- Go to: `https://code.foss.global/serve.zone/nupst/actions`
|
||||
- Check the "Release" workflow run
|
||||
|
||||
### Manual Release (Fallback)
|
||||
|
||||
If workflows fail, you can create a release manually:
|
||||
|
||||
```bash
|
||||
# Compile all binaries
|
||||
bash scripts/compile-all.sh
|
||||
|
||||
# Generate checksums
|
||||
cd dist/binaries
|
||||
sha256sum * > SHA256SUMS.txt
|
||||
cd ../..
|
||||
|
||||
# Create release on Gitea UI
|
||||
# Upload binaries manually
|
||||
```
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
### Version Mismatch Error
|
||||
|
||||
If the release workflow fails with "Version mismatch":
|
||||
- Ensure `deno.json` version matches the git tag
|
||||
- Example: tag `v4.0.0` requires `"version": "4.0.0"` in deno.json
|
||||
|
||||
### Compilation Errors
|
||||
|
||||
If compilation fails:
|
||||
1. Test locally: `bash scripts/compile-all.sh`
|
||||
2. Check Deno version compatibility
|
||||
3. Review TypeScript errors: `deno check mod.ts`
|
||||
|
||||
### Upload Failures
|
||||
|
||||
If binary upload fails:
|
||||
1. Check Gitea Actions permissions
|
||||
2. Verify `GITHUB_TOKEN` secret exists (auto-provided by Gitea)
|
||||
3. Try manual release creation
|
||||
|
||||
## Workflow Secrets
|
||||
|
||||
The workflows use the following secrets:
|
||||
|
||||
- `GITHUB_TOKEN` - Auto-provided by Gitea Actions (no setup needed)
|
||||
|
||||
## Development
|
||||
|
||||
### Testing Workflows Locally
|
||||
|
||||
You can test compilation locally:
|
||||
|
||||
```bash
|
||||
# Install Deno
|
||||
curl -fsSL https://deno.land/install.sh | sh
|
||||
|
||||
# Test type checking
|
||||
deno check mod.ts
|
||||
|
||||
# Test compilation
|
||||
bash scripts/compile-all.sh
|
||||
|
||||
# Test binary
|
||||
./dist/binaries/nupst-linux-x64 --version
|
||||
```
|
||||
|
||||
### Modifying Workflows
|
||||
|
||||
After modifying workflows:
|
||||
|
||||
1. Test syntax: Use a YAML validator
|
||||
2. Commit changes: `git add .gitea/workflows/`
|
||||
3. Push to feature branch first to test CI
|
||||
4. Merge to main once verified
|
||||
|
||||
## Links
|
||||
|
||||
- Gitea Actions Documentation: https://docs.gitea.com/usage/actions/overview
|
||||
- Deno Compile Documentation: https://docs.deno.com/runtime/manual/tools/compiler
|
||||
- NUPST Repository: https://code.foss.global/serve.zone/nupst
|
85
.gitea/workflows/ci.yml
Normal file
85
.gitea/workflows/ci.yml
Normal file
@@ -0,0 +1,85 @@
|
||||
name: CI
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
- 'migration/**'
|
||||
pull_request:
|
||||
branches:
|
||||
- main
|
||||
|
||||
jobs:
|
||||
check:
|
||||
name: Type Check & Lint
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Set up Deno
|
||||
uses: denoland/setup-deno@v1
|
||||
with:
|
||||
deno-version: v1.x
|
||||
|
||||
- name: Check TypeScript types
|
||||
run: deno check mod.ts
|
||||
|
||||
- name: Lint code
|
||||
run: deno lint
|
||||
continue-on-error: true
|
||||
|
||||
- name: Format check
|
||||
run: deno fmt --check
|
||||
continue-on-error: true
|
||||
|
||||
build:
|
||||
name: Build Test (Current Platform)
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Set up Deno
|
||||
uses: denoland/setup-deno@v1
|
||||
with:
|
||||
deno-version: v1.x
|
||||
|
||||
- name: Compile for current platform
|
||||
run: |
|
||||
echo "Testing compilation for Linux x86_64..."
|
||||
deno compile --allow-all --no-check \
|
||||
--output nupst-test \
|
||||
--target x86_64-unknown-linux-gnu mod.ts
|
||||
|
||||
- name: Test binary execution
|
||||
run: |
|
||||
chmod +x nupst-test
|
||||
./nupst-test --version
|
||||
./nupst-test help
|
||||
|
||||
build-all:
|
||||
name: Build All Platforms (Tag/Main only)
|
||||
runs-on: ubuntu-latest
|
||||
if: github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/')
|
||||
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Set up Deno
|
||||
uses: denoland/setup-deno@v1
|
||||
with:
|
||||
deno-version: v1.x
|
||||
|
||||
- name: Compile all platform binaries
|
||||
run: bash scripts/compile-all.sh
|
||||
|
||||
- name: Upload binaries as artifacts
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: nupst-binaries
|
||||
path: dist/binaries/*
|
||||
retention-days: 30
|
182
.gitea/workflows/release.yml
Normal file
182
.gitea/workflows/release.yml
Normal file
@@ -0,0 +1,182 @@
|
||||
name: Release
|
||||
|
||||
on:
|
||||
push:
|
||||
tags:
|
||||
- 'v*'
|
||||
|
||||
jobs:
|
||||
build-and-release:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Set up Deno
|
||||
uses: denoland/setup-deno@v1
|
||||
with:
|
||||
deno-version: v1.x
|
||||
|
||||
- name: Get version from tag
|
||||
id: version
|
||||
run: |
|
||||
VERSION=${GITHUB_REF#refs/tags/}
|
||||
echo "version=$VERSION" >> $GITHUB_OUTPUT
|
||||
echo "version_number=${VERSION#v}" >> $GITHUB_OUTPUT
|
||||
echo "Building version: $VERSION"
|
||||
|
||||
- name: Verify deno.json version matches tag
|
||||
run: |
|
||||
DENO_VERSION=$(grep -o '"version": "[^"]*"' deno.json | cut -d'"' -f4)
|
||||
TAG_VERSION="${{ steps.version.outputs.version_number }}"
|
||||
echo "deno.json version: $DENO_VERSION"
|
||||
echo "Tag version: $TAG_VERSION"
|
||||
if [ "$DENO_VERSION" != "$TAG_VERSION" ]; then
|
||||
echo "ERROR: Version mismatch!"
|
||||
echo "deno.json has version $DENO_VERSION but tag is $TAG_VERSION"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
- name: Compile binaries for all platforms
|
||||
run: |
|
||||
echo "================================================"
|
||||
echo " NUPST Release Compilation"
|
||||
echo " Version: ${{ steps.version.outputs.version }}"
|
||||
echo "================================================"
|
||||
echo ""
|
||||
|
||||
mkdir -p dist/binaries
|
||||
|
||||
# Linux x86_64
|
||||
echo "→ Compiling for Linux x86_64..."
|
||||
deno compile --allow-all --no-check \
|
||||
--output dist/binaries/nupst-linux-x64 \
|
||||
--target x86_64-unknown-linux-gnu mod.ts
|
||||
echo " ✓ Linux x86_64 complete"
|
||||
|
||||
# Linux ARM64
|
||||
echo "→ Compiling for Linux ARM64..."
|
||||
deno compile --allow-all --no-check \
|
||||
--output dist/binaries/nupst-linux-arm64 \
|
||||
--target aarch64-unknown-linux-gnu mod.ts
|
||||
echo " ✓ Linux ARM64 complete"
|
||||
|
||||
# macOS x86_64
|
||||
echo "→ Compiling for macOS x86_64..."
|
||||
deno compile --allow-all --no-check \
|
||||
--output dist/binaries/nupst-macos-x64 \
|
||||
--target x86_64-apple-darwin mod.ts
|
||||
echo " ✓ macOS x86_64 complete"
|
||||
|
||||
# macOS ARM64
|
||||
echo "→ Compiling for macOS ARM64..."
|
||||
deno compile --allow-all --no-check \
|
||||
--output dist/binaries/nupst-macos-arm64 \
|
||||
--target aarch64-apple-darwin mod.ts
|
||||
echo " ✓ macOS ARM64 complete"
|
||||
|
||||
# Windows x86_64
|
||||
echo "→ Compiling for Windows x86_64..."
|
||||
deno compile --allow-all --no-check \
|
||||
--output dist/binaries/nupst-windows-x64.exe \
|
||||
--target x86_64-pc-windows-msvc mod.ts
|
||||
echo " ✓ Windows x86_64 complete"
|
||||
|
||||
echo ""
|
||||
echo "All binaries compiled successfully!"
|
||||
ls -lh dist/binaries/
|
||||
|
||||
- name: Generate SHA256 checksums
|
||||
run: |
|
||||
cd dist/binaries
|
||||
sha256sum * > SHA256SUMS.txt
|
||||
cat SHA256SUMS.txt
|
||||
cd ../..
|
||||
|
||||
- name: Extract changelog for this version
|
||||
id: changelog
|
||||
run: |
|
||||
VERSION="${{ steps.version.outputs.version }}"
|
||||
|
||||
# Check if CHANGELOG.md exists
|
||||
if [ ! -f CHANGELOG.md ]; then
|
||||
echo "No CHANGELOG.md found, using default release notes"
|
||||
cat > /tmp/release_notes.md << EOF
|
||||
## NUPST $VERSION
|
||||
|
||||
Pre-compiled binaries for multiple platforms.
|
||||
|
||||
### Installation
|
||||
|
||||
Use the installation script:
|
||||
\`\`\`bash
|
||||
curl -sSL https://code.foss.global/serve.zone/nupst/raw/branch/main/install.sh | sudo bash
|
||||
\`\`\`
|
||||
|
||||
Or download the binary for your platform and make it executable.
|
||||
|
||||
### Supported Platforms
|
||||
- Linux x86_64 (x64)
|
||||
- Linux ARM64 (aarch64)
|
||||
- macOS x86_64 (Intel)
|
||||
- macOS ARM64 (Apple Silicon)
|
||||
- Windows x86_64
|
||||
|
||||
### Checksums
|
||||
SHA256 checksums are provided in SHA256SUMS.txt
|
||||
EOF
|
||||
else
|
||||
# Try to extract section for this version from CHANGELOG.md
|
||||
# This is a simple extraction - adjust based on your CHANGELOG format
|
||||
awk "/## \[$VERSION\]/,/## \[/" CHANGELOG.md | sed '$d' > /tmp/release_notes.md || cat > /tmp/release_notes.md << EOF
|
||||
## NUPST $VERSION
|
||||
|
||||
See CHANGELOG.md for full details.
|
||||
|
||||
### Installation
|
||||
|
||||
Use the installation script:
|
||||
\`\`\`bash
|
||||
curl -sSL https://code.foss.global/serve.zone/nupst/raw/branch/main/install.sh | sudo bash
|
||||
\`\`\`
|
||||
EOF
|
||||
fi
|
||||
|
||||
echo "Release notes:"
|
||||
cat /tmp/release_notes.md
|
||||
|
||||
- name: Create Gitea Release
|
||||
uses: actions/gitea-release-action@v1
|
||||
with:
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
tag_name: ${{ steps.version.outputs.version }}
|
||||
name: NUPST ${{ steps.version.outputs.version }}
|
||||
body_path: /tmp/release_notes.md
|
||||
draft: false
|
||||
prerelease: false
|
||||
files: |
|
||||
dist/binaries/nupst-linux-x64
|
||||
dist/binaries/nupst-linux-arm64
|
||||
dist/binaries/nupst-macos-x64
|
||||
dist/binaries/nupst-macos-arm64
|
||||
dist/binaries/nupst-windows-x64.exe
|
||||
dist/binaries/SHA256SUMS.txt
|
||||
|
||||
- name: Release Summary
|
||||
run: |
|
||||
echo "================================================"
|
||||
echo " Release ${{ steps.version.outputs.version }} Complete!"
|
||||
echo "================================================"
|
||||
echo ""
|
||||
echo "Binaries published:"
|
||||
ls -lh dist/binaries/
|
||||
echo ""
|
||||
echo "Release URL:"
|
||||
echo "https://code.foss.global/serve.zone/nupst/releases/tag/${{ steps.version.outputs.version }}"
|
||||
echo ""
|
||||
echo "Installation command:"
|
||||
echo "curl -sSL https://code.foss.global/serve.zone/nupst/raw/branch/main/install.sh | sudo bash"
|
||||
echo ""
|
Reference in New Issue
Block a user