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

[AC-1856] Add publish automation workflows #138

Merged
merged 8 commits into from
Apr 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
File renamed without changes.
77 changes: 77 additions & 0 deletions .github/workflows/package-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
name: publish

on:
workflow_dispatch:
inputs:
version:
description: 'version'
required: true
type: string
npm_tag:
description: 'release tag'
required: false
type: string

jobs:
publish:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: actions/setup-node@v3
with:
node-version: 16.x
- name: Check if the release branch exists
run: |
set -x
branch_name="release/v${{ github.event.inputs.version }}"
if ! git ls-remote --exit-code --heads origin "$branch_name" > /dev/null; then
echo "Branch $branch_name does not exist. Make sure to create the branch and create a Jira ticket with pr-comment-bot."
exit 1
fi
- name: Install and Build
run: |
npm install
touch .env.production
echo "VITE_CHAT_AI_WIDGET_KEY=${{ secrets.chat_ai_widget_key }}" >> .env.production
npm run build:npm
- name: Publish to npm
run: |
if [ -z "${{ github.event.inputs.npm_tag }}" ]; then
npm publish --access=public
else
npm publish --tag ${{ github.event.inputs.npm_tag }} --access=public
fi
- name: Set environments
run: |
git config --global user.name "sendbird-sdk-deployment"
git config --global user.email "[email protected]"
echo "RELEASE_DATE=$(date +'%b %d %Y')" >> $GITHUB_ENV
echo "LATEST_TAG=$(git describe --tags $(git rev-list --tags --max-count=1))" >> $GITHUB_ENV
- name: Generate CHANEGLOG
run: |
echo "## [$LATEST_TAG] - $RELEASE_DATE" > temp-changelog.md
git log $LATEST_TAG..develop --oneline >> temp-changelog.md
echo "" >> temp-changelog.md
cat CHANGELOG.md >> temp-changelog.md
mv temp-changelog.md CHANGELOG.md
git commit -m "Update CHANGELOG.md for $LATEST_TAG"
git push origin v${{ github.event.inputs.version }}
- name: Update installed chat-ai-widget version to latest under packages/*
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
packages=( "url-webdemo" "self-service" )
for package in "${packages[@]}"; do
cd ./packages/$package
npm install @sendbird/chat-ai-widget@${{ github.event.inputs.version }}
cd -
done
git add .
git commit -m "chore: update chat-ai-widget version to v${{ github.event.inputs.version }}"
git push origin release/v${{ github.event.inputs.version }}
- name: Tag new target and push to origin
run: |
git tag v${{ github.event.inputs.version }}
git push origin v${{ github.event.inputs.version }}
18 changes: 0 additions & 18 deletions packages/self-service/script-publish.md

This file was deleted.

33 changes: 18 additions & 15 deletions release-guide.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,23 @@
# Release Steps

## Step 0 - Setup
1. Create a new branch for the release: e.g. `git checkout -b release/{X.X.X}`
2. Write/Generate changelog in CHANGELOG.md
3. Commit all changes, push to remote
4. Comment `/bot create ticket` on github PR to make release ticket automatically
1. Create a new branch for the release, for example: git checkout -b release/{X.X.X}.
2. Update the version field in package.json. Use the format {version}-rc-0 for Release Candidates (RC), increasing the number as necessary. For the final release, follow the semantic versioning (semver) format.
3. Commit the changes, push them to remote, and create a Pull Request (PR).
4. Comment /bot create ticket on the GitHub PR to automatically generate a release ticket.
5. Obtain approval from your manager for the ticket before proceeding to the next step.

## Step 1 - Release Candidate
1. Update the version in `package.json`: e.g. `version: {version}-rc-0` (increase the number if it's necessary)
2. Run `npm run build:npm` under the root directory
3. Run `npm publish --tag rc`
4. Test the RC version in your project(s) e.g. [CodeSandbox Sample](https://codesandbox.io/s/broken-glitter-6sjw6l?file=/src/App.tsx)
5. If everything is fine, go to Step 2. Otherwise make changes to main branch, rebase and repeat Step 1
## Step 1 - Publish a new chat-ai-widget package (using automated workflow)
1. Navigate to Actions -> [Publish Workflow](./.github/workflows/package-publish.yml) in the GitHub repository.
2. Fill in the version field with the target version (e.g., 1.3.1), and use rc / alpha / beta for the npm_tag field if needed.
3. Once all the steps in the workflow are successfully completed:
- The build output will be published to npm.
- A commit will be pushed to the release PR created in Step 0. This commit includes:
- Changes to the CHANGELOG and version updates.
- `@sendbird/chat-ai-widget` dependency version updated in `/packages/*`.
- A new tag will be pushed to the origin. <- Please use this tag if you wish to publish the changes.

## Step 2 - Actual release
10. Commit all changes
11. Update the version in `package.json` to the new real release version: Run `npm version patch/minor/major`
12. Run `npm run build:npm`
13. Run `npm publish -access=public`
## Step 2 - Deploy a new script under `packages/*`
1. Monitor the package build status on the [Circle CI dashboard](https://app.circleci.com/pipelines/github/sendbird/chat-ai-widget).
2. If the Circle CI dashboard indicates a successful build, proceed to [gate-k8s](https://github.com/sendbird/gate-k8s) and update the `common.version` value in [this file](https://github.com/sendbird/gate-k8s/blob/main/values/aichatbot/prod.yaml) with the tag created in step 1. [This PR](https://github.com/sendbird/gate-k8s/pull/1396) might be helpful to see how you can create a PR in the gate-k8s repository.
3. Once your PR is merged into the main branch in gate-k8s, the new script will be deployed immediately.