0.2.11 • Published 5 months ago

@sahilks/dummy-library v0.2.11

Weekly downloads
-
License
ISC
Repository
github
Last release
5 months ago

Node Package version control/versioning

This GitHub Action automates the process of managing the version of an npm package, including updating the package version number, stashing any changes to the code, and pushing the changes back to the repository. Additionally, it includes a step to publish the updated package to the npm registry.

Workflow

The workflow is triggered when a push event occurs on the main branch. There are two jobs included in this workflow: build and publish. The build job updates the package version and pushes the changes back to the repository, while the publish job installs the updated packages and publishes them to the npm registry.

Steps

  • Checkout: This step checks out the repository code in order to perform the necessary updates and changes.
  • Authenticate with GitHub: This step authenticates the user's GitHub account using a GitHub token, which is stored in the GH_TOKEN secret. This allows the GitHub API to be used in subsequent steps.
  • Set git user: This step sets the git user name and email, which is required to make commits to the repository.
  • Stash changes: This step stashes any changes to the repository code, which will be applied after the package version has been updated.
  • Update package version: This step uses the npm version command to update the package version, using the patch option to increment the patch number of the current version. This command also updates the package.json file in the repository with the new version number.
  • Apply stash: This step applies the stashed changes to the repository code, including the updated package.json file. The changes are then pushed back to the repository using the git push command.
  • Checkout: This step checks out the repository code in the publish job, which is required to install the updated packages.
  • Setup node: This step sets up the node environment using the specified version and registry URL.
  • Install packages: This step installs the updated packages using the npm install command.
  • Publish: This step publishes the updated packages to the npm registry using the npm publish command. The authentication token is stored in the NODE_AUTH_TOKEN secret.

Secrets

This workflow requires two secrets to be stored in the GitHub repository:

  • GH_TOKEN: This secret contains a GitHub token, which is required to authenticate with the GitHub API in order to make changes to the repository.

    > **_NOTE:_**  In this github token you need to give permission for: Full control of private repositories and workflow. Eg: 

    text

  • NPM_AUTH_TOKEN: This secret contains an npm authentication token, which is required to publish packages to the npm registry.

    > **_NOTE:_**  In this npm token you need to give permission for: Automation. Eg: 

    text

Important Note:

NOTE: Make sure you can give Workflow permissions for read and write. Eg: text then text then click the save button.

Usage

To use this GitHub Action in your repository, create a new file in the .github/workflows directory with a name such as manage-npm-package-version.yml. Then copy and paste the code from this repository into the new file.

Make sure to add the necessary secrets to your repository settings in order for the workflow to function properly.

Conclusion

By using this GitHub Action, developers can save time and ensure that their npm packages are always up-to-date with the latest version number. This automation reduces the possibility of errors and ensures that the package version number is consistent across different environments.

0.2.11

5 months ago

0.2.9

11 months ago

0.2.7

1 year ago

0.2.6

1 year ago

0.2.5

1 year ago

0.2.4

1 year ago