Skip to content

Commit

Permalink
New release process
Browse files Browse the repository at this point in the history
  • Loading branch information
arnautov-anton committed Feb 26, 2025
1 parent c174fb4 commit 30dce3c
Show file tree
Hide file tree
Showing 9 changed files with 2,457 additions and 210 deletions.
68 changes: 0 additions & 68 deletions .github/workflows/initiate_release.yml

This file was deleted.

2 changes: 1 addition & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:

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

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

- name: Lint
Expand Down
57 changes: 25 additions & 32 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,42 +1,35 @@
name: Release

on:
pull_request:
types: [closed]
branches:
- master
workflow_dispatch:
inputs:
dry_run:
description: Run package release in "dry run" mode (does not publish)
default: false
type: boolean

jobs:
Release:
name: 🚀 Release
if: github.event.pull_request.merged && startsWith(github.head_ref, 'release-')
package_release:
name: Release From "${{ github.ref_name }}" Branch
runs-on: ubuntu-latest
# GH does not allow to limit branches in the workflow_dispatch settings so this here is a safety measure
if: ${{ inputs.dry_run || startsWith(github.ref_name, 'release') || startsWith(github.ref_name, 'master') }}
steps:
- uses: actions/checkout@v3
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0

- uses: actions/github-script@v6
- name: Setup Node.js
uses: actions/setup-node@v4
with:
script: |
const get_change_log_diff = require('./scripts/get_changelog_diff.js')
core.exportVariable('CHANGELOG', get_change_log_diff())
// Getting the release version from the PR source branch
// Source branch looks like this: release-1.0.0
const version = context.payload.pull_request.head.ref.split('-')[1]
core.exportVariable('VERSION', version)
- uses: ./.github/actions/setup-node

- name: Publish package
run: npm publish
node-version: 22
- name: Install Dependencies & Build
run: yarn install --frozen-lockfile
- name: Release
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

- name: Create release on GitHub
uses: ncipollo/release-action@v1
with:
body: ${{ env.CHANGELOG }}
tag: ${{ env.VERSION }}
token: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
# https://github.com/stream-ci-bot
GH_TOKEN: ${{ secrets.DOCUSAURUS_GH_TOKEN }}
HUSKY: 0
run: >
yarn semantic-release
${{ inputs.dry_run && '--dry-run' || '' }}
81 changes: 81 additions & 0 deletions .releaserc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
{
"branches": [
{
"name": "master",
"channel": "latest"
},
{
"name": "release-v8",
"channel": "v8",
"range": "8.x"
}
],
"plugins": [
[
"@semantic-release/commit-analyzer",
{
"preset": "angular",
"releaseRules": [
{ "type": "chore", "scope": "deps", "release": "patch" },
{ "type": "refactor", "release": "patch" }
]
}
],
[
"@semantic-release/release-notes-generator",
{
"preset": "conventionalcommits",
"presetConfig": {
"types": [
{
"type": "fix",
"section": "Bug Fixes",
"hidden": false
},
{
"type": "feat",
"section": "Features",
"hidden": false
},
{
"type": "chore",
"scope": "deps",
"section": "Chores",
"hidden": false
},
{
"type": "refactor",
"section": "Refactors",
"hidden": false
},
{
"type": "perf",
"section": "Performance Improvements",
"hidden": false
}
]
}
}
],
[
"@semantic-release/exec",
{
"prepareCmd": "NEXT_VERSION=${nextRelease.version} npm run build"
}
],
[
"@semantic-release/changelog",
{
"changelogFile": "./CHANGELOG.md"
}
],
[
"@semantic-release/git",
{
"assets": ["./CHANGELOG.md"]
}
],
"@semantic-release/github",
"@semantic-release/npm"
]
}
15 changes: 8 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "stream-chat",
"version": "8.56.1",
"version": "0.0.0-development",
"description": "JS SDK for the Stream Chat API",
"homepage": "https://getstream.io/chat/",
"author": {
Expand Down Expand Up @@ -61,6 +61,9 @@
"devDependencies": {
"@commitlint/cli": "^16.0.2",
"@commitlint/config-conventional": "^16.0.0",
"@semantic-release/changelog": "^6.0.3",
"@semantic-release/exec": "^7.0.3",
"@semantic-release/git": "^10.0.1",
"@types/base64-js": "^1.3.0",
"@types/chai": "^4.2.15",
"@types/chai-arrays": "^2.0.0",
Expand All @@ -80,6 +83,7 @@
"chai-like": "^1.1.1",
"chai-sorted": "^0.2.0",
"concurrently": "^9.1.2",
"conventional-changelog-conventionalcommits": "^8.0.0",
"dotenv": "^8.2.0",
"esbuild": "^0.25.0",
"eslint": "7.21.0",
Expand All @@ -93,6 +97,7 @@
"mocha": "^11.1.0",
"nyc": "^15.1.0",
"prettier": "^2.2.1",
"semantic-release": "^24.2.3",
"sinon": "^12.0.1",
"standard-version": "^9.3.2",
"ts-node": "^10.9.2",
Expand All @@ -102,7 +107,6 @@
},
"scripts": {
"start": "tsc --watch",
"changelog": "standard-version --release-as $VERSION --skip.tag --skip.commit --tag-prefix=v",
"commitlinter": "commitlint",
"build": "rm -rf dist && yarn bundle",
"bundle": "concurrently 'tsc --declaration --emitDeclarationOnly --outDir ./dist/types' ./scripts/bundle.mjs",
Expand All @@ -119,13 +123,10 @@
"lint": "yarn run prettier && yarn run eslint",
"lint-fix": "yarn run prettier-fix && yarn run eslint-fix",
"fix-staged": "lint-staged --config .lintstagedrc.fix.json --concurrent 1",
"prepare": "yarn run build",
"preversion": "yarn && yarn lint && yarn test-unit",
"version": "git add yarn.lock",
"postversion": "git push && git push --tags && npm publish"
"semantic-release": "semantic-release"
},
"engines": {
"node": ">=16"
},
"packageManager": "[email protected]+sha1.1959a18351b811cdeedbd484a8f86c3cc3bbaf72"
}
}
5 changes: 4 additions & 1 deletion scripts/bundle.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import { resolve } from 'node:path';
import * as esbuild from 'esbuild';
import packageJson from '../package.json' with {'type': 'json'};
import getPackageVersion from './get-package-version.mjs';

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

const version = getPackageVersion();

const deps = Object.keys({
...packageJson.dependencies,
...packageJson.peerDependencies,
Expand All @@ -24,7 +27,7 @@ const commonBuildOptions = {
target: 'ES2020',
sourcemap: 'linked',
define: {
'process.env.PKG_VERSION': JSON.stringify(packageJson.version),
'process.env.PKG_VERSION': JSON.stringify(version),
},
};

Expand Down
23 changes: 23 additions & 0 deletions scripts/get-package-version.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { execSync } from 'node:child_process';
import packageJson from '../package.json' with { type: 'json' };

// 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)
export default function getPackageVersion() {
let version;
// During release, use the version being released
// see .releaserc.json where the `NEXT_VERSION` env variable is set
if (process.env.NEXT_VERSION) {
version = process.env.NEXT_VERSION;
} else {
// Otherwise use the latest git tag
try {
version = execSync('git describe --tags --abbrev=0').toString().trim();
} catch (error) {
console.error(error);
console.warn('Could not get latest version from git tags, falling back to package.json');
version = packageJson.version;
}
}
console.log(`Determined the build package version to be ${version}`);
return version;
}
26 changes: 0 additions & 26 deletions scripts/get_changelog_diff.js

This file was deleted.

Loading

0 comments on commit 30dce3c

Please sign in to comment.