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

NPM distribution #561

Closed
TheSpyder opened this issue Oct 24, 2023 Discussed in #550 · 7 comments · Fixed by #563
Closed

NPM distribution #561

TheSpyder opened this issue Oct 24, 2023 Discussed in #550 · 7 comments · Fixed by #563

Comments

@TheSpyder
Copy link
Contributor

As a JavaScript developer, I'd like to use changie but it's not available as a peer of other JavaScript tooling through NPM. JavaScript projects generally only require npm to be installed on the system, everything else (even binary executables) are installed through NPM packages.

Transferred from #550

Where we've landed in the discussion is I will contribute some JS scripts and initial config. The bulk of this task is adding a step to release.yml that collects the archive binaries for distribution. To keep the size of the npm package down, I'm going to exclude the 386 builds and just ship the 6 major OS/Arch combinations:

  • dist/changie_darwin_arm64/changie
  • dist/changie_darwin_amd64_v1/changie
  • dist/changie_linux_arm64/changie
  • dist/changie_linux_amd64_v1/changie
  • dist/changie_windows_arm64/changie.exe
  • dist/changie_windows_amd64_v1/changie.exe

To achieve this, I need to do a few things.

  • create a script to parse dist/artifacts.json and collect the required binaries (the paths above cannot be relied on)
  • Execute this script after the Run GoReleaser step in the release github action
  • Add a package.json and include it to the list of replacements in .changie.yaml config
  • Use the NodeJS github action to publish changie
@miniscruff
Copy link
Owner

Let me know when you are getting close and I can sign up for the NPM Token

@TheSpyder
Copy link
Contributor Author

I haven't tested it yet but I've written the code. I'll do some sample runs to check my logic tomorrow.
main...TheSpyder:changie:561-npm-publishing

@TheSpyder
Copy link
Contributor Author

I also realised my list of 6 platforms is a bit aggressive; 32-bit windows is probably far more common than ARM windows (and ARM windows has emulation built-in). I'll adjust that tomorrow as well.

@TheSpyder
Copy link
Contributor Author

The branch is ready, I have tested it about as much as I can without having it on NPM (I've run the postinstall script with forced platform settings, but it's hard to do actual testing on other platforms from source).

Do you want me to do docs before I open the PR?

@miniscruff
Copy link
Owner

hmm, if you can just give a basic overview of docs in the PR so I can add it when I rework the site that should be fine.

@TheSpyder
Copy link
Contributor Author

I've written basic docs but I just realised my approach of minimal disruption - I put everything in an npm subfolder instead of the project root - means the package has no readme or license file. I will think about how to tweak this before opening my PR (probably tomorrow).

@TheSpyder
Copy link
Contributor Author

I decided to double-check my scripts on a windows VM, and I'm glad I did, because they didn't work quite how I intended 😅

I was over-optimising for performance by trying to have the direct binary linked, but NodeJS makes that difficult. So I've swapped to a NodeJS wrapper that then spawns the executable - slower, but far more reliable and compatible cross-platform.

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 a pull request may close this issue.

2 participants