Skip to content

Commit 6b64ee2

Browse files
authored
[CLNP-3380] chore: add release automation workflow (#1099)
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 ```
1 parent 49d57ae commit 6b64ee2

File tree

1 file changed

+66
-0
lines changed

1 file changed

+66
-0
lines changed
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
name: Package build and publish
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
version:
7+
description: 'version'
8+
required: true
9+
type: string
10+
npm_tag:
11+
description: 'release tag'
12+
required: false
13+
type: string
14+
15+
jobs:
16+
publish:
17+
runs-on: ubuntu-latest
18+
steps:
19+
- uses: actions/checkout@v4
20+
with:
21+
token: ${{ secrets.GITHUB_TOKEN }}
22+
fetch-depth: 0
23+
- uses: actions/setup-node@v4
24+
with:
25+
node-version: 18.x
26+
cache: 'yarn'
27+
- name: Check if the release branch exists
28+
run: |
29+
set -x
30+
branch_name="release/v${{ github.event.inputs.version }}"
31+
if ! git ls-remote --exit-code --heads origin "$branch_name" > /dev/null; then
32+
echo "Branch $branch_name does not exist. Make sure to create the branch and create a Jira ticket with pr-comment-bot."
33+
exit 1
34+
fi
35+
- name: Setup jq
36+
if: ${{ github.event.inputs.npm_tag }}
37+
uses: dcarbone/install-jq-action@v2
38+
- name: Update version in package.json if npm_tag is provided
39+
if: ${{ github.event.inputs.npm_tag }}
40+
run: |
41+
npm_version="${{ github.event.inputs.version }}-${{ github.event.inputs.npm_tag }}"
42+
jq --arg npm_version "$npm_version" '.version = $npm_version' package.json > package.json.tmp && mv package.json.tmp package.json
43+
- name: Set environments
44+
run: |
45+
git config --global user.name "sendbird-sdk-deployment"
46+
git config --global user.email "[email protected]"
47+
- name: Install and Build
48+
run: |
49+
yarn install --immutable --immutable-cache
50+
yarn build
51+
- name: Publish to npm
52+
run: |
53+
echo "//registry.npmjs.org/:_authToken=${{ secrets.npm_token }}" >> .npmrc
54+
cd dist
55+
if [ -z "${{ github.event.inputs.npm_tag }}" ]; then
56+
yarn npm publish --access=public
57+
else
58+
yarn npm publish --tag ${{ github.event.inputs.npm_tag }} --access=public
59+
echo "npm_tag is provided; Skipping the rest of the steps."
60+
exit 1
61+
fi
62+
cd -
63+
- name: Tag new target and push to origin
64+
run: |
65+
git tag v${{ github.event.inputs.version }}
66+
git push origin v${{ github.event.inputs.version }}

0 commit comments

Comments
 (0)