From 17d7fb6b12563bdce9d55725393bdbcc74312488 Mon Sep 17 00:00:00 2001 From: Jan-Henrik Bruhn Date: Sun, 7 Dec 2025 22:49:36 +0100 Subject: [PATCH] Add GitHub Actions workflows for CI/CD and releases MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Add build.yml workflow for continuous integration - Builds web app on Ubuntu - Packages Electron app for Windows, macOS, and Linux - Uploads artifacts for each platform - Add release.yml workflow with release-drafter integration - Automatically creates draft releases on push to main - Auto-calculates version based on PR labels (major/minor/patch) - Updates package.json version during build for proper installers - Uploads platform-specific installers to draft releases - Add release-drafter.yml configuration - Organizes changelog by categories (Features, Bug Fixes, Maintenance) - Supports semantic versioning via PR labels 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 --- .github/release-drafter.yml | 43 ++++++++++++++++ .github/workflows/build.yml | 92 ++++++++++++++++++++++++++++++++++ .github/workflows/release.yml | 94 +++++++++++++++++++++++++++++++++++ 3 files changed, 229 insertions(+) create mode 100644 .github/release-drafter.yml create mode 100644 .github/workflows/build.yml create mode 100644 .github/workflows/release.yml diff --git a/.github/release-drafter.yml b/.github/release-drafter.yml new file mode 100644 index 0000000..42b1421 --- /dev/null +++ b/.github/release-drafter.yml @@ -0,0 +1,43 @@ +name-template: 'v$RESOLVED_VERSION' +tag-template: 'v$RESOLVED_VERSION' + +categories: + - title: '🚀 Features' + labels: + - 'feature' + - 'enhancement' + - title: '🐛 Bug Fixes' + labels: + - 'fix' + - 'bugfix' + - 'bug' + - title: '🧰 Maintenance' + labels: + - 'chore' + - 'dependencies' + +change-template: '- $TITLE @$AUTHOR (#$NUMBER)' +change-title-escapes: '\<*_&' # You can add # and @ to disable mentions, and add ` to disable code blocks. + +version-resolver: + major: + labels: + - 'major' + - 'breaking' + minor: + labels: + - 'minor' + - 'feature' + patch: + labels: + - 'patch' + - 'fix' + - 'bugfix' + default: patch + +template: | + ## Changes + + $CHANGES + + **Full Changelog**: https://github.com/$OWNER/$REPOSITORY/compare/$PREVIOUS_TAG...v$RESOLVED_VERSION diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..c83d8db --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,92 @@ +name: Build and Package + +on: + push: + branches: [ main ] + pull_request: + branches: [ main ] + workflow_dispatch: + +jobs: + build-web: + name: Build Web Application + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version: '20' + cache: 'npm' + + - name: Install dependencies + run: npm ci + + - name: Build web application + run: npm run build + + - name: Upload web build artifacts + uses: actions/upload-artifact@v4 + with: + name: web-build + path: dist/ + retention-days: 7 + + build-electron: + name: Build Electron - ${{ matrix.os }} + runs-on: ${{ matrix.os }} + + strategy: + matrix: + os: [ubuntu-latest, windows-latest, macos-latest] + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version: '20' + cache: 'npm' + + - name: Install dependencies + run: npm ci + + - name: Package Electron app + run: npm run package + + - name: Create distributables + run: npm run make + + - name: Upload Windows artifacts + if: matrix.os == 'windows-latest' + uses: actions/upload-artifact@v4 + with: + name: electron-windows + path: | + out/make/squirrel.windows/**/*.exe + out/make/squirrel.windows/**/*.nupkg + retention-days: 30 + + - name: Upload macOS artifacts + if: matrix.os == 'macos-latest' + uses: actions/upload-artifact@v4 + with: + name: electron-macos + path: | + out/make/zip/**/*.zip + retention-days: 30 + + - name: Upload Linux artifacts + if: matrix.os == 'ubuntu-latest' + uses: actions/upload-artifact@v4 + with: + name: electron-linux + path: | + out/make/deb/**/*.deb + out/make/rpm/**/*.rpm + retention-days: 30 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..19c2e0c --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,94 @@ +name: Release + +on: + push: + branches: + - main + workflow_dispatch: + +permissions: + contents: write + pull-requests: write + +jobs: + draft-release: + name: Draft Release + runs-on: ubuntu-latest + outputs: + release-id: ${{ steps.drafter.outputs.id }} + tag-name: ${{ steps.drafter.outputs.tag_name }} + version: ${{ steps.drafter.outputs.resolved_version }} + steps: + - name: Draft release + id: drafter + uses: release-drafter/release-drafter@v5 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + build-release: + name: Build Release - ${{ matrix.os }} + needs: draft-release + if: needs.draft-release.outputs.tag-name != '' + runs-on: ${{ matrix.os }} + + strategy: + matrix: + os: [ubuntu-latest, windows-latest, macos-latest] + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version: '20' + cache: 'npm' + + - name: Update package.json version + run: | + npm version ${{ needs.draft-release.outputs.version }} --no-git-tag-version + + - name: Install dependencies + run: npm ci + + - name: Package and make + run: npm run make + + - name: Upload Windows release assets + if: matrix.os == 'windows-latest' + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: https://uploads.github.com/repos/${{ github.repository }}/releases/${{ needs.draft-release.outputs.release-id }}/assets + asset_path: out/make/squirrel.windows/x64/*.exe + asset_name: SKiTCH-Controller-${{ needs.draft-release.outputs.version }}-Setup.exe + asset_content_type: application/octet-stream + + - name: Upload all Windows assets + if: matrix.os == 'windows-latest' + run: | + for file in out/make/squirrel.windows/x64/*; do + gh release upload ${{ needs.draft-release.outputs.tag-name }} "$file" --clobber + done + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: Upload macOS assets + if: matrix.os == 'macos-latest' + run: | + for file in out/make/zip/darwin/**/*.zip; do + gh release upload ${{ needs.draft-release.outputs.tag-name }} "$file" --clobber + done + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: Upload Linux assets + if: matrix.os == 'ubuntu-latest' + run: | + for file in out/make/deb/x64/*.deb out/make/rpm/x64/*.rpm; do + gh release upload ${{ needs.draft-release.outputs.tag-name }} "$file" --clobber + done + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}