Skip to content

Commit 4e5c763

Browse files
committed
release
1 parent faeabcf commit 4e5c763

File tree

2 files changed

+28
-122
lines changed

2 files changed

+28
-122
lines changed

.github/workflows/branch-release.yaml

Lines changed: 13 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,18 @@
11
name: Branch Release
22

33
on:
4-
push:
5-
branches:
6-
- '**' # Runs on all branches except `main`
4+
push
75

86
jobs:
97
branch_publish:
108
runs-on: ubuntu-latest
11-
strategy:
12-
matrix:
13-
react_version: [18, 19]
14-
159
steps:
1610
- uses: actions/checkout@v4
1711

1812
- name: Setup Node.js
1913
uses: actions/setup-node@v3
2014
with:
21-
node-version: '20'
15+
node-version: '20' # Specify the Node.js version you want to use
2216

2317
- name: Setup pnpm
2418
uses: pnpm/action-setup@v2
@@ -28,55 +22,24 @@ jobs:
2822
- name: Install Dependencies
2923
run: pnpm install --frozen-lockfile
3024

31-
- name: Set Version and Tag
32-
id: release_info
33-
run: |
34-
BRANCH_NAME=${GITHUB_REF#refs/heads/}
35-
SHORT_SHA=$(git rev-parse --short HEAD)
36-
BASE_VERSION="0.1.0" # Base version for branch builds
37-
38-
if [ "${{ matrix.react_version }}" = "19" ]; then
39-
echo "VERSION=${BASE_VERSION}-${BRANCH_NAME}-beta-${SHORT_SHA}" >> $GITHUB_ENV
40-
echo "NPM_TAG=branch-beta" >> $GITHUB_ENV
41-
else
42-
echo "VERSION=${BASE_VERSION}-${BRANCH_NAME}-${SHORT_SHA}" >> $GITHUB_ENV
43-
echo "NPM_TAG=branch" >> $GITHUB_ENV
44-
fi
45-
46-
- name: Update package.json for React Version
47-
run: |
48-
if [ "${{ matrix.react_version }}" = "19" ]; then
49-
jq '.peerDependencies.react = "^19.0.0" |
50-
.peerDependencies["react-dom"] = "^19.0.0" |
51-
.overrides["react-is"] = "19.0.0" |
52-
.devDependencies["@types/react"] = "^19.0.10" |
53-
.devDependencies["@types/react-dom"] = "^19.0.4"' package.json > temp.json && mv temp.json package.json
54-
else
55-
jq '.peerDependencies.react = "^18.2.0" |
56-
.peerDependencies["react-dom"] = "^18.2.0" |
57-
del(.overrides) |
58-
.devDependencies["@types/react"] = "^18.2.0" |
59-
.devDependencies["@types/react-dom"] = "^18.2.0"' package.json > temp.json && mv temp.json package.json
60-
fi
61-
62-
- name: Install Correct React Version
63-
run: |
64-
pnpm add react@${{ matrix.react_version }} react-dom@${{ matrix.react_version }} --save-exact
65-
6625
- name: Build
6726
run: pnpm run build
6827

69-
- name: Set Version in package.json
70-
run: pnpm version ${{ env.VERSION }} --no-git-tag-version
28+
- name: Set Version from Branch
29+
run: |
30+
BRANCH_NAME=${GITHUB_REF#refs/heads/}
31+
SHORT_SHA=$(git rev-parse --short HEAD)
32+
BASE_VERSION="0.1.0" # Define a base version
33+
VERSION="${BASE_VERSION}-${BRANCH_NAME}-${SHORT_SHA}"
34+
pnpm version $VERSION --no-git-tag-version
7135
7236
- name: Configure NPM Authentication
7337
run: |
7438
echo "@bitte-ai:registry=https://registry.npmjs.org/" > ~/.npmrc
7539
echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}" >> ~/.npmrc
7640
77-
- name: Publish to NPM
78-
run: |
79-
echo "Publishing version ${{ env.VERSION }} with tag ${{ env.NPM_TAG }}"
80-
pnpm publish --access public --tag ${{ env.NPM_TAG }} --no-git-checks
41+
- name: Publish with pnpm
42+
if: ${{ github.ref_name != 'main'}}
43+
run: pnpm publish --access public --tag branch --no-git-checks
8144
env:
82-
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
45+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

.github/workflows/release.yaml

Lines changed: 15 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,20 @@
11
name: Publish Package
22

33
on:
4-
release:
5-
types: [created] # Triggers when a new GitHub release is created
4+
push:
5+
tags:
6+
- 'v*' # Triggers on version tags like v1.0.0
67

78
jobs:
8-
publish-beta-and-stable:
9+
publish:
910
runs-on: ubuntu-latest
10-
strategy:
11-
matrix:
12-
release_type: [beta, stable] # Runs for both beta and stable
13-
1411
steps:
1512
- uses: actions/checkout@v4
16-
with:
17-
fetch-depth: 0
1813

1914
- name: Setup Node.js
2015
uses: actions/setup-node@v3
2116
with:
22-
node-version: '20'
23-
registry-url: 'https://registry.npmjs.org'
17+
node-version: '20' # Specify the Node.js version you want to use
2418

2519
- name: Setup pnpm
2620
uses: pnpm/action-setup@v2
@@ -30,75 +24,24 @@ jobs:
3024
- name: Install Dependencies
3125
run: pnpm install --frozen-lockfile
3226

33-
- name: Determine Version
34-
id: versioning
35-
run: |
36-
git fetch --tags
37-
38-
RELEASE_VERSION=${GITHUB_REF#refs/tags/v}
39-
echo "GitHub Release Version: $RELEASE_VERSION"
40-
41-
if [[ "${{ matrix.release_type }}" == "beta" ]]; then
42-
echo "Release type: BETA"
43-
44-
EXISTING_VERSIONS=$(npm view @bitte-ai/your-package versions --json | jq -r '.[]' || echo "")
45-
BETA_VERSION="${RELEASE_VERSION}-beta"
46-
47-
if echo "$EXISTING_VERSIONS" | grep -q "\"${BETA_VERSION}\""; then
48-
BETA_COUNTER=1
49-
BETA_VERSION="${RELEASE_VERSION}-beta.${BETA_COUNTER}"
50-
while echo "$EXISTING_VERSIONS" | grep -q "\"${BETA_VERSION}\""; do
51-
BETA_COUNTER=$((BETA_COUNTER + 1))
52-
BETA_VERSION="${RELEASE_VERSION}-beta.${BETA_COUNTER}"
53-
done
54-
fi
55-
56-
echo "VERSION=$BETA_VERSION" >> $GITHUB_ENV
57-
echo "NPM_TAG=beta" >> $GITHUB_ENV
58-
echo "REACT_VERSION=19" >> $GITHUB_ENV
59-
60-
else
61-
echo "Release type: STABLE"
62-
echo "VERSION=$RELEASE_VERSION" >> $GITHUB_ENV
63-
echo "NPM_TAG=latest" >> $GITHUB_ENV
64-
echo "REACT_VERSION=18" >> $GITHUB_ENV
65-
fi
66-
67-
- name: Update package.json for React Version
68-
run: |
69-
if [ "${{ env.REACT_VERSION }}" = "19" ]; then
70-
jq '.peerDependencies.react = "^19.0.0" |
71-
.peerDependencies["react-dom"] = "^19.0.0" |
72-
.overrides["react-is"] = "19.0.0" |
73-
.devDependencies["@types/react"] = "^19.0.10" |
74-
.devDependencies["@types/react-dom"] = "^19.0.4"' package.json > temp.json && mv temp.json package.json
75-
else
76-
jq '.peerDependencies.react = "^18.2.0" |
77-
.peerDependencies["react-dom"] = "^18.2.0" |
78-
del(.overrides) |
79-
.devDependencies["@types/react"] = "^18.2.0" |
80-
.devDependencies["@types/react-dom"] = "^18.2.0"' package.json > temp.json && mv temp.json package.json
81-
fi
82-
83-
- name: Install Correct React Version
84-
run: |
85-
echo "Installing React ${{ env.REACT_VERSION }}"
86-
pnpm add react@${{ env.REACT_VERSION }} react-dom@${{ env.REACT_VERSION }} --save-exact
87-
8827
- name: Build
8928
run: pnpm run build
9029

91-
- name: Set Version in package.json
30+
- name: Determine Version
31+
id: determine_version
32+
run: |
33+
VERSION=${GITHUB_REF#refs/tags/}
34+
echo "VERSION=$VERSION" >> $GITHUB_ENV
35+
36+
- name: Set Version in Package
9237
run: pnpm version ${{ env.VERSION }} --no-git-tag-version
9338

9439
- name: Configure NPM Authentication
9540
run: |
9641
echo "@bitte-ai:registry=https://registry.npmjs.org/" > ~/.npmrc
9742
echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}" >> ~/.npmrc
9843
99-
- name: Publish to NPM
100-
run: |
101-
echo "Publishing version ${{ env.VERSION }} with tag ${{ env.NPM_TAG }}"
102-
pnpm publish --access public --tag ${{ env.NPM_TAG }} --no-git-checks
44+
- name: Publish with pnpm
45+
run: pnpm publish --access public --tag latest --no-git-checks
10346
env:
104-
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
47+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

0 commit comments

Comments
 (0)