diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..da42a42 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,57 @@ +name: CodeSnip CI + +on: + push: + branches: + - 26Q2.5 + - main + - '26Q3*' + pull_request: + branches: + - 26Q2.5 + - main + - '26Q3*' + +permissions: + contents: read + +jobs: + build: + name: Build CodeSnip + runs-on: windows-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version: 22 + cache: npm + + - name: Install dependencies + run: npm ci --include=dev + + - name: Normalize Electron version + shell: pwsh + run: npm pkg set version=26.2.5 + + - name: Build Windows application + run: npx electron-builder --win portable --publish never + env: + CSC_IDENTITY_AUTO_DISCOVERY: 'false' + + - name: Verify Windows build + shell: pwsh + run: | + $exe = Get-ChildItem -Path dist -Filter *.exe -ErrorAction Stop + if (-not $exe) { throw 'Windows executable was not produced.' } + $exe | Format-Table Name, Length + + - name: Upload Windows build + uses: actions/upload-artifact@v4 + with: + name: CodeSnip-Windows + path: dist/*.exe + if-no-files-found: error diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..752775c --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,41 @@ +name: CodeSnip Release + +on: + push: + tags: + - 'v*' + +permissions: + contents: write + +jobs: + release: + name: Build and Release CodeSnip + runs-on: windows-latest + + steps: + - name: Checkout repository + 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 Windows application + run: npm run dist:win + + - name: Create GitHub Release + shell: pwsh + env: + GH_TOKEN: ${{ github.token }} + run: | + $assets = Get-ChildItem -Path dist -Filter *.exe | ForEach-Object { $_.FullName } + if (-not $assets) { + throw 'No Windows executable was produced.' + } + gh release create "${{ github.ref_name }}" $assets --generate-notes --title "CodeSnip ${{ github.ref_name }}" diff --git a/package.json b/package.json index 8ddf3c7..9100f1e 100644 --- a/package.json +++ b/package.json @@ -5,7 +5,12 @@ "license": "MIT", "scripts": { "start": "electron .", - "dist": "electron-builder --windows" + "dist": "electron-builder --windows", + "dist:win": "electron-builder --windows" + }, + "devDependencies": { + "electron": "^31.0.0", + "electron-builder": "^26.15.3" }, "build": { "appId": "com.selim.codesnip",