Bump actions/setup-node from 4 to 6 #241
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This workflow will run tests using node and then publish a package to the npm registry when a release is created | |
# For more information see: https://help.github.com/actions/language-and-framework-guides/publishing-nodejs-packages | |
name: Node.js Package | |
on: | |
pull_request: | |
push: | |
branches: | |
- main | |
- master | |
jobs: | |
test: | |
runs-on: ubuntu-latest | |
steps: | |
- | |
uses: actions/checkout@v5 | |
with: | |
repository: ether/etherpad-lite | |
path: etherpad-lite | |
- | |
run: mv etherpad-lite .. | |
- | |
uses: actions/checkout@v5 | |
- | |
uses: actions/setup-node@v6 | |
with: | |
node-version: 20 | |
- uses: pnpm/action-setup@v4 | |
name: Install pnpm | |
with: | |
version: 10 | |
run_install: false | |
- name: Get pnpm store directory | |
shell: bash | |
run: | | |
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV | |
- uses: actions/cache@v4 | |
name: Setup pnpm cache | |
with: | |
path: ${{ env.STORE_PATH }} | |
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} | |
restore-keys: | | |
${{ runner.os }}-pnpm-store- | |
- | |
run: cd ../etherpad-lite && ./bin/installDeps.sh && pnpm link --global | |
- | |
run: | | |
pnpm config set auto-install-peers false | |
pnpm i | |
- | |
run: | | |
has_testcli_script () { | |
[[ $(pnpm run | grep "^ test" | wc -l) > 0 ]] | |
} | |
if has_testcli_script; then | |
pnpm run test | |
else | |
echo "No test script found" | |
fi | |
name: Run tests if available | |
- | |
run: pnpm run lint | |
publish-npm: | |
if: github.event_name == 'push' | |
needs: test | |
runs-on: ubuntu-latest | |
steps: | |
- | |
uses: actions/checkout@v5 | |
with: | |
fetch-depth: 0 | |
- | |
uses: actions/setup-node@v6 | |
with: | |
node-version: 20 | |
registry-url: https://registry.npmjs.org/ | |
- uses: pnpm/action-setup@v4 | |
name: Install pnpm | |
with: | |
version: 10 | |
run_install: false | |
- name: Get pnpm store directory | |
shell: bash | |
run: | | |
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV | |
- uses: actions/cache@v4 | |
name: Setup pnpm cache | |
with: | |
path: ${{ env.STORE_PATH }} | |
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} | |
restore-keys: | | |
${{ runner.os }}-pnpm-store- | |
- name: Only install direct dependencies | |
run: pnpm config set auto-install-peers false | |
- | |
name: Bump version (patch) | |
run: | | |
LATEST_TAG=$(git describe --tags --abbrev=0) || exit 1 | |
NEW_COMMITS=$(git rev-list --count "${LATEST_TAG}"..) || exit 1 | |
[ "${NEW_COMMITS}" -gt 0 ] || exit 0 | |
git config user.name 'github-actions[bot]' | |
git config user.email '41898282+github-actions[bot]@users.noreply.github.com' | |
pnpm i | |
pnpm version patch | |
git push --follow-tags | |
- | |
run: pnpm i | |
- | |
run: pnpm publish | |
env: | |
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}} | |
- | |
name: Add package to etherpad organization | |
run: npm access grant read-write etherpad:developers | |
env: | |
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}} |