From 2573b9475472c660af449062003fc8127519b104 Mon Sep 17 00:00:00 2001 From: peterdeme Date: Wed, 20 Apr 2022 14:47:02 +0200 Subject: [PATCH] chore(maintenance): general maintenance --- .github/workflows/ci.yml | 36 ++++++++++++++++ .github/workflows/gradle.yml | 48 ---------------------- .github/workflows/initiate_release.yml | 47 +++++++++++++++++++++ .github/workflows/release.yml | 50 ++++++++++++++++++++++ .versionrc.js | 16 ++++++++ README.md | 57 +++++++++++++++----------- assets/logo.svg | 16 ++++++++ scripts/get_changelog_diff.js | 26 ++++++++++++ 8 files changed, 224 insertions(+), 72 deletions(-) create mode 100644 .github/workflows/ci.yml delete mode 100644 .github/workflows/gradle.yml create mode 100644 .github/workflows/initiate_release.yml create mode 100644 .github/workflows/release.yml create mode 100644 .versionrc.js create mode 100644 assets/logo.svg create mode 100644 scripts/get_changelog_diff.js diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 00000000..67e7253e --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,36 @@ +name: build + +on: [pull_request] + +concurrency: + group: ${{ github.workflow }}-${{ github.head_ref }} + cancel-in-progress: true + +jobs: + build: + name: πŸ§ͺ Test & lint + runs-on: ubuntu-latest + steps: + - name: Check out code + uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - name: Commit message lint + uses: wagoid/commitlint-github-action@v4 + + - name: Restore cache + uses: actions/cache@v3 + with: + path: ~/.gradle/caches + key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }} + restore-keys: | + ${{ runner.os }}-gradle- + + - name: Test + env: + STREAM_KEY: ${{ secrets.STREAM_KEY }} + STREAM_SECRET: ${{ secrets.STREAM_SECRET }} + run: | + ./gradlew spotlessCheck --no-daemon + ./gradlew test --no-daemon diff --git a/.github/workflows/gradle.yml b/.github/workflows/gradle.yml deleted file mode 100644 index 3c1dd2d2..00000000 --- a/.github/workflows/gradle.yml +++ /dev/null @@ -1,48 +0,0 @@ -name: build - -on: [push] - -concurrency: - group: ${{ github.workflow }} - cancel-in-progress: true - -jobs: - build: - name: Release build and publish - runs-on: ubuntu-latest - steps: - - name: Check out code - uses: actions/checkout@v2 - - - name: Restore cache - uses: actions/cache@v2 - with: - path: ~/.gradle/caches - key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }} - restore-keys: | - ${{ runner.os }}-gradle- - - - name: Test - if: startsWith(github.ref , 'refs/tags/') != true - env: - STREAM_KEY: ${{ secrets.STREAM_KEY }} - STREAM_SECRET: ${{ secrets.STREAM_SECRET }} - run: | - ./gradlew spotlessCheck --no-daemon - ./gradlew test --no-daemon - - - name: Publish to MavenCentral - if: startsWith(github.ref, 'refs/tags/') - run: | - sudo bash -c "echo '$GPG_KEY_CONTENTS' | base64 -d > '$SIGNING_SECRET_KEY_RING_FILE'" - ./gradlew publishReleasePublicationToSonatypeRepository --no-daemon --max-workers 1 closeAndReleaseSonatypeStagingRepository - env: - STREAM_KEY: ${{ secrets.STREAM_KEY }} - STREAM_SECRET: ${{ secrets.STREAM_SECRET }} - GPG_KEY_CONTENTS: ${{ secrets.GPG_KEY_CONTENTS }} - OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }} - OSSRH_PASSWORD: ${{ secrets.OSSRH_PASSWORD }} - SIGNING_KEY_ID: ${{ secrets.SIGNING_KEY_ID }} - SIGNING_PASSWORD: ${{ secrets.SIGNING_PASSWORD }} - SIGNING_SECRET_KEY_RING_FILE: ${{ secrets.SIGNING_SECRET_KEY_RING_FILE }} - SONATYPE_STAGING_PROFILE_ID: ${{ secrets.SONATYPE_STAGING_PROFILE_ID }} diff --git a/.github/workflows/initiate_release.yml b/.github/workflows/initiate_release.yml new file mode 100644 index 00000000..9233cfcd --- /dev/null +++ b/.github/workflows/initiate_release.yml @@ -0,0 +1,47 @@ +name: Create release PR + +on: + workflow_dispatch: + inputs: + version: + description: "The new version number. Example: 1.40.1" + required: true + +jobs: + init_release: + name: πŸš€ Create release PR + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + with: + fetch-depth: 0 # gives the changelog generator access to all previous commits + + - name: Update CHANGELOG.md, build.gradle and push release branch + env: + VERSION: ${{ github.event.inputs.version }} + run: | + npx --yes standard-version@9.3.2 --release-as "$VERSION" --skip.tag --skip.commit --tag-prefix= + 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 "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 }}" diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 00000000..b5bb0739 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,50 @@ +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) + + - name: Publish to MavenCentral + run: | + sudo bash -c "echo '$GPG_KEY_CONTENTS' | base64 -d > '$SIGNING_SECRET_KEY_RING_FILE'" + ./gradlew publishReleasePublicationToSonatypeRepository --no-daemon --max-workers 1 closeAndReleaseSonatypeStagingRepository + env: + STREAM_KEY: ${{ secrets.STREAM_KEY }} + STREAM_SECRET: ${{ secrets.STREAM_SECRET }} + GPG_KEY_CONTENTS: ${{ secrets.GPG_KEY_CONTENTS }} + OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }} + OSSRH_PASSWORD: ${{ secrets.OSSRH_PASSWORD }} + SIGNING_KEY_ID: ${{ secrets.SIGNING_KEY_ID }} + SIGNING_PASSWORD: ${{ secrets.SIGNING_PASSWORD }} + SIGNING_SECRET_KEY_RING_FILE: ${{ secrets.SIGNING_SECRET_KEY_RING_FILE }} + SONATYPE_STAGING_PROFILE_ID: ${{ secrets.SONATYPE_STAGING_PROFILE_ID }} + + - name: Create release on GitHub + uses: ncipollo/release-action@v1 + with: + body: ${{ env.CHANGELOG }} + tag: ${{ env.VERSION }} + token: ${{ secrets.GITHUB_TOKEN }} diff --git a/.versionrc.js b/.versionrc.js new file mode 100644 index 00000000..2367c93c --- /dev/null +++ b/.versionrc.js @@ -0,0 +1,16 @@ +const gradleUpdater = { + VERSION_REGEX: /version = '(.+)'/, + + readVersion: function (contents) { + const version = this.VERSION_REGEX.exec(contents)[1]; + return version; + }, + + writeVersion: function (contents, version) { + return contents.replace(this.VERSION_REGEX.exec(contents)[0], `version = '${version}'`); + } +} + +module.exports = { + bumpFiles: [{ filename: './build.gradle', updater: gradleUpdater }], +} diff --git a/README.md b/README.md index 4aa6898d..68c429fe 100644 --- a/README.md +++ b/README.md @@ -1,12 +1,32 @@ -# stream-java [![Maven Central](https://maven-badges.herokuapp.com/maven-central/io.getstream.client/stream-java/badge.svg?style=flat)](https://maven-badges.herokuapp.com/maven-central/io.getstream.client/stream-java) [![build](https://github.com/GetStream/stream-java/workflows/build/badge.svg)](https://github.com/GetStream/stream-java/actions) +# Official Java SDK for [Stream Feeds](https://getstream.io/activity-feeds/) -[stream-java](https://github.com/GetStream/stream-java) is a Java feed client for [Stream](https://getstream.io/). At the moment, there is no pure Java client for chat but you can find REST docs [here](https://getstream.io/chat/docs_rest/) and an Android specific implementation in Kotlin can be seen [here](https://github.com/GetStream/stream-chat-android). +[![build](https://github.com/GetStream/stream-java/workflows/build/badge.svg)](https://github.com/GetStream/stream-java/actions) -You can sign up for a Stream account at https://getstream.io/get_started. +

