Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Support volta, asdf, and package.json engines for declaring version #151

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

happycollision
Copy link

⚠️ I only ran the build script. Not sure if there is anything else needed.

This addresses #109 and #84 and could be extended later to also address #150.

Using the same logic as actions/setup-node, we can support asdf, volta or other version management techniques.

I thought it'd be nice to allow something like this:

on:
  - push
  - pull_request

jobs:
  install:
    runs-on: ubuntu-latest

    steps:
      - uses: pnpm/action-setup@v4
        with:
          version_file_path: ".tool-versions" # with asdf
          # version_file_path: "package.json" # with volta or package.json's `engines`

Using the same logic as `actions/setup-node`, we can support `asdf`, `volta` or other version management techniques.
@happycollision happycollision changed the title Support volta, asdf, and package.json engines feat: Support volta, asdf, and package.json engines for declaring version Nov 28, 2024
Comment on lines +103 to +104
const { versionFilePath, packageJsonFile, standalone } = opts
let { version } = opts
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks weird to destructure it twice. Just use let for all.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Heh, I agree. I just wanted to change as little as possible from the code I snagged to it was more comparable. I’ll change it though, since that is a less important goal.

@zkochan zkochan requested a review from KSXGitHub January 9, 2025 00:02
Comment on lines +10 to +12
version_file_path:
description: "Path to a version file. Eg: '.tool-versions' for asdf or 'package.json' for volta"
required: false
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is problematic. .tool-versions and package.json are completely different formats and should be treated as different features.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Honestly, the only reason I did it this way was to match up with how they do it for node versioning in the referenced lib. I figure if js devs are familiar with any GitHub actions at all, it’s likely that one.

I’ll rethink the inputs throwing out that goal and come back with something else.

Or not. Heh. If I have the time I will.

@KSXGitHub
Copy link
Collaborator

@zkochan Normally, I only want @pnpm/action-setup to focus only on pnpm. This action supporting corepack makes sense because pnpm itself supports corepack. Do you want to add support for additional tooling that pnpm doesn't commit to support?

@happycollision Shouldn't volta and asdf have their own GH actions?

@happycollision
Copy link
Author

@happycollision Shouldn't volta and asdf have their own GH actions?

I doubt it? I assume the best actions to use for setup are the incredibly common one provided by the GH Actions team for node and then for pnpm, the one maintained by the actual developers of pnpm. 😇

I use a node action to setup node and this pnpm action to set up pnpm in CI (just as described in your docs). But to version control in development I use asdf, sometimes Volta. All I really want is a single, canonical place to declare a version and have it respected by all those tools, rather than assume everyone on my team is familiar enough with all of them to know and remember to update the version in multiple places. So that’s my particular use case.

Now, the .tool-versions format is easy enough to dig through with shell scripting, but if you give people an easy way to do it, you’d save people some time and effort. This, I assume, is why the node action offers to read these common version declaration files.

I gave my other answers above before reading this comment, so until I hear back from you guys, I’ll sit on this so you can decide what is best for the project. Feel free to close this out if you like.

Cheers.

Side note: We are in the middle of transitioning from npm to pnpm at my workplace. I am the one doing the work for it, and I am loving the benefits I am seeing. Thanks for the incredible work on this package manager.

@KSXGitHub
Copy link
Collaborator

KSXGitHub commented Jan 9, 2025

@happycollision Both volta and asdf aim to be the single, canonical place to configure all the versions of JS runtimes and package managers if I'm not mistaken? Them not having GH actions of their own is a flaw they should address.

pnpm initially also didn't have a GH action, so I made one, and proposed with zkochan to move it from my account to the @pnpm org, making it official.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants