Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Testing the CI/CD process on the master branch on my fork #582

Merged
merged 26 commits into from
Sep 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
0ac42a8
import old release pipeline into the new release pipeline
baruchiro Sep 6, 2024
65bb3cd
remove workflow_call
baruchiro Sep 6, 2024
917e04b
baruchiro
baruchiro Sep 6, 2024
1dc32e5
Add PR Title workflow and release configuration
baruchiro Sep 6, 2024
1794ee5
add @semantic-release/commit-analyzer
baruchiro Sep 6, 2024
22cef9f
yarn install
baruchiro Sep 6, 2024
d42b181
Update lint.yml, release.yml, tests.yml, and typechecking.yml workflows
baruchiro Sep 6, 2024
fe554b7
add dependency
baruchiro Sep 6, 2024
ec14532
Chore: message for release
baruchiro Sep 6, 2024
277b89d
semantic-release release
baruchiro Sep 6, 2024
4efef84
Build: fix configuration
baruchiro Sep 6, 2024
f649303
Build: add some info
baruchiro Sep 6, 2024
46e9b28
Build: an object could not be cloned
baruchiro Sep 6, 2024
193b194
fix pipelines
baruchiro Sep 6, 2024
c44bce9
run all pipelines alone
baruchiro Sep 6, 2024
602da8f
run tests only on ubuntu
baruchiro Sep 6, 2024
9b96e9b
Build: release for all os
baruchiro Sep 6, 2024
20a408e
Fix: env var
baruchiro Sep 13, 2024
5c6fd0e
Fix: move env to include build
baruchiro Sep 13, 2024
51c2930
Fix: but run yarn under developement
baruchiro Sep 13, 2024
e15d051
Fix: ElectronGoogleOAuth2
baruchiro Sep 13, 2024
19bdf63
todo
baruchiro Sep 13, 2024
40f973b
don't stop running release if newer release inserted
baruchiro Sep 13, 2024
cccad6d
revert name
baruchiro Sep 13, 2024
aa028be
fix env vars
baruchiro Sep 15, 2024
871d46d
Merge remote-tracking branch 'upstream/vite-electron-builder'
baruchiro Sep 15, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions .env
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
VITE_APP_VERSION=$npm_package_version
VITE_APP_NAME=$npm_package_name
VITE_APP_VERSION=0.0.0
VITE_APP_NAME=caspion

SENTRY_DSN=
VITE_SENTRY_DSN=

GOOGLE_CLIENT_ID=
GOOGLE_CLIENT_ID=
VITE_GOOGLE_CLIENT_ID=
VITE_GOOGLE_CLIENT_SECRET=
31 changes: 31 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Build

on:
workflow_dispatch:
pull_request:

jobs:
build:
strategy:
fail-fast: true
matrix:
os:
- macos-latest
- ubuntu-latest
- windows-latest

runs-on: ${{ matrix.os }}

steps:
- uses: actions/checkout@v4
- name: Install Node.js, NPM and Yarn
uses: actions/setup-node@v4
with:
node-version-file: '.node-version'
cache: 'yarn'
- name: Install dependencies
run: yarn
- name: Build
run: yarn compile


49 changes: 0 additions & 49 deletions .github/workflows/ci.yml

This file was deleted.

6 changes: 5 additions & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
name: Lint

on:
workflow_dispatch:
push:
Expand Down Expand Up @@ -40,6 +42,7 @@ jobs:
- uses: actions/setup-node@v4
with:
cache: 'yarn'
node-version-file: '.node-version'

- run: yarn
env:
Expand All @@ -56,6 +59,7 @@ jobs:
- uses: actions/setup-node@v4
with:
cache: 'yarn'
node-version-file: '.node-version'

- run: yarn add prettier
- run: npx prettier --check "**/*.{js,mjs,cjs,jsx,ts,mts,cts,tsx,vue}"
- run: yarn format:check
40 changes: 40 additions & 0 deletions .github/workflows/pr-title.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: PR Title

on:
pull_request:
types: [opened, edited, synchronize, reopened]

jobs:
validate:
runs-on: ubuntu-latest
steps:
- uses: deepakputhraya/action-pr-title@3864bebc79c5f829d25dd42d3c6579d040b0ef16
name: Validate PR Title
continue-on-error: false
with:
regex: '\w+:( [\w\.,]+)+( \(\w+ #\d+\))?' # Regex the title should match. "Level: message (optional #123)"
allowed_prefixes: 'Breaking,Build,Chore,Fix,New,Update,Upgrade,Deps' # title should start with the given prefix
# disallowed_prefixes: 'feat/,hotfix' # title should not start with the given prefix
prefix_case_sensitive: true # title prefix are case insensitive
# min_length: 5 # Min length of the title
max_length: 50 # Max length of the title
github_token: ${{ secrets.GITHUB_TOKEN }} # Default: ${{ github.token }}
- uses: mshick/add-pr-comment@07f690343c25a94e24a8acb70d03c86b701ae322
name: Comment on PR
if: ${{ failure() }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
message: |
Please fix the title of this PR.

Examples:

```
Breaking: I broke something
Fix: fix (fixes #1234)
Update: some packages updates (refs #123)
New: Added a new feature
```

See more in `release.config.js`.
87 changes: 69 additions & 18 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
name: Release
on:
push:
branches:
- vite-electron-builder
workflow_call:
workflow_dispatch:
inputs:
dry-run:
description: 'Compiles the app but not upload artifacts to distribution server'
# TODO: default: false
default: true
version:
description: 'Exsiting version to publish files. If not provided, will create a new release.'
required: false
type: boolean
type: string

push:
branches:
- master
paths-ignore:
- 'nuxt/**'

concurrency:
group: release-${{ github.ref }}
cancel-in-progress: true
cancel-in-progress: false


defaults:
Expand All @@ -23,7 +24,45 @@ defaults:


jobs:
draft_release:
release:
runs-on: ubuntu-latest

outputs:
new_release_version: ${{ steps.semantic.outputs.new_release_version }}
new_release_published: ${{ steps.semantic.outputs.new_release_published }}

steps:
- uses: actions/checkout@v4
# https://github.com/nodejs/node-gyp/issues/2869
- name: Install Node.js, NPM and Yarn
uses: actions/setup-node@v4
with:
node-version-file: '.node-version'
cache: 'yarn'

- name: Install semantic-release dependencies
run: yarn add -D @semantic-release/commit-analyzer conventional-changelog-eslint
- uses: cycjimmy/semantic-release-action@cb425203a562475bca039ba4dbf90c7f9ac790f4
id: semantic
if: inputs.version == ''
with:
semantic_version: 24.1.0
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

publish:
needs: [release]
if: needs.release.outputs.new_release_published == 'true' || inputs.version != ''
env:
NEW_RELEASE_PUBLISHED: ${{ inputs.version && 'true' || needs.release.outputs.new_release_published }}
NEW_RELEASE_VERSION: ${{ needs.release.outputs.new_release_version || inputs.version }}

NODE_ENV: production
MODE: production
VITE_GOOGLE_CLIENT_ID: ${{ secrets.GOOGLE_CLIENT_ID }}
VITE_GOOGLE_CLIENT_SECRET: ${{ secrets.GOOGLE_CLIENT_SECRET }}
VITE_SEGMENT_WRITE_KEY: ${{ secrets.SEGMENT_WRITE_KEY }}
VITE_SENTRY_DSN: ${{ secrets.SENTRY_DSN }}

permissions:
contents: write # Allows this job to create releases
Expand All @@ -33,8 +72,8 @@ jobs:
matrix:
os:
- macos-latest
# - ubuntu-latest
# - windows-latest
- ubuntu-latest
- windows-latest

runs-on: ${{ matrix.os }}

Expand All @@ -44,14 +83,27 @@ jobs:
- uses: actions/setup-node@v4
with:
cache: 'yarn'
node-version-file: '.node-version'

- name: Install Snapcraft
uses: samuelmeuli/action-snapcraft@d33c176a9b784876d966f80fb1b461808edc0641
# Only install Snapcraft on Ubuntu
if: startsWith(matrix.os, 'ubuntu')
continue-on-error: true
env:
SNAPCRAFT_STORE_CREDENTIALS: ${{ secrets.SNAPCRAFT_TOKEN }}

- name: set version
run: yarn version --no-git-tag-version --new-version ${{ env.NEW_RELEASE_VERSION }}

- run: yarn
env:
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: 1
NODE_ENV: development

- run: yarn build

- name: Compile artifacts ${{ inputs.dry-run && '' || 'and upload them to github release' }}
- name: Compile artifacts ${{ env.NEW_RELEASE_PUBLISHED == 'true' && 'and upload them to github release' || '' }}
# I use this action because it is capable of retrying multiple times if there are any issues with the distribution server
uses: nick-fields/retry@v3
with:
Expand All @@ -62,13 +114,12 @@ jobs:
shell: 'bash'
# Due to this issue https://github.com/electron-userland/electron-builder/issues/6411 the build with npx when rebuilding native dependencies hangs forever
# see https://github.com/cawa-93/vite-electron-builder/pull/953
command: ./node_modules/.bin/electron-builder --config electron-builder.yml --publish ${{ inputs.dry-run && 'never' || 'always' }}
command: ./node_modules/.bin/electron-builder --config electron-builder.yml --publish $PUBLISH_PARAM
env:
# Code Signing params
# See https://www.electron.build/code-signing
# CSC_LINK: ''
# CSC_KEY_PASSWORD: ''
# Publishing artifacts
GH_TOKEN: ${{ secrets.github_token }} # GitHub token, automatically provided (No need to define this secret in the repo settings)
NODE_ENV: production
MODE: production
GH_TOKEN: ${{ secrets.github_token }}
PUBLISH_PARAM: ${{ env.NEW_RELEASE_PUBLISHED == 'true' && 'always' || 'never' }}
11 changes: 9 additions & 2 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
name: Tests
on: [ workflow_call ]
on:
workflow_dispatch:
pull_request:

concurrency:
group: tests-${{ github.ref }}
Expand All @@ -14,13 +16,18 @@ jobs:
strategy:
fail-fast: false
matrix:
os: [ windows-latest, ubuntu-latest, macos-latest ]
os:
# - windows-latest
- ubuntu-latest
# - macos-latest

runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4
- uses: actions/setup-node@v4
with:
cache: 'yarn'
node-version-file: '.node-version'
- run: yarn
env:
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: 1
Expand Down
5 changes: 4 additions & 1 deletion .github/workflows/typechecking.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
name: Typechecking
on: [ workflow_call ]
on:
workflow_dispatch:
pull_request:

concurrency:
group: typechecking-${{ github.ref }}
Expand All @@ -18,6 +20,7 @@ jobs:
- uses: actions/setup-node@v4
with:
cache: 'yarn'
node-version-file: '.node-version'

- run: yarn
env:
Expand Down
2 changes: 1 addition & 1 deletion .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"request": "launch",
"name": "Debug Main Process",
"skipFiles": ["<node_internals>/**"],
"program": "${workspaceFolder}\\scripts\\watch.js",
"program": "${workspaceFolder}/scripts/watch.js",
"autoAttachChildProcesses": true
}
]
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,8 @@ If you wish though to build/debug this from source, you will need to setup your
Now that you have the keys above, store them as env variables:

```
EXPORT GOOGLE_CLIENT_ID=XXXXX
EXPORT GOOGLE_CLIENT_SECRET=YYYYYY
EXPORT VITE_GOOGLE_CLIENT_ID=XXXXX
EXPORT VITE_GOOGLE_CLIENT_SECRET=YYYYYY
```

That's it. Next time you'll run the code a one time OAuth authorization window will appear and ask for access.
Expand Down
4 changes: 4 additions & 0 deletions electron-builder.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,7 @@ files:

linux:
target: deb

publish:
- provider: github
releaseType: release
6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,11 @@
"typecheck:renderer": "tsc --noEmit -p packages/renderer/tsconfig.json",
"typecheck": "yarn typecheck:main && yarn typecheck:preload && yarn typecheck:renderer",
"postinstall": "cross-env ELECTRON_RUN_AS_NODE=1 electron scripts/update-electron-vendors.js",
"format": "prettier --write \"**/*.{js,mjs,cjs,ts,mts,cts,tsx,json}\""
"format": "prettier --write \"**/*.{js,mjs,cjs,ts,mts,cts,tsx,json}\"",
"format:check": "prettier --check \"**/*.{js,mjs,cjs,ts,mts,cts,tsx,json}\""
},
"devDependencies": {
"@semantic-release/commit-analyzer": "^13.0.0",
"@sveltejs/vite-plugin-svelte": "^3.1.1",
"@testing-library/dom": "^10.4.0",
"@testing-library/jest-dom": "^6.4.8",
Expand Down Expand Up @@ -69,7 +71,7 @@
"bottleneck": "^2.19.5",
"csv-parse": "^5.5.6",
"csv-stringify": "^6.5.0",
"electron-google-oauth2": "^3.0.0",
"electron-google-oauth2": "^3.1.0",
"electron-log": "^5.1.5",
"electron-updater": "6.2.1",
"emittery": "^1.0.3",
Expand Down
Loading
Loading