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

CI: Workflow to Publish to npm if Package Version is Changed #7

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

BowTiedDevOps
Copy link

@BowTiedDevOps BowTiedDevOps commented Apr 4, 2024

Description

As per #6, a workflow that automatically pushes packages to npm when it detects a version changed is a good addition, because some developers that update these packages might not have the permissions to publish themselves, and it makes their jobs easier by not having to worry about uploading the package once it's updated - that is now automated.

Closes #6

Notes:

  • Prior to using this workflow, a repository secret named NODE_AUTH_TOKEN must be added, and it should contain the npm auth token of the stacks organisation (Automation type, so it can bypass 2FA).
  • The current workflow ONLY works with node packages. The workflow will have to be updated prior to any other type of package addition because otherwise it will fail every time a commit is made to that crate.
  • The workflow currently uses the --access=public option for npm publish command because I couldn't test it with private packages. This will need a discussion with Jesse so I can properly update the command.

Workflow runs:

NPM Profile (Published Packages): https://www.npmjs.com/~bowtieddevops

Tag @wileyj and @hugocaillard because I can't add reviewers on this repo.

@wileyj
Copy link
Contributor

wileyj commented Apr 4, 2024

fyi i've added the npm auth token to this repo

@BowTiedDevOps
Copy link
Author

@hugocaillard @MarvinJanssen After talking to Jesse, we've come to a solution regarding the access option - we will keep it public (if anyone wants to publish a private package, this ain't the place) and I'll change to an action that makes parsing the args to npm publish easier. I do have 1 question regarding the solo npm ci step though (silly me thought it comes from Continuous Integration) - it's useless rn, I can either remove it or do a npm ci && npm test command which will look like this:

- name: Test Package
  id: test_package
  run: |
    cd ${{ needs.check_version_change.outputs.PACKAGE_PATH }}
    npm ci
    npm test

Question is - do we want to test before publish or not?

@hugocaillard
Copy link
Contributor

Yes npm ci is a bit badly named i think
Yes I think it's better to run the tests before publishing 👍

@BowTiedDevOps
Copy link
Author

Run with npm test and publish after latest commit: https://github.com/BowTiedDevOps/stacks-test-tools/actions/runs/8570853362/job/23489745755

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.

Publish updates to npm
3 participants