Statement of the problem
I have written a JavaScript library that I want to make accessible in third-party projects (just like jQuery), for this I have thought of using the JSDelivr service and its GitHub option.
I first made a Package npm through GitHub (thinking it was necessary) but then I noticed that it didn't work and only after doing a Release on GitHub was it possible to import the library using:https://cdn.jsdelivr.net/gh/user/repo@version/file
I also had to make a new version of the program through Release but when doing the same thing in Packages I couldn't find a way, so I have a Release version v1.0.1
and a Packages version v1.0.0
and I don't know how to align the Packages version.
conclusion
- What is the difference between Packages and Releases, both are required for the JSDelivr service?
- How do you create a new version of a GitHub Package (eg: v.1.0.1)?
1. What is the difference between Packages and Releases, both are required for the jsdelivr service?
A release indicates a version of the code that the repository contains.
When a release is created , the code that is in the repository is saved and uploaded as release , later it can be downloaded and the files can be deleted, since they have already been published as release
Instead, packages ( packages ) are external service integrations with the repository, as it says in GitHub Docs :
That is , if needed, packages that have been published in repositories can be used as dependencies on other packages, while releases are just versions of the repository.
Both are not necessary , you just have to do a release , since JSDelivr has a CDN service for GitHub as follows
In this case, we are going to request a jQuery file
If you check, it loads correctly and jQuery does not have any packages
2. How do you create a new version of a GitHub Package (eg v.1.0.1)?
Source: GitHub Docs
By default, GitHub Packages publishes a package to the GitHub repository that you specify in the file name field
package.json
. For example, you would publish a package called@my-org/test
to the GitHub repositorymy-org/test
. You can add a summary to the package listing page by including a README.md file in your packages directory. For more information, see Working with package.json and _ How to create Node.js modules in the npm documentation .You can configure the scope mapping for your project using a local file in the project or by using the publishConfig
.npmrc
option in the . GitHub packages only support scoped npm packages . Scoped packages have names of the form . Scoped packages always start with an @ symbol. You may need to update the name in your package.json to use the scope name. For example, "name": "@codertocat/hello-world-npm".package.json
@propietario/nombre
After you publish a package, you can view it on GitHub. For more information, see Viewing Packages .
However, specific versions of a package cannot be published, you can publish a release , as follows:
The input tag version is the version number, for example, if it is 1.4, in JSDelivr it will be accessible like this:
The input release title is what is shown as the title, that is
(The release description is optional)
Finally, press the Publish release button and that's it!