# This file is automatically added by @npmcli/template-oss. Do not edit.

name: Release Please - libnpmfund

on:
  push:
    paths:
      - workspaces/libnpmfund/**
    branches:
      - main
      - latest

permissions:
  contents: write
  pull-requests: write

jobs:
  release-please:
    runs-on: ubuntu-latest
    steps:
      - uses: google-github-actions/release-please-action@v3
        id: release
        with:
          release-type: node
          monorepo-tags: true
          path: workspaces/libnpmfund
          # name can be removed after this is merged
          # https://github.com/google-github-actions/release-please-action/pull/459
          package-name: "libnpmfund"
          changelog-types: >
            [
              {"type":"feat","section":"Features","hidden":false},
              {"type":"fix","section":"Bug Fixes","hidden":false},
              {"type":"docs","section":"Documentation","hidden":false},
              {"type":"deps","section":"Dependencies","hidden":false},
              {"type":"chore","hidden":true}
            ]
      - uses: actions/checkout@v3
      - name: Setup git user
        run: |
          git config --global user.email "ops+npm-cli@npmjs.com"
          git config --global user.name "npm cli ops bot"
      - uses: actions/setup-node@v3
        with:
          node-version: 16.x
      - name: Update npm to latest
        run: npm i --prefer-online --no-fund --no-audit -g npm@latest
      - run: npm -v
      - name: Update package-lock.json and commit
        if: steps.release.outputs.pr
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        run: |
          gh pr checkout ${{ fromJSON(steps.release.outputs.pr).number }}
          npm run resetdeps
          title="${{ fromJSON(steps.release.outputs.pr).title }}"
          # get the version from the pr title
          # get everything after the last space
          git commit -am "deps: libnpmfund@${title##* }"
          git push
