Skip to content

ci: automate releases on every push to main #7

ci: automate releases on every push to main

ci: automate releases on every push to main #7

Workflow file for this run

name: CI/CD & Auto-Release
on:
push:
branches: [main, master, develop]
tags:
- 'v*'
pull_request:
branches: [main, master, develop]
workflow_dispatch:
env:
NODE_VERSION: '22'
jobs:
# ============================================================
# Stage 1: Validation & Code Quality
# ============================================================
quality:
name: πŸ”¬ Quality & Lint
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- name: πŸ” Checkout code
uses: actions/checkout@v4
- name: 🟒 Setup Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
cache: 'npm'
- name: πŸ“¦ Install dependencies
run: npm ci
- name: ✨ Prettier Format Check
run: npm run format:check
- name: 🧹 Lint Check
run: npm run lint
- name: πŸ›‘οΈ TypeScript Type Check
run: npm run type-check
# ============================================================
# Stage 2: Unit Testing
# ============================================================
test:
name: πŸ§ͺ Unit Tests
needs: quality
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- name: πŸ” Checkout code
uses: actions/checkout@v4
- name: 🟒 Setup Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
cache: 'npm'
- name: πŸ“¦ Install dependencies
run: npm ci
- name: πŸƒ Run Tests
run: npm test
# ============================================================
# Stage 3: Build & Release (Windows)
# ============================================================
build-and-release:
name: πŸ—οΈ Build & Release EXE
needs: test
runs-on: windows-latest
timeout-minutes: 20
permissions:
contents: write
pull-requests: write
steps:
- name: πŸ” Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: 🟒 Setup Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
cache: 'npm'
- name: πŸ“¦ Install dependencies
run: npm ci
- name: πŸ”¨ Build Standalone EXE
run: npm run build:sea
- name: ⬆️ Upload Artifact (Summary Page)
uses: actions/upload-artifact@v4
with:
name: remote-opencode-windows
path: dist/remote-opencode.exe
retention-days: 7
# ============================================================
# Release Logic (Automated for Push to Main)
# ============================================================
- name: πŸš€ Create/Update Release
if: github.event_name == 'push' && (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v'))
uses: softprops/action-gh-release@v2
with:
files: dist/remote-opencode.exe
# If it's a tag, use tag name. Otherwise, use 'Latest Build'
name: ${{ startsWith(github.ref, 'refs/tags/v') && github.ref_name || 'Latest Build (Main)' }}
tag_name: ${{ startsWith(github.ref, 'refs/tags/v') && github.ref_name || 'latest' }}
draft: false
prerelease: ${{ !startsWith(github.ref, 'refs/tags/v') }} # Mark rolling builds as pre-release
generate_release_notes: true
make_latest: ${{ startsWith(github.ref, 'refs/tags/v') && 'true' || 'false' }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# ============================================================
# PR Feedback
# ============================================================
- name: πŸ“Š Post PR Summary
if: github.event_name == 'pull_request' && always()
uses: actions/github-script@v7
with:
script: |
const body = `## βœ… CI/CD Pipeline Passed
- πŸ”¬ Code Quality: Passed
- πŸ§ͺ Unit Tests: Passed
- πŸ—οΈ Build EXE: Standalone Windows binary generated successfully.
This PR is ready to be merged. Once merged to main, a new **Latest Build** release will be automatically created! πŸŽ‰`;
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: body
});