fix release script, use OIDC (#5713)
This commit is contained in:
parent
f1cd985445
commit
8d9130ec63
2 changed files with 23 additions and 22 deletions
7
.github/workflows/release.yml
vendored
7
.github/workflows/release.yml
vendored
|
|
@ -12,8 +12,11 @@ jobs:
|
||||||
release:
|
release:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
if: ${{ github.repository == 'pedroslopez/whatsapp-web.js' }}
|
if: ${{ github.repository == 'pedroslopez/whatsapp-web.js' }}
|
||||||
|
permissions:
|
||||||
|
contents: write
|
||||||
|
id-token: write
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v4
|
||||||
with:
|
with:
|
||||||
token: ${{ secrets.RELEASE_GITHUB_TOKEN }}
|
token: ${{ secrets.RELEASE_GITHUB_TOKEN }}
|
||||||
- run: git config --global user.email "hello@wwebjs.dev"
|
- run: git config --global user.email "hello@wwebjs.dev"
|
||||||
|
|
@ -21,8 +24,6 @@ jobs:
|
||||||
- name: Bump version and publish to NPM
|
- name: Bump version and publish to NPM
|
||||||
id: publish
|
id: publish
|
||||||
run: ./tools/publish ${{ github.event.inputs.release_type }}
|
run: ./tools/publish ${{ github.event.inputs.release_type }}
|
||||||
env:
|
|
||||||
NPM_TOKEN: ${{ secrets.RELEASE_NPM_TOKEN }}
|
|
||||||
- name: Create GitHub Release
|
- name: Create GitHub Release
|
||||||
id: create_release
|
id: create_release
|
||||||
uses: ncipollo/release-action@v1
|
uses: ncipollo/release-action@v1
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
set -e
|
||||||
|
|
||||||
cd "$(dirname "$0")"
|
cd "$(dirname "$0")"
|
||||||
cd '..'
|
cd '..'
|
||||||
|
|
@ -40,17 +41,18 @@ else
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -f ~/.npmrc ]; then
|
# Note: When running in GitHub Actions with trusted publishing (OIDC),
|
||||||
echo "Found existing .npmrc"
|
# npm whoami won't work as OIDC auth only applies during npm publish.
|
||||||
|
# For local publishing, ensure you're logged in with 'npm login'.
|
||||||
|
if [[ -z "$CI" ]] && ! npm whoami &> /dev/null; then
|
||||||
|
echo "Not authenticated with npm. Run 'npm login' to authenticate."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
if [[ -z "$CI" ]]; then
|
||||||
|
echo "Publishing as NPM user: $(npm whoami)"
|
||||||
else
|
else
|
||||||
if [[ -z "$NPM_TOKEN" ]];then
|
echo "Publishing via GitHub Actions OIDC trusted publishing"
|
||||||
echo "No NPM_TOKEN or ~/.npmrc, exiting.."
|
|
||||||
exit 1;
|
|
||||||
else
|
|
||||||
echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" >> ~/.npmrc
|
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
echo "Publishing as NPM user: `npm whoami`"
|
|
||||||
|
|
||||||
if [[ $BRANCH != 'main' ]]; then
|
if [[ $BRANCH != 'main' ]]; then
|
||||||
echo "Not on 'main' branch. Exiting"
|
echo "Not on 'main' branch. Exiting"
|
||||||
|
|
@ -66,9 +68,12 @@ echo ""
|
||||||
echo "-----> BUMP VERSION"
|
echo "-----> BUMP VERSION"
|
||||||
echo ""
|
echo ""
|
||||||
|
|
||||||
npm version $VERSION_ARGS || exit 1
|
npm version $VERSION_ARGS
|
||||||
|
|
||||||
git push && git push --tags || exit 1
|
git push && git push --tags
|
||||||
|
|
||||||
|
NEW_VERSION=$(cat package.json | jq -r .version)
|
||||||
|
echo "New Version: $NEW_VERSION"
|
||||||
|
|
||||||
npm install
|
npm install
|
||||||
|
|
||||||
|
|
@ -78,10 +83,7 @@ git add .
|
||||||
|
|
||||||
git commit -am "chore(${NEW_VERSION}): generate docs"
|
git commit -am "chore(${NEW_VERSION}): generate docs"
|
||||||
|
|
||||||
git push
|
git push
|
||||||
|
|
||||||
NEW_VERSION=`cat package.json | jq -r .version`
|
|
||||||
echo "New Version: $NEW_VERSION"
|
|
||||||
|
|
||||||
echo ""
|
echo ""
|
||||||
echo "-----> PUSH TO NPM"
|
echo "-----> PUSH TO NPM"
|
||||||
|
|
@ -95,7 +97,5 @@ echo "-----> Done!"
|
||||||
echo "Version $NEW_VERSION published to $DIST_TAG tag"
|
echo "Version $NEW_VERSION published to $DIST_TAG tag"
|
||||||
echo ""
|
echo ""
|
||||||
|
|
||||||
echo "::set-output name=NEW_VERSION::$NEW_VERSION"
|
echo "NEW_VERSION=$NEW_VERSION" >> $GITHUB_OUTPUT
|
||||||
echo "::set-output name=PRERELEASE::$PRERELEASE"
|
echo "PRERELEASE=$PRERELEASE" >> $GITHUB_OUTPUT
|
||||||
|
|
||||||
exit 0
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue