Skip to content

Commit 8a57f42

Browse files
New release process
1 parent 1d846c8 commit 8a57f42

File tree

11 files changed

+2462
-219
lines changed

11 files changed

+2462
-219
lines changed

.github/workflows/initiate_release.yml

Lines changed: 0 additions & 68 deletions
This file was deleted.

.github/workflows/lint.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515

1616
- uses: ./.github/actions/setup-node
1717

18-
- name: Commit message lint
18+
- name: Commit Message Lint
1919
run: echo "${{ github.event.pull_request.title }}" | yarn commitlinter
2020

2121
- name: Lint

.github/workflows/release.yml

Lines changed: 25 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,35 @@
11
name: Release
2-
32
on:
4-
pull_request:
5-
types: [closed]
6-
branches:
7-
- master
3+
workflow_dispatch:
4+
inputs:
5+
dry_run:
6+
description: Run package release in "dry run" mode (does not publish)
7+
default: false
8+
type: boolean
89

910
jobs:
10-
Release:
11-
name: 🚀 Release
12-
if: github.event.pull_request.merged && startsWith(github.head_ref, 'release-')
11+
package_release:
12+
name: Release From "${{ github.ref_name }}" Branch
1313
runs-on: ubuntu-latest
14+
# GH does not allow to limit branches in the workflow_dispatch settings so this here is a safety measure
15+
if: ${{ inputs.dry_run || startsWith(github.ref_name, 'release') || startsWith(github.ref_name, 'master') }}
1416
steps:
15-
- uses: actions/checkout@v3
17+
- name: Checkout
18+
uses: actions/checkout@v4
1619
with:
1720
fetch-depth: 0
18-
19-
- uses: actions/github-script@v6
21+
- name: Setup Node.js
22+
uses: actions/setup-node@v4
2023
with:
21-
script: |
22-
const get_change_log_diff = require('./scripts/get_changelog_diff.js')
23-
core.exportVariable('CHANGELOG', get_change_log_diff())
24-
25-
// Getting the release version from the PR source branch
26-
// Source branch looks like this: release-1.0.0
27-
const version = context.payload.pull_request.head.ref.split('-')[1]
28-
core.exportVariable('VERSION', version)
29-
30-
- uses: ./.github/actions/setup-node
31-
32-
- name: Publish package
33-
run: npm publish
24+
node-version: 22
25+
- name: Install Dependencies & Build
26+
run: yarn install --frozen-lockfile
27+
- name: Release
3428
env:
35-
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
36-
37-
- name: Create release on GitHub
38-
uses: ncipollo/release-action@v1
39-
with:
40-
body: ${{ env.CHANGELOG }}
41-
tag: ${{ env.VERSION }}
42-
token: ${{ secrets.GITHUB_TOKEN }}
29+
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
30+
# https://github.com/stream-ci-bot
31+
GH_TOKEN: ${{ secrets.DOCUSAURUS_GH_TOKEN }}
32+
HUSKY: 0
33+
run: >
34+
yarn semantic-release
35+
${{ inputs.dry_run && '--dry-run' || '' }}

.mocharc.json

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,5 @@
33
"bail": true,
44
"exit": true,
55
"timeout": 20000,
6-
"require": [
7-
"ts-node/register"
8-
]
9-
}
6+
"require": ["ts-node/register"]
7+
}

.releaserc.json

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
{
2+
"branches": [
3+
{
4+
"name": "master",
5+
"channel": "latest"
6+
},
7+
{
8+
"name": "release-v8",
9+
"channel": "v8",
10+
"range": "8.x"
11+
}
12+
],
13+
"plugins": [
14+
[
15+
"@semantic-release/commit-analyzer",
16+
{
17+
"preset": "angular",
18+
"releaseRules": [
19+
{ "type": "chore", "scope": "deps", "release": "patch" },
20+
{ "type": "refactor", "release": "patch" }
21+
]
22+
}
23+
],
24+
[
25+
"@semantic-release/release-notes-generator",
26+
{
27+
"preset": "conventionalcommits",
28+
"presetConfig": {
29+
"types": [
30+
{
31+
"type": "fix",
32+
"section": "Bug Fixes",
33+
"hidden": false
34+
},
35+
{
36+
"type": "feat",
37+
"section": "Features",
38+
"hidden": false
39+
},
40+
{
41+
"type": "chore",
42+
"scope": "deps",
43+
"section": "Chores",
44+
"hidden": false
45+
},
46+
{
47+
"type": "refactor",
48+
"section": "Refactors",
49+
"hidden": false
50+
},
51+
{
52+
"type": "perf",
53+
"section": "Performance Improvements",
54+
"hidden": false
55+
}
56+
]
57+
}
58+
}
59+
],
60+
[
61+
"@semantic-release/exec",
62+
{
63+
"prepareCmd": "NEXT_VERSION=${nextRelease.version} npm run build"
64+
}
65+
],
66+
[
67+
"@semantic-release/changelog",
68+
{
69+
"changelogFile": "./CHANGELOG.md"
70+
}
71+
],
72+
[
73+
"@semantic-release/git",
74+
{
75+
"assets": ["./CHANGELOG.md"]
76+
}
77+
],
78+
"@semantic-release/github",
79+
"@semantic-release/npm"
80+
]
81+
}

