{"id":17222927,"url":"https://github.com/rush/publish-to-git","last_synced_at":"2025-04-14T00:18:12.862Z","repository":{"id":42236076,"uuid":"138365496","full_name":"Rush/publish-to-git","owner":"Rush","description":"Publish private npm packages to Git repositories with npm publish semantics","archived":false,"fork":false,"pushed_at":"2025-01-06T16:52:03.000Z","size":66,"stargazers_count":45,"open_issues_count":9,"forks_count":13,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-22T02:34:49.333Z","etag":null,"topics":["git","npm","npm-publish","package","private-repository"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Rush.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-06-23T02:37:35.000Z","updated_at":"2025-03-05T09:34:34.000Z","dependencies_parsed_at":"2025-03-04T20:31:35.935Z","dependency_job_id":"d1c15e3c-a336-48a6-bf77-112481cd52ea","html_url":"https://github.com/Rush/publish-to-git","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Rush%2Fpublish-to-git","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Rush%2Fpublish-to-git/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Rush%2Fpublish-to-git/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Rush%2Fpublish-to-git/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Rush","download_url":"https://codeload.github.com/Rush/publish-to-git/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248799968,"owners_count":21163404,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["git","npm","npm-publish","package","private-repository"],"created_at":"2024-10-15T04:06:44.768Z","updated_at":"2025-04-14T00:18:12.839Z","avatar_url":"https://github.com/Rush.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# publish-to-git\nPublish private npm packages to Git repositories with npm publish semantics (uses same files as `npm publish`)\n\nDefault behavior takes the version from package.json, runs `npm pack` and then pushes the contents to an orphan tag `v\u003cVERSION\u003e` (for example `v1.0.0`). It's similar to how `gh-pages` works.\n\nSuch tags can be easily referenced to in `package.json`. It provides proper versioning to private Git npm packages along with an easy publish path that's compatible with `npm`.\n\n## Installation\n```js\nnpm install --save-dev publish-to-git\n```\nRequirements: `node \u003e 8.0.0` and `git` command being in the `PATH`.\n\n## Consumption of private Git NPM packages\nFor Github\n```json\n\"some-package\": \"reponame/repo#v1.0.0\",\n\"some-package-with-semver\": \"reponame/repo#semver:^v1.0.0\",\n```\n\nFor Gitlab or BitBucket (use `bitbucket:`)\n```json\n\"some-package\": \"gitlab:reponame/repo#v1.0.0\",\n\"some-package-with-semver\": \"gitlab:reponame/repo#semver:^v1.0.0\",\n```\n\nFor some other Git repo:\n```json\n\"some-package\": \"git+ssh://git@somehow.com:somerepo#v1.0.0\",\n\"some-package-with-semver\": \"git+ssh://git@somehow.com:somerepo#semver:^v1.0.0\",\n```\n\nNote: Installing from Github/Gitlab/Bitbucket seems to be more efficient due to the way [it conditionally turns on shallow clone](https://github.com/zkat/pacote/blob/ccc6e9094c2e872f09cc12ae966a0cbc1a570eed/lib/fetchers/git.js#L169).\n\n## Usage\nIn package.json\n```js\n\"scripts\": {\n  \"publish\": \"publish-to-git\"\n}\n```\n\nor run with `npx`:\n```\n# npx publish-to-git\n```\n\nSee also a few options which may assist in your particular use case:\n```\nOptions:\n  --help     Show help [boolean]\n  --version  Show version number [boolean]\n  --remote   Git remote, may be remote name or full URL to the repo [default: \"origin\"]\n  --tag      Tag name to which src will be published, for example: v1.2.3 - by default uses version from package.json\n  --branch   Branch name to append this new release to - none by default\n  --push     Push update to the git remote (pass --no-push to disable) [boolean] [default: \"true\"]\n  --force    Override any existing tag on the remote as well as locally (git tag -f, git push -f) [boolean]\n\nExamples:\n  publish-to-git --tag v2.1.3 --no-push     # by default version from package.json is used\n  publish-to-git --remote https://USER:GITHUB_TOKEN@github.com/USER/REPO\n  publish-to-git --force    # useful in CI and when we want to override the same tag which triggered the build\n```\n\n## Programmatic usage\n\n```js\nconst { publish } = require('publish-to-git');\n\nconst options = {\n  tag: 'v1.0.0', // you can also provide version: '1.0.0' instead of tag\n  push: { // set to false to not push\n    remote: 'origin', // set to URL or remote name\n    force: false, // set to true to force push\n  }\n};\n\npublish(options).then(() =\u003e {\n  console.log('Done');\n});\n```\n\nPlease see https://github.com/Rush/publish-to-git/blob/master/main.js for reference\n\n## Usage in Drone CI\n\nThis example assumes that the developer pushes a tag that's identical to the version in package json. CI will complete the build and override tag contents. If you find this approach ugly, you could push tags in form of `build-v1.0.0` and then have `publish-to-git` publish using default options.\n\n```yaml\npipeline:\n  # other pipelines here, like build etc.\n  publish-to-git:\n    commands:\n      - git config --global user.email \"admin@drone\" # git will complain if these are not set\n      - git config --global user.name \"Drone CI\"\n      - npx publish-to-git --force # this will override existing tag with npm package contents\n    when:\n      event: tag\n```\n\n## Quick note on semver with https\nOlder versions of `npm` prior to `6.0` had a bug with supporting semver git packages. It's no longer a problem since npm `6.0`.\n\nFor automated publishing to Github `~/.netc` and `npm`/`git` will automatically pick it up:\n```\nmachine github.com\nlogin \u003cGITHUB_TOKEN\u003e\npassword=x-oauth-basic\n```\n\n## License\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frush%2Fpublish-to-git","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frush%2Fpublish-to-git","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frush%2Fpublish-to-git/lists"}