diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index df66f8519..a12491516 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -3,7 +3,7 @@ name: Release App on: push: branches: - - release + - 'release/v**' jobs: release-macos: @@ -27,6 +27,9 @@ jobs: run: yarn install - name: Build + env: + OAUTH_CLIENT_ID: ${{ secrets.oauth_client_id }} + OAUTH_CLIENT_SECRET: ${{ secrets.oauth_client_secret }} run: yarn build - name: Pack (electron-builder) diff --git a/README.md b/README.md index b5e7f0de5..7672ec1d0 100644 --- a/README.md +++ b/README.md @@ -31,12 +31,11 @@ Gitify currently only supports mac OS. ### Development -First you will need to set the testing `CLIENT_ID` and `CLIENT_SECRET` in `src/js/utils/constants.js` file. You can use the development app credentials (use at your own discretion): +Optional: If you want you use your own OAuth credentials, you can do so by passing them as environment variables when bundling the app. This is optional as the app has some default "development" keys (use at your own discretion). - Client Id: 3fef4433a29c6ad8f22c - Client Secret Key: 9670de733096c15322183ff17ed0fc8704050379 + OAUTH_CLIENT_ID="123" OAUTH_CLIENT_SECRET="456789" yarn build -To watch for changes in the `src` directory: +To watch for changes(`webpack`) in the `src` directory: yarn run watch @@ -44,24 +43,29 @@ To run the actual **electron app**: yarn start -### Distribution +### Releases -To prepare the app for distribution run: +The release process is automated. Follow the steps below. - yarn run build - yarn run pack - yarn run make:macos + 1. Create a [new **draft** release](https://github.com/manosim/gitify/releases/new). Set the tag version to something with the format of `v1.2.3`. Save as a **draft**. + 2. Once everything is merged to `master`, create a branch that starts with `release/vX.X.X` (ie. `release/v1.2.3`). + 3. In the same branch, **bump the version** of the app in the `package.json` file and open a PR. GitHub Actions will build, sign and upload the release assets for each commit to that branch as long as a branch is named like `release/vX.X.X` and there is a draft release with the same version number(`package.json`). + 4. Merge your release branch into `master`. + 5. Publish the draft release once you've added notes to it and all assets are there. ### Tests -There are 2 linters for `js` & `scss` and unit tests with `jest`. +There are 2 checks - one for prettier and one for the unit tests with `jest`. - // Run only unit tests - yarn run jest + // Run prettier to check + yarn run prettier-check // Run linter & unit tests with coverage yarn run test + // Run jest directly - allows to pass arguments like `--watch` + yarn run jest + ### FAQ #### My notifications aren't showing? diff --git a/package.json b/package.json index bb991d9ea..d166ff253 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "gitify", - "version": "3.0.0", + "version": "3.0.1", "description": "GitHub Notifications on your menu bar.", "main": "main.js", "scripts": { @@ -50,6 +50,9 @@ "homepage": "https://www.gitify.io/", "jest": { "preset": "ts-jest/presets/js-with-ts", + "setupFiles": [ + "/src/js/__helpers__/setupEnvVars.js" + ], "testEnvironment": "jsdom", "coverageThreshold": { "global": { diff --git a/src/js/__helpers__/setupEnvVars.js b/src/js/__helpers__/setupEnvVars.js new file mode 100644 index 000000000..a9ea03aef --- /dev/null +++ b/src/js/__helpers__/setupEnvVars.js @@ -0,0 +1,2 @@ +process.env.OAUTH_CLIENT_ID = 'FAKE_CLIENT_ID_123'; +process.env.OAUTH_CLIENT_SECRET = 'FAKE_CLIENT_SECRET_123'; diff --git a/src/js/utils/constants.tsx b/src/js/utils/constants.tsx index b86e6e63f..753da0e85 100644 --- a/src/js/utils/constants.tsx +++ b/src/js/utils/constants.tsx @@ -4,8 +4,8 @@ export default { DEFAULT_AUTH_OPTIONS: { hostname: 'github.com', - clientId: '3fef4433a29c6ad8f22c', - clientSecret: '9670de733096c15322183ff17ed0fc8704050379', + clientId: process.env.OAUTH_CLIENT_ID, + clientSecret: process.env.OAUTH_CLIENT_SECRET, }, REPO_SLUG: 'manosim/gitify', diff --git a/src/js/utils/helpers.test.ts b/src/js/utils/helpers.test.ts index ce4e181df..41f19ba28 100644 --- a/src/js/utils/helpers.test.ts +++ b/src/js/utils/helpers.test.ts @@ -111,7 +111,7 @@ describe('utils/helpers.ts', () => { expect(new BrowserWindow().loadURL).toHaveBeenCalledTimes(1); expect(new BrowserWindow().loadURL).toHaveBeenCalledWith( - 'https://github.com/login/oauth/authorize?client_id=3fef4433a29c6ad8f22c&scope=user:email,notifications' + 'https://github.com/login/oauth/authorize?client_id=FAKE_CLIENT_ID_123&scope=user:email,notifications' ); expect(new BrowserWindow().destroy).toHaveBeenCalledTimes(1); @@ -171,7 +171,7 @@ describe('utils/helpers.ts', () => { expect(new BrowserWindow().loadURL).toHaveBeenCalledTimes(1); expect(new BrowserWindow().loadURL).toHaveBeenCalledWith( - 'https://github.com/login/oauth/authorize?client_id=3fef4433a29c6ad8f22c&scope=user:email,notifications' + 'https://github.com/login/oauth/authorize?client_id=FAKE_CLIENT_ID_123&scope=user:email,notifications' ); expect(new BrowserWindow().destroy).toHaveBeenCalledTimes(1); diff --git a/webpack.common.js b/webpack.common.js index 7592b98d6..dcc2a111d 100644 --- a/webpack.common.js +++ b/webpack.common.js @@ -1,4 +1,5 @@ const path = require('path'); +const webpack = require('webpack'); module.exports = { mode: 'development', @@ -14,6 +15,13 @@ module.exports = { }, ], }, + plugins: [ + new webpack.EnvironmentPlugin({ + // Development Keys - See README.md + OAUTH_CLIENT_ID: '3fef4433a29c6ad8f22c', + OAUTH_CLIENT_SECRET: '9670de733096c15322183ff17ed0fc8704050379', + }), + ], resolve: { extensions: ['.tsx', '.ts', '.js'], },