@@ -11,7 +11,6 @@ permissions:
1111
1212jobs :
1313 release :
14- if : github.event.pull_request.merged == true
1514 runs-on : ubuntu-latest
1615
1716 steps :
@@ -24,22 +23,47 @@ jobs:
2423 node-version : 20
2524 cache : yarn
2625
26+ - name : Configure Git
27+ run : |
28+ git config user.name "github-actions"
29+ git config user.email "[email protected] " 30+
2731 - name : Install dependencies
2832 run : yarn install --frozen-lockfile
2933
30- - name : Extract version from package.json
31- id : extract_version
34+ - name : Generate version from date
35+ id : generate_version
3236 run : |
33- VERSION=$(jq -r '.version' package.json)
37+ VERSION="v$(date +'%Y.%m.%d' | sed 's/0//g')"
3438 echo "VERSION=$VERSION" >> $GITHUB_ENV
39+ echo "Generated version: $VERSION"
40+
41+ - name : Update version in package.json
42+ run : |
43+ jq --arg new_version "${{ env.VERSION }}" '.version = $new_version' package.json > temp.json && mv temp.json package.json
44+ echo "Updated package.json to version: ${{ env.VERSION }}"
45+
46+ - name : Commit updated package.json
47+ run : |
48+ git add package.json
49+ git commit -m "chore: update version to ${{ env.VERSION }}"
50+ git push origin main
3551
3652 - name : Create Git tag
3753 run : |
38- git tag -a "$VERSION" -m "Release $VERSION"
39- git push origin "$VERSION"
54+ git tag -a "${{ env. VERSION }} " -m "Release ${{ env. VERSION }} "
55+ git push origin "${{ env. VERSION }} "
4056
4157 - name : Build the package
4258 run : yarn build
4359
4460 - name : Notify release
4561 run : echo "Release ${{ env.VERSION }} has been successfully created."
62+
63+ - name : Set up NPM auth
64+ run : echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}" > ~/.npmrc
65+
66+ - name : Publish to npm
67+ run : yarn publish --non-interactive
68+ env :
69+ NODE_AUTH_TOKEN : ${{ secrets.NPM_TOKEN }}
0 commit comments