Skip to content

Commit 87ea2bc

Browse files
ci: update version bump logic for alpha branch & npm publish in CI (#508)
* ci: update version bump logic for alpha branch & npm publish in CI * ci: allow publish runs for test branch * ci: debug info * ci: test alpha version publishment * ci: push to HEAD:<name-of-remote-branch> when pushing tags after publishment * ci: add check for existing versions on publish attempt * ci: jump over locked alpha.3 version since unpublishment takes up to 72 hours * ci: add notifications to slack * ci: adjust notification text of npm publishment * ci: jump over alpha.4 due to locks in 72 hours * ci: cut off slack announce & version skip of alpha.5 because of 72 hours lock when unpublishing * ci: version skip to alpha.6 & publishing alpha minor patch update if pushing to dev branch or if manually starting up in dev branch, otherwise regular patch version update * ci: working CI for publishment & version jump to alpha.7 * ci: separate build and publish workflows, committing updated package.json * ci: fix alpha version bump check * ci: pushing to branch based on ref_name instead of head_ref * ci: fix of publish with latest or alpha tags based on ref_name * Version bump 2.0.8-alpha.10 * ci: include release tag on npm in slack notification * ci: version bump GUI & fix of setup vars * Version bump 2.0.8-alpha.12 * ci: simplify checks in workflow * Version bump 2.0.8-alpha.13 * ci: removed test/workflow-alpha-version mentions * chore: restore original formatting of build ci workflow config file --------- Co-authored-by: GitHub Actions <github-actions[bot]@users.noreply.github.com>
1 parent 3efa513 commit 87ea2bc

File tree

3 files changed

+139
-4
lines changed

3 files changed

+139
-4
lines changed
Lines changed: 136 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,136 @@
1+
name: Refact Agent GUI CI Publish (Node.js)
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
perform_publish:
7+
required: true
8+
type: boolean
9+
default: false
10+
description: Publish to NPM Registry
11+
push:
12+
branches: [main, dev]
13+
paths:
14+
- 'refact-agent/gui/**'
15+
- '.github/workflows/agent_gui_*'
16+
17+
defaults:
18+
run:
19+
working-directory: refact-agent/gui
20+
21+
jobs:
22+
publish:
23+
runs-on: ubuntu-latest
24+
# Runs only if pushing to dev or main branches,
25+
# or workflow_dispatch with inputs.perform_publish
26+
if: |
27+
inputs.perform_publish ||
28+
(
29+
github.event_name == 'push' &&
30+
(
31+
github.ref_name == 'main' ||
32+
github.ref_name == 'dev'
33+
)
34+
)
35+
36+
steps:
37+
- uses: actions/checkout@v3
38+
with:
39+
fetch-depth: 0
40+
ref: ${{ github.ref_name }}
41+
42+
- name: Use Node.js
43+
uses: actions/setup-node@v3
44+
with:
45+
node-version: 'lts/*'
46+
registry-url: 'https://registry.npmjs.org'
47+
cache: 'npm'
48+
cache-dependency-path: refact-agent/gui/package-lock.json
49+
50+
- name: Install dependencies
51+
run: |
52+
npm pkg delete scripts.prepare
53+
npm ci
54+
55+
- name: Configure Git
56+
run: |
57+
git config --global user.name 'GitHub Actions'
58+
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
59+
60+
- name: Bump version
61+
run: |
62+
VERSION=$(node -p "require('./package.json').version")
63+
echo "Current version: $VERSION"
64+
65+
# Determine version bump type based on branch
66+
if [[ "${{ github.ref_name }}" == "dev" ]]; then
67+
echo "Bumping alpha version..."
68+
npm run alpha:version
69+
else
70+
echo "Bumping patch version..."
71+
npm version patch -m "Bump version to %s [skip ci]"
72+
fi
73+
74+
NEW_VERSION=$(node -p "require('./package.json').version")
75+
echo "New version: $NEW_VERSION"
76+
77+
- name: Publish to NPM Registry
78+
run: |
79+
VERSION=$(node -p "require('./package.json').version")
80+
echo "Attempting to publish version: $VERSION"
81+
82+
if npm view refact-chat-js@$VERSION version &> /dev/null; then
83+
echo "Version $VERSION already exists in npm registry!"
84+
exit 1
85+
else
86+
echo "Version $VERSION is available, proceeding with publish..."
87+
if [[ "${{ github.ref_name }}" == "dev" ]]; then
88+
npm run alpha:publish
89+
else
90+
npm publish
91+
fi
92+
fi
93+
env:
94+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
95+
96+
- name: Setup vars
97+
shell: bash
98+
id: setupvars
99+
run: |
100+
echo "gui_version=$(node -p "require('./package.json').version")" >> "$GITHUB_OUTPUT"
101+
echo "release_tag=$(node -p "require('./package.json').version.includes('alpha') ? 'alpha' : 'latest'")" >> "$GITHUB_OUTPUT"
102+
103+
- name: Commit and push version update
104+
run: |
105+
VERSION="${{ steps.setupvars.outputs.gui_version }}"
106+
git add package.json package-lock.json
107+
git commit -m "Version bump $VERSION"
108+
git push origin HEAD:${{ github.ref_name }}
109+
110+
- name: Post to a Slack channel
111+
id: slack
112+
uses: slackapi/slack-github-action@v1.26.0
113+
with:
114+
payload: |
115+
{
116+
"blocks": [
117+
{
118+
"type": "header",
119+
"text": {
120+
"type": "plain_text",
121+
"text": "GUI ${{ steps.setupvars.outputs.gui_version }} is published on npm registry with '${{ steps.setupvars.outputs.release_tag }}' tag",
122+
"emoji": true
123+
}
124+
},
125+
{
126+
"type": "section",
127+
"text": {
128+
"type": "mrkdwn",
129+
"text": "by ${{ github.actor }}"
130+
}
131+
}
132+
]
133+
}
134+
env:
135+
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
136+
SLACK_WEBHOOK_TYPE: INCOMING_WEBHOOK

refact-agent/gui/package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

refact-agent/gui/package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "refact-chat-js",
3-
"version": "2.0.8-alpha.2",
3+
"version": "2.0.8-alpha.13",
44
"type": "module",
55
"license": "BSD-3-Clause",
66
"files": [
@@ -39,7 +39,6 @@
3939
"coverage": "vitest run --coverage",
4040
"format:check": "prettier . --check",
4141
"format": "prettier . --write",
42-
"prepare": "husky install",
4342
"storybook": "storybook dev -p 6006",
4443
"build-storybook": "storybook build",
4544
"types": "tsc --noEmit",

0 commit comments

Comments
 (0)