package.json

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "stream-chat",
3-
"version": "8.56.1",
3+
"version": "0.0.0-development",
44
"description": "JS SDK for the Stream Chat API",
55
"homepage": "https://getstream.io/chat/",
66
"author": {
@@ -61,6 +61,9 @@
6161
"devDependencies": {
6262
"@commitlint/cli": "^16.0.2",
6363
"@commitlint/config-conventional": "^16.0.0",
64+
"@semantic-release/changelog": "^6.0.3",
65+
"@semantic-release/exec": "^7.0.3",
66+
"@semantic-release/git": "^10.0.1",
6467
"@types/base64-js": "^1.3.0",
6568
"@types/chai": "^4.2.15",
6669
"@types/chai-arrays": "^2.0.0",
@@ -80,6 +83,7 @@
8083
"chai-like": "^1.1.1",
8184
"chai-sorted": "^0.2.0",
8285
"concurrently": "^9.1.2",
86+
"conventional-changelog-conventionalcommits": "^8.0.0",
8387
"dotenv": "^8.2.0",
8488
"esbuild": "^0.25.0",
8589
"eslint": "7.21.0",
@@ -93,6 +97,7 @@
9397
"mocha": "^11.1.0",
9498
"nyc": "^15.1.0",
9599
"prettier": "^2.2.1",
100+
"semantic-release": "^24.2.3",
96101
"sinon": "^12.0.1",
97102
"standard-version": "^9.3.2",
98103
"ts-node": "^10.9.2",
@@ -102,7 +107,6 @@
102107
},
103108
"scripts": {
104109
"start": "tsc --watch",
105-
"changelog": "standard-version --release-as $VERSION --skip.tag --skip.commit --tag-prefix=v",
106110
"commitlinter": "commitlint",
107111
"build": "rm -rf dist && yarn bundle",
108112
"bundle": "concurrently 'tsc --declaration --emitDeclarationOnly --outDir ./dist/types' ./scripts/bundle.mjs",
@@ -119,10 +123,7 @@
119123
"lint": "yarn run prettier && yarn run eslint",
120124
"lint-fix": "yarn run prettier-fix && yarn run eslint-fix",
121125
"fix-staged": "lint-staged --config .lintstagedrc.fix.json --concurrent 1",
122-
"prepare": "yarn run build",
123-
"preversion": "yarn && yarn lint && yarn test-unit",
124-
"version": "git add yarn.lock",
125-
"postversion": "git push && git push --tags && npm publish"
126+
"semantic-release": "semantic-release"
126127
},
127128
"engines": {
128129
"node": ">=16"

scripts/bundle.mjs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import { resolve } from 'node:path';
44
import * as esbuild from 'esbuild';
55
import packageJson from '../package.json' with {'type': 'json'};
6+
import getPackageVersion from './get-package-version.mjs';
67

78
// import.meta.dirname is not available before Node 20
89
const __dirname = import.meta.dirname;
@@ -11,6 +12,8 @@ const __dirname = import.meta.dirname;
1112
// in our CJS bundle. We convert them to CJS and bundle them instead.
1213
const bundledDeps = ['axios', 'form-data', 'isomorphic-ws', 'base64-js'];
1314

15+
const version = getPackageVersion();
16+
1417
const deps = Object.keys({
1518
...packageJson.dependencies,
1619
...packageJson.peerDependencies,
@@ -24,7 +27,7 @@ const commonBuildOptions = {
2427
target: 'ES2020',
2528
sourcemap: 'linked',
2629
define: {
27-
'process.env.PKG_VERSION': JSON.stringify(packageJson.version),
30+
'process.env.PKG_VERSION': JSON.stringify(version),
2831
},
2932
};
3033

scripts/get-package-version.mjs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import { execSync } from 'node:child_process';
2+
import packageJson from '../package.json' with { type: 'json' };
3+
4+
// Get the latest version so that magic string __STREAM_CHAT_REACT_VERSION__ can be replaced with it in the source code (used for reporting purposes)
5+
export default function getPackageVersion() {
6+
let version;
7+
// During release, use the version being released
8+
// see .releaserc.json where the `NEXT_VERSION` env variable is set
9+
if (process.env.NEXT_VERSION) {
10+
version = process.env.NEXT_VERSION;
11+
} else {
12+
// Otherwise use the latest git tag
13+
try {
14+
version = execSync('git describe --tags --abbrev=0').toString().trim();
15+
} catch (error) {
16+
console.error(error);
17+
console.warn('Could not get latest version from git tags, falling back to package.json');
18+
version = packageJson.version;
19+
}
20+
}
21+
console.log(`Determined the build package version to be ${version}`);
22+
return version;
23+
}

scripts/get_changelog_diff.js

Lines changed: 0 additions & 26 deletions
This file was deleted.

tsconfig.test.json

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,11 @@
33
"compilerOptions": {
44
"moduleResolution": "node10",
55
"module": "CommonJS",
6-
"strict": false,
6+
"strict": false
77
},
88
"ts-node": {
99
"transpileOnly": true,
10-
"logError": true,
10+
"logError": true
1111
},
12-
"include": [
13-
"./test/**/*"
14-
]
15-
}
12+
"include": ["./test/**/*"]
13+
}

0 commit comments

Comments
 (0)