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

feat: general maintenance of ci/cd #504

Merged
merged 2 commits into from
Apr 28, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
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
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ test/integration/utils/kjur.js
/.git/
/docs/
**/*.sh
get_changelog_diff.js
5 changes: 3 additions & 2 deletions .github/actions/setup-node/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,16 @@ runs:
using: 'composite'
steps:
- name: Setup Node
uses: actions/setup-node@v2
uses: actions/setup-node@v3
with:
node-version: ${{ inputs.node-version }}
- name: Cache Dependencies
uses: actions/cache@v2
uses: actions/cache@v3
with:
path: ./node_modules
key: ${{ runner.os }}-${{ inputs.node-version }}-modules-${{ hashFiles('**/yarn.lock') }}
restore-keys: ${{ runner.os }}-${{ inputs.node-version }}-modules-

- name: Install Dependencies & Build
run: yarn install --frozen-lockfile --ignore-engines
shell: bash
2 changes: 1 addition & 1 deletion .github/workflows/browser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
browser:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- uses: ./.github/actions/setup-node
- name: Test
env:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/cloud.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
qa:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- uses: ./.github/actions/setup-node
- name: Test
env:
Expand Down
68 changes: 68 additions & 0 deletions .github/workflows/initiate_release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
name: Create release PR

on:
workflow_dispatch:
inputs:
version:
description: "The new version number with 'v' prefix. Example: v1.40.1"
required: true

jobs:
init_release:
name: 🚀 Create release PR
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0 # gives the changelog generator access to all previous commits

- name: Get current tag
id: previoustag
uses: WyriHaximus/github-action-get-previous-tag@v1

- name: Ensure version number higher than current
uses: actions/github-script@v5
env:
PREVIOUS_TAG: ${{ steps.previoustag.outputs.tag }}
DESTINATION_TAG: ${{ github.event.inputs.version }}
with:
script: |
const { PREVIOUS_TAG, DESTINATION_TAG } = process.env;
const result = DESTINATION_TAG.localeCompare(PREVIOUS_TAG, undefined, { numeric: true, sensitivity: 'base' })

if (result != 1) {
throw new Error('The new version number must be greater than the previous one.')
}

- name: Restore dependencies
uses: ./.github/actions/setup-node

- name: Update CHANGELOG.md, package.json and push release branch
env:
VERSION: ${{ github.event.inputs.version }}
run: |
npm run changelog
git config --global user.name 'github-actions'
git config --global user.email 'release@getstream.io'
git checkout -q -b "release-$VERSION"
git commit -am "chore(release): $VERSION"
git push -q -u origin "release-$VERSION"

- name: Get changelog diff
uses: actions/github-script@v5
with:
script: |
const get_change_log_diff = require('./scripts/get_changelog_diff.js')
core.exportVariable('CHANGELOG', get_change_log_diff())

- name: Open pull request
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh pr create \
-t "chore(release): ${{ github.event.inputs.version }}" \
-b "# :rocket: ${{ github.event.inputs.version }}
Make sure to use squash & merge when merging!
Once this is merged, another job will kick off automatically and publish the package.
# :memo: Changelog
${{ env.CHANGELOG }}"
2 changes: 1 addition & 1 deletion .github/workflows/integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
integration:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- uses: ./.github/actions/setup-node
- name: Test
env:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- uses: ./.github/actions/setup-node
- name: Lint
run: yarn run lint
42 changes: 42 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: Release

on:
pull_request:
types: [closed]
branches:
- main

jobs:
Release:
name: 🚀 Release
if: github.event.pull_request.merged && startsWith(github.head_ref, 'release-')
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0

- uses: actions/github-script@v5
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
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
ferhatelmas marked this conversation as resolved.
Show resolved Hide resolved

- name: Create release on GitHub
uses: ncipollo/release-action@v1
with:
body: ${{ env.CHANGELOG }}
tag: ${{ env.VERSION }}
token: ${{ secrets.GITHUB_TOKEN }}
4 changes: 2 additions & 2 deletions .github/workflows/size.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: preactjs/compressed-size-action@v2.0.1
- uses: actions/checkout@v3
- uses: preactjs/compressed-size-action@v2
with:
repo-token: '${{ secrets.GITHUB_TOKEN }}'
build-script: 'dist'
2 changes: 1 addition & 1 deletion .github/workflows/type.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
types:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- uses: ./.github/actions/setup-node
- name: Type check
run: yarn run types
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/unit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
matrix:
node: [12, 14, 16]
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- uses: ./.github/actions/setup-node
with:
node-version: ${{ matrix.node }}
Expand Down
41 changes: 29 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,33 @@
# Stream-JS

[![build](https://github.com/GetStream/stream-js/workflows/build/badge.svg)](https://github.com/GetStream/stream-js/actions)
# Official JavaScript SDK for [Stream Feeds](https://getstream.io/activity-feeds/)

[![build](https://github.com/GetStream/stream-js/workflows/build/badge.svg)](https://github.com/GetStream/stream-js/actions)
[![NPM](https://nodei.co/npm/getstream.png)](https://nodei.co/npm/getstream/)

<p align="center">
<img src="./assets/logo.svg" width="50%" height="50%">
</p>
<p align="center">
Official JavaScript API client for Stream Feeds, a web service for building scalable newsfeeds and activity streams.
<br />
<a href="https://getstream.io/activity-feeds/docs/?language=javascript"><strong>Explore the docs »</strong></a>
<br />
<br />
<a href="https://github.com/GetStream/stream-js/issues">Report Bug</a>
·
<a href="https://github.com/GetStream/stream-js/issues">Request Feature</a>
</p>

## 📝 About Stream

[stream-js](https://github.com/GetStream/stream-js) is the official JavaScript client for [Stream](https://getstream.io/), a web service for building scalable newsfeeds and activity streams.

Note that there is also a [higher level Node integration](https://github.com/getstream/stream-node-orm) which hooks into your ORM.

You can sign up for a Stream account at https://getstream.io/get_started.

### Installation
## ⚙️ Installation

#### Install from NPM/YARN
### Install from NPM/YARN

```bash
npm install getstream
Expand All @@ -36,22 +51,22 @@ yarn add getstream
<script src="https://cdn.jsdelivr.net/npm/getstream@5.0.0/dist/js_min/getstream.js"></script>
```

#### Install by downloading the JS file
### Install by downloading the JS file

[JS](https://github.com/GetStream/stream-js/main/dist/js/getstream.js) /
[Minified JS](https://github.com/GetStream/stream-js/main/dist/js_min/getstream.js)

> :warning: Beware about the version you're pulling. It's the latest by default which can break your app anytime.

### Full documentation
## 📚 Full documentation

Documentation for this JavaScript client are available at the [Stream website](https://getstream.io/docs/?language=js).

#### Using with React Native

This package can be integrated into React Native applications. Remember to not expose the App Secret in browsers, "native" mobile apps, or other non-trusted environments.

### Usage
## ✨ Getting started

### API client setup Node

Expand Down Expand Up @@ -359,15 +374,15 @@ subscription.cancel();

Docs are available on [GetStream.io](http://getstream.io/docs/?language=js).

#### Node version requirements & Browser support
## ⚠️ Node version requirements & Browser support

This API Client project requires Node.js v10 at a minimum.

The project is supported in line with the Node.js Foundation Release Working Group.

See the [github action configuration](.github/workflows/ci.yml) for details of how it is built, tested and packaged.
See the [github action configuration](.github/workflows/) for details of how it is built, tested and packaged.

## Contributing
## ♻️ Contributing

See extensive at [test documentation](test/README.md) for your changes.

Expand All @@ -377,7 +392,9 @@ You can find generic API documentation enriched by code snippets from this packa

Project is licensed under the [BSD 3-Clause](LICENSE).

## We are hiring!
We welcome code changes that improve this library or fix a problem, please make sure to follow all best practices and add tests if applicable before submitting a Pull Request on Github. We are very happy to merge your code in the official repository. Make sure to sign our [Contributor License Agreement (CLA)](https://docs.google.com/forms/d/e/1FAIpQLScFKsKkAJI7mhCr7K9rEIOpqIDThrWxuvxnwUq2XkHyG154vQ/viewform) first. See our [license file](./LICENSE) for more details.

## 🧑‍💻 We are hiring!

We've recently closed a [$38 million Series B funding round](https://techcrunch.com/2021/03/04/stream-raises-38m-as-its-chat-and-activity-feed-apis-power-communications-for-1b-users/) and we keep actively growing.
Our APIs are used by more than a billion end-users, and you'll have a chance to make a huge impact on the product within a team of the strongest engineers all over the world.
Expand Down
16 changes: 16 additions & 0 deletions assets/logo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
26 changes: 26 additions & 0 deletions scripts/get_changelog_diff.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/*
Here we're trying to parse the latest changes from CHANGELOG.md file.
The changelog looks like this:

## 0.0.3
- Something #3
## 0.0.2
- Something #2
## 0.0.1
- Something #1

In this case we're trying to extract "- Something #3" since that's the latest change.
*/
module.exports = () => {
const fs = require('fs');

changelog = fs.readFileSync('CHANGELOG.md', 'utf8');
releases = changelog.match(/## [?[0-9](.+)/g);

current_release = changelog.indexOf(releases[0]);
previous_release = changelog.indexOf(releases[1]);

latest_changes = changelog.substr(current_release, previous_release - current_release);

return latest_changes;
};