Skip to content

Commit

Permalink
[CLNP-3380] chore: add release automation workflow (#1099)
Browse files Browse the repository at this point in the history
Our current release steps are like below. 
1. Preparation
  a. Create a release branch; `release/v{version}`
  b. Update package.json
  c. Write CHANGELOG
  d. Push to remote
  e. create a PR
2. Run `/bot create ticket` to create a release ticket and get an
approval from a manager
3. Once 2 is done, run `yarn run build` -> `cd dist` -> `yarn npm
publish`


This workflow will cover step 3. Step 1 & 2 need to be done manually as
we've done.

### How can we trigger the workflow?
<img width="367" alt="Screenshot 2024-05-22 at 4 39 15 PM"
src="https://github.com/sendbird/sendbird-uikit-react/assets/10060731/95d0030b-d200-417b-aff2-3520c91195aa">

```mermaid
graph TD
  A[Start: Run workflow] --> B[Check if release branch exists]
  B --> C{npm_tag provided?}
  C -- Yes --> E[Update version in package.json]
  C -- No --> F[Install and Build]
  E --> F
  F --> G[Publish to npm]
  G --> H{npm_tag provided?}
  H -- Yes --> I[Publish with tag] --> End
  H -- No --> J[Publish without tag]
  J --> L[Tag new target and push to origin]
  L --> End
```
  • Loading branch information
AhyoungRyu authored May 23, 2024
1 parent 49d57ae commit 6b64ee2
Showing 1 changed file with 66 additions and 0 deletions.
66 changes: 66 additions & 0 deletions .github/workflows/package-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
name: Package build and 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@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}
fetch-depth: 0
- uses: actions/setup-node@v4
with:
node-version: 18.x
cache: 'yarn'
- 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: Setup jq
if: ${{ github.event.inputs.npm_tag }}
uses: dcarbone/install-jq-action@v2
- name: Update version in package.json if npm_tag is provided
if: ${{ github.event.inputs.npm_tag }}
run: |
npm_version="${{ github.event.inputs.version }}-${{ github.event.inputs.npm_tag }}"
jq --arg npm_version "$npm_version" '.version = $npm_version' package.json > package.json.tmp && mv package.json.tmp package.json
- name: Set environments
run: |
git config --global user.name "sendbird-sdk-deployment"
git config --global user.email "[email protected]"
- name: Install and Build
run: |
yarn install --immutable --immutable-cache
yarn build
- name: Publish to npm
run: |
echo "//registry.npmjs.org/:_authToken=${{ secrets.npm_token }}" >> .npmrc
cd dist
if [ -z "${{ github.event.inputs.npm_tag }}" ]; then
yarn npm publish --access=public
else
yarn npm publish --tag ${{ github.event.inputs.npm_tag }} --access=public
echo "npm_tag is provided; Skipping the rest of the steps."
exit 1
fi
cd -
- name: Tag new target and push to origin
run: |
git tag v${{ github.event.inputs.version }}
git push origin v${{ github.event.inputs.version }}

0 comments on commit 6b64ee2

Please sign in to comment.