Skip to content

CI: phips28/gh-action-bump-version fails — package.json not found #2

Description

@aj1126

Describe the bug

The Semantic Versioning GitHub Actions job fails on push to main. The step using phips28/gh-action-bump-version@v10.0.0 throws an error because it expects a package.json in the repository root, but this repository contains PowerShell code only and has no package.json.

Steps to reproduce

  1. Push any commit to the main branch (or run the "Semantic Versioning" workflow manually).
  2. Observe the job version run on ubuntu-latest.
  3. The step "Bump version" (phips28/gh-action-bump-version@v10.0.0) errors out immediately.

Expected behavior

The workflow should either:

  • Bump/create a repository tag for semantic versioning without requiring Node/package metadata, or
  • Only run a package.json-based bump when a package.json exists.

Logs / Output

Relevant excerpt from the failing job log:

/home/runner/work/MyBookTools/MyBookTools
/home/runner/work/_actions/phips28/gh-action-bump-version/v10.0.0/index.js:260
if (!existsSync(pathToPackage)) throw new Error("package.json could not be found in your project's root.");
^

--- ERROR ---
Error: package.json could not be found in your project's root.
at getPackageJson (/home/runner/work/_actions/phips28/gh-action-bump-version/v10.0.0/index.js:260:41)
at Object. (/home/runner/work/_actions/phips28/gh-action-bump-version/v10.0.0/index.js:18:13)

Failing workflow file: .github/workflows/semantic-versioning.yml (uses phips28/gh-action-bump-version@v10.0.0)

Repository language composition: PowerShell: 100%

Environment

  • Runner OS: ubuntu-latest (GitHub Actions)
  • Repository type: PowerShell project (no package.json present)
  • Workflow: .github/workflows/semantic-versioning.yml

Suggested fixes

  1. Preferred: Replace the Node/package.json-dependent action with a tag-based semantic versioning step that does not require a package.json. This is appropriate since the repo is PowerShell-only.

Update .github/workflows/semantic-versioning.yml to use a tag-based approach. Example replacement workflow:

name: Semantic Versioning

on:
  push:
    branches: [ main ]

jobs:
  version:
    runs-on: ubuntu-latest
    permissions:
      contents: write

    steps:
      - uses: actions/checkout@v4
        with:
          fetch-depth: 0

      - name: Get latest tag
        id: tag
        run: |
          git fetch --tags
          latest_tag=$(git tag --list 'v*' --sort=-version:refname | head -n 1)
          if [ -z "$latest_tag" ]; then
            latest_tag="v0.0.0"
          fi
          echo "latest_tag=$latest_tag" >> $GITHUB_OUTPUT

      - name: Bump patch version
        id: bump
        run: |
          tag="${{ steps.tag.outputs.latest_tag }}"
          version="${tag#v}"
          IFS='.' read -r major minor patch <<< "$version"
          patch=$((patch + 1))
          new_tag="v${major}.${minor}.${patch}"
          echo "new_tag=$new_tag" >> $GITHUB_OUTPUT

      - name: Create tag
        run: |
          git config user.name "github-actions"
          git config user.email "github-actions@github.com"
          git tag "${{ steps.bump.outputs.new_tag }}"
          git push origin "${{ steps.bump.outputs.new_tag }}"

This approach bumps the patch version and pushes a new tag without reading any repository files.

  1. Alternative: If you intend to use the existing phips28/gh-action-bump-version action, add a minimal package.json at the repository root with a version field and maintain it as the canonical version source. Example package.json:
{
  "name": "MyBookTools",
  "version": "0.1.0"
}
  1. Short-term workaround: Guard the bump step so it only runs when package.json exists. Example step change in the current workflow (uses an if condition):
- name: Bump version
  if: ${{ exists('package.json') }}
  uses: phips28/gh-action-bump-version@v10.0.0
  env:
    GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  with:
    tag-prefix: "v"

Note: GitHub Actions exists() function is not available directly; instead you can check with a run step that sets an output and conditionally run the bump step based on that output. The tag-based workflow above is simpler for non-Node repos.

Action items

  • Decide whether you want repo-level versioning via tag (recommended for PowerShell-only repo) or to maintain a package.json for Node-style bumping.
  • If tag-based: replace the workflow as shown and push to main.
  • If package.json-based: add package.json with version and keep the current action.

If you want, I can create the issue on the repository now or open a draft PR with the updated workflow file.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions