1
1
name : Publish Package
2
2
3
3
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
6
7
7
8
jobs :
8
- publish-beta-and-stable :
9
+ publish :
9
10
runs-on : ubuntu-latest
10
- strategy :
11
- matrix :
12
- release_type : [beta, stable] # Runs for both beta and stable
13
-
14
11
steps :
15
12
- uses : actions/checkout@v4
16
- with :
17
- fetch-depth : 0
18
13
19
14
- name : Setup Node.js
20
15
uses : actions/setup-node@v3
21
16
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
24
18
25
19
- name : Setup pnpm
26
20
uses : pnpm/action-setup@v2
@@ -30,75 +24,24 @@ jobs:
30
24
- name : Install Dependencies
31
25
run : pnpm install --frozen-lockfile
32
26
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
-
88
27
- name : Build
89
28
run : pnpm run build
90
29
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
92
37
run : pnpm version ${{ env.VERSION }} --no-git-tag-version
93
38
94
39
- name : Configure NPM Authentication
95
40
run : |
96
41
echo "@bitte-ai:registry=https://registry.npmjs.org/" > ~/.npmrc
97
42
echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}" >> ~/.npmrc
98
43
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
103
46
env :
104
- NODE_AUTH_TOKEN : ${{ secrets.NPM_TOKEN }}
47
+ NODE_AUTH_TOKEN : ${{ secrets.NPM_TOKEN }}
0 commit comments