Skip to content

Commit 99ef57c

Browse files
author
Involvex
committed
feat: Add comprehensive GitHub Actions workflows
- auto-version.yml: Semantic versioning based on conventional commits (feat, fix, BREAKING CHANGE) with automatic tagging and release notes - release.yml: Multi-platform Electron builds (Windows, macOS, Linux) with automated GitHub releases - node.js.yml: Enhanced CI pipeline with type checking, web builds, and conditional Electron testing Features: - Automatic version bumping based on commit message patterns - Multi-platform builds with artifact uploading - GitHub release creation with proper tagging - Modern GitHub Actions v4 and Node.js 20 - Proper YAML formatting with spaces (no tabs)
1 parent 9ae957c commit 99ef57c

3 files changed

Lines changed: 291 additions & 0 deletions

File tree

.github/workflows/auto-version.yml

Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
name: Auto Version and Release
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
paths-ignore:
8+
- 'docs/**'
9+
- '*.md'
10+
- '.gitignore'
11+
12+
jobs:
13+
auto-version:
14+
runs-on: ubuntu-latest
15+
if: "!contains(github.event.head_commit.message, '[skip ci]')"
16+
outputs:
17+
new-version: ${{ steps.version.outputs.new-version }}
18+
version-changed: ${{ steps.version.outputs.version-changed }}
19+
20+
steps:
21+
- name: Checkout repository
22+
uses: actions/checkout@v4
23+
with:
24+
fetch-depth: 0
25+
token: ${{ secrets.GITHUB_TOKEN }}
26+
27+
- name: Set up Node.js
28+
uses: actions/setup-node@v4
29+
with:
30+
node-version: '20'
31+
cache: 'npm'
32+
33+
- name: Install dependencies
34+
run: npm ci
35+
36+
- name: Configure Git
37+
run: |
38+
git config --global user.name 'github-actions[bot]'
39+
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
40+
41+
- name: Determine version bump type
42+
id: version-type
43+
run: |
44+
COMMIT_MSG="${{ github.event.head_commit.message }}"
45+
echo "Commit message: $COMMIT_MSG"
46+
47+
if [[ "$COMMIT_MSG" =~ ^feat(\(.+\))?!:|^fix(\(.+\))?!:|BREAKING\ CHANGE ]]; then
48+
echo "type=major" >> $GITHUB_OUTPUT
49+
echo "Detected: BREAKING CHANGE -> major version bump"
50+
elif [[ "$COMMIT_MSG" =~ ^feat(\(.+\))?: ]]; then
51+
echo "type=minor" >> $GITHUB_OUTPUT
52+
echo "Detected: feature -> minor version bump"
53+
elif [[ "$COMMIT_MSG" =~ ^fix(\(.+\))?: ]]; then
54+
echo "type=patch" >> $GITHUB_OUTPUT
55+
echo "Detected: fix -> patch version bump"
56+
elif [[ "$COMMIT_MSG" =~ ^(docs|style|refactor|perf|test|chore)(\(.+\))?: ]]; then
57+
echo "type=patch" >> $GITHUB_OUTPUT
58+
echo "Detected: maintenance -> patch version bump"
59+
else
60+
echo "type=patch" >> $GITHUB_OUTPUT
61+
echo "Default: patch version bump"
62+
fi
63+
64+
- name: Bump version
65+
id: version
66+
run: |
67+
CURRENT_VERSION=$(node -p "require('./package.json').version")
68+
echo "Current version: $CURRENT_VERSION"
69+
70+
npm version ${{ steps.version-type.outputs.type }} --no-git-tag-version
71+
72+
NEW_VERSION=$(node -p "require('./package.json').version")
73+
echo "New version: $NEW_VERSION"
74+
echo "new-version=$NEW_VERSION" >> $GITHUB_OUTPUT
75+
76+
if [[ "$CURRENT_VERSION" != "$NEW_VERSION" ]]; then
77+
echo "version-changed=true" >> $GITHUB_OUTPUT
78+
else
79+
echo "version-changed=false" >> $GITHUB_OUTPUT
80+
fi
81+
82+
- name: Create release notes
83+
if: steps.version.outputs.version-changed == 'true'
84+
run: |
85+
NEW_VERSION="${{ steps.version.outputs.new-version }}"
86+
COMMIT_MSG="${{ github.event.head_commit.message }}"
87+
88+
echo "# Release Notes for v$NEW_VERSION" > RELEASE_NOTES.md
89+
echo "" >> RELEASE_NOTES.md
90+
echo "## Changes" >> RELEASE_NOTES.md
91+
echo "- $COMMIT_MSG" >> RELEASE_NOTES.md
92+
echo "" >> RELEASE_NOTES.md
93+
echo "## Commit Details" >> RELEASE_NOTES.md
94+
echo "- **Commit**: ${{ github.event.head_commit.id }}" >> RELEASE_NOTES.md
95+
echo "- **Author**: ${{ github.event.head_commit.author.name }}" >> RELEASE_NOTES.md
96+
echo "- **Date**: $(date -u '+%Y-%m-%d %H:%M:%S UTC')" >> RELEASE_NOTES.md
97+
98+
- name: Commit and push changes
99+
if: steps.version.outputs.version-changed == 'true'
100+
run: |
101+
git add package.json RELEASE_NOTES.md
102+
git commit -m "chore(release): bump version to ${{ steps.version.outputs.new-version }} [skip ci]"
103+
git tag "v${{ steps.version.outputs.new-version }}"
104+
git push origin main --follow-tags
105+
106+
- name: Trigger release workflow
107+
if: steps.version.outputs.version-changed == 'true'
108+
run: |
109+
echo "Version bumped to ${{ steps.version.outputs.new-version }}"
110+
echo "Release workflow will be triggered by the new tag"

.github/workflows/node.js.yml

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
name: Node.js CI
2+
3+
on:
4+
push:
5+
branches: [ "main" ]
6+
pull_request:
7+
branches: [ "main" ]
8+
9+
jobs:
10+
build:
11+
runs-on: ubuntu-latest
12+
13+
strategy:
14+
matrix:
15+
node-version: [20]
16+
17+
steps:
18+
- name: Checkout repository
19+
uses: actions/checkout@v4
20+
21+
- name: Use Node.js ${{ matrix.node-version }}
22+
uses: actions/setup-node@v4
23+
with:
24+
node-version: ${{ matrix.node-version }}
25+
cache: 'npm'
26+
27+
- name: Install dependencies
28+
run: npm ci
29+
30+
- name: Run type checking
31+
run: npm run typecheck
32+
33+
- name: Build web version
34+
run: npm run build:web
35+
36+
- name: Run tests
37+
run: npm run test
38+
39+
electron-build-test:
40+
runs-on: ${{ matrix.os }}
41+
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
42+
strategy:
43+
matrix:
44+
os: [windows-latest, macos-latest, ubuntu-latest]
45+
46+
steps:
47+
- name: Checkout repository
48+
uses: actions/checkout@v4
49+
50+
- name: Use Node.js 20
51+
uses: actions/setup-node@v4
52+
with:
53+
node-version: 20
54+
cache: 'npm'
55+
56+
- name: Install dependencies
57+
run: npm ci
58+
59+
- name: Run type checking
60+
run: npm run typecheck
61+
62+
- name: Build application
63+
run: npm run build
64+
65+
- name: Validate build artifacts
66+
run: npm run validate:build

.github/workflows/release.yml

Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*'
7+
workflow_dispatch:
8+
inputs:
9+
version:
10+
description: 'Version to release (e.g., 1.3.0)'
11+
required: true
12+
type: string
13+
14+
env:
15+
NODE_VERSION: '20'
16+
17+
jobs:
18+
build-and-release:
19+
runs-on: ${{ matrix.os }}
20+
strategy:
21+
matrix:
22+
os: [windows-latest, macos-latest, ubuntu-latest]
23+
include:
24+
- os: windows-latest
25+
platform: win
26+
- os: macos-latest
27+
platform: mac
28+
- os: ubuntu-latest
29+
platform: linux
30+
31+
steps:
32+
- name: Checkout repository
33+
uses: actions/checkout@v4
34+
with:
35+
fetch-depth: 0
36+
37+
- name: Set up Node.js
38+
uses: actions/setup-node@v4
39+
with:
40+
node-version: ${{ env.NODE_VERSION }}
41+
cache: 'npm'
42+
43+
- name: Install dependencies
44+
run: npm ci
45+
46+
- name: Run type checking
47+
run: npm run typecheck
48+
49+
- name: Build application
50+
run: npm run build
51+
52+
- name: Install app dependencies (Electron)
53+
run: npm run postinstall
54+
55+
- name: Build Electron app
56+
env:
57+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
58+
CSC_IDENTITY_AUTO_DISCOVERY: false
59+
run: |
60+
if [[ "${{ matrix.platform }}" == "win" ]]; then
61+
npm run package:win
62+
elif [[ "${{ matrix.platform }}" == "mac" ]]; then
63+
npm run package:mac
64+
elif [[ "${{ matrix.platform }}" == "linux" ]]; then
65+
npm run package:linux
66+
fi
67+
shell: bash
68+
69+
- name: Upload artifacts
70+
uses: actions/upload-artifact@v4
71+
with:
72+
name: release-${{ matrix.platform }}
73+
path: |
74+
dist-electron/*.exe
75+
dist-electron/*.dmg
76+
dist-electron/*.AppImage
77+
dist-electron/*.deb
78+
retention-days: 5
79+
80+
create-release:
81+
needs: build-and-release
82+
runs-on: ubuntu-latest
83+
if: startsWith(github.ref, 'refs/tags/')
84+
85+
steps:
86+
- name: Checkout repository
87+
uses: actions/checkout@v4
88+
89+
- name: Download all artifacts
90+
uses: actions/download-artifact@v4
91+
with:
92+
path: ./artifacts
93+
94+
- name: Get version from tag
95+
id: version
96+
run: |
97+
TAG_NAME=${GITHUB_REF#refs/tags/}
98+
VERSION=${TAG_NAME#v}
99+
echo "version=$VERSION" >> $GITHUB_OUTPUT
100+
echo "tag=$TAG_NAME" >> $GITHUB_OUTPUT
101+
102+
- name: Create GitHub Release
103+
uses: softprops/action-gh-release@v2
104+
with:
105+
tag_name: ${{ steps.version.outputs.tag }}
106+
name: New World Chat AI ${{ steps.version.outputs.version }}
107+
files: |
108+
./artifacts/**/*.exe
109+
./artifacts/**/*.dmg
110+
./artifacts/**/*.AppImage
111+
./artifacts/**/*.deb
112+
draft: false
113+
prerelease: false
114+
env:
115+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)