@@ -52,11 +52,17 @@ jobs:
5252 contents : write
5353 pull-requests : write
5454 steps :
55+ - name : Dependabot metadata
56+ id : metadata
57+ uses : dependabot/fetch-metadata@v3
58+ with :
59+ github-token : " ${{ secrets.GITHUB_TOKEN }}"
5560 - name : Enable auto-merge for Dependabot PRs
56- run : gh pr merge --auto --merge "$PR_URL" # Use Github CLI to merge automatically the PR
61+ if : steps.metadata.outputs.update-type == 'version-update:semver-patch' || steps.metadata.outputs.update-type == 'version-update:semver-minor'
62+ run : gh pr merge --auto --merge "$PR_URL" # Use GitHub CLI to merge automatically the PR
5763 env :
5864 PR_URL : ${{github.event.pull_request.html_url}}
59- GITHUB_TOKEN : ${{secrets.GITHUB_TOKEN}}
65+ GH_TOKEN : ${{secrets.GITHUB_TOKEN}}
6066
6167 npm-publish-dev :
6268 needs : build
7783 name : build
7884 - uses : actions/setup-node@v6
7985 with :
80- node-version : 22
86+ node-version : 20 # required for OIDC npm@latest
8187 registry-url : ' https://registry.npmjs.org'
8288 - name : Update npm to latest (required for OIDC)
8389 run : npm install -g npm@latest
8692 - name : Publish to npm
8793 if : github.actor != 'dependabot[bot]' && github.actor != 'dependabot-preview[bot]'
8894 run : npm publish --tag latest
95+
96+ github-release :
97+ needs : [npm-publish-latest]
98+ runs-on : ubuntu-latest
99+ if : github.ref == 'refs/heads/main' && github.event_name == 'push'
100+ permissions :
101+ contents : write
102+ steps :
103+ - uses : actions/checkout@v6
104+ with :
105+ fetch-depth : 0
106+ - name : Create GitHub release with generated notes
107+ env :
108+ GH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
109+ run : |
110+ TAG="v$(node -p 'require("./package.json").version')"
111+
112+ if gh release view "$TAG" >/dev/null 2>&1; then
113+ echo "Release $TAG already exists. Skipping."
114+ exit 0
115+ fi
116+
117+ if git ls-remote --exit-code --tags origin "refs/tags/$TAG" >/dev/null 2>&1; then
118+ echo "Tag $TAG already exists on origin. Creating release from existing tag."
119+ gh release create "$TAG" --verify-tag --generate-notes
120+ else
121+ echo "Creating tag and release $TAG from commit $GITHUB_SHA."
122+ gh release create "$TAG" --target "$GITHUB_SHA" --generate-notes
123+ fi
0 commit comments