+ +

+

+ Official Java API client for Stream Feeds, a web service for building scalable newsfeeds and activity streams. +
+ Explore the docs Β» +
+
+ JavaDoc + Β· + Report Bug + Β· + Request Feature +

---- +## πŸ“ About Stream -### Installation +You can sign up for a Stream account at our [Get Started](https://getstream.io/chat/get_started/) page. + +You can use this library to access feeds API endpoints server-side. + +For the client-side integrations (web and mobile) have a look at the JavaScript, iOS and Android SDK libraries ([docs](https://getstream.io/activity-feeds/)). + +## βš™οΈ Installation Add the following dependency to your `pom.xml`: @@ -29,15 +49,9 @@ you can download it from [here](https://github.com/GetStream/stream-java/release Snapshots of the development version are available in [Sonatype](https://oss.sonatype.org/content/repositories/snapshots/io/getstream/client/) snapshots repository. ---- - -### JDK / JVM version requirements +> πŸ’‘This API Client project requires Java SE 7. -This API Client project requires Java SE 7. - ---- - -### FAQ +## πŸ™‹ FAQ 1. Is Android supported? @@ -49,31 +63,26 @@ If you're using proguard, ensure having following: `-keep class io.getstream.cor Additionally, we're using Jackson JSON processor and see [their definitions](https://github.com/FasterXML/jackson-docs/wiki/JacksonOnAndroid) too unless you're already using it. ---- - -### Full documentation +## πŸ“š Full documentation Documentation for this Java client are available at the [Stream website](https://getstream.io/docs/?language=java). -For examples have a look [here](https://github.com/GetStream/stream-java/tree/master/example/Example.java). +For examples have a look [here](./example/Example.java). Docs are available on [GetStream.io](https://getstream.io/docs/?language=java). JavaDoc is available [here](https://getstream.github.io/stream-java/). ---- - -### Building & Testing +## πŸ§ͺ Building & Testing Run `gradlew test` to execute integration tests ---- -### Copyright and License Information +## ✍️ Contributing -Project is licensed under the [BSD 3-Clause](LICENSE). +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 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. diff --git a/assets/logo.svg b/assets/logo.svg new file mode 100644 index 00000000..1c68c5cc --- /dev/null +++ b/assets/logo.svg @@ -0,0 +1,16 @@ + + + + STREAM MARK + Created with Sketch. + + + + + + + + + + + \ No newline at end of file diff --git a/scripts/get_changelog_diff.js b/scripts/get_changelog_diff.js new file mode 100644 index 00000000..ce034389 --- /dev/null +++ b/scripts/get_changelog_diff.js @@ -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 +}