Skip to content

Option to set package.json version fieldΒ #390

@mmkal

Description

@mmkal

Hi - I've found myself going for a GitHub Actions workflow like this:

name: pkg.pr.new
on:
  push: {}

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - run: npm install -g [email protected] # todo: delete if https://github.com/nodejs/corepack/issues/612 is resolved
      - run: corepack enable
      - name: set package.json version
        # note: if dependencies are a "real" version that matches the repo's package.json, pnpm uses the cached version. So patch to a dev, timestamped version.
        run: |
          sed -i 's|"version":|"version": "0.0.0-dev-todaysdate","oldversion":|g' package.json
          sed -i "s|todaysdate|$(date +%Y%m%d%H%M%S)|g" package.json
      - run: pnpm install
      - run: pnpm build
      - run: pnpm pkg-pr-new publish

To make sure all tools (and humans) know that the version installed is not the "real" one from the npm registry. It'd be great if I could do this by passing a CLI argument or something, which used the commit hash to set the version field, or something like that.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions