{"id":16465034,"url":"https://github.com/ajoberstar/gradle-git-publish","last_synced_at":"2025-04-05T20:06:53.291Z","repository":{"id":44513335,"uuid":"72951567","full_name":"ajoberstar/gradle-git-publish","owner":"ajoberstar","description":"Gradle plugin for publishing to Git repositories","archived":false,"fork":false,"pushed_at":"2025-03-09T19:26:59.000Z","size":758,"stargazers_count":96,"open_issues_count":1,"forks_count":16,"subscribers_count":5,"default_branch":"main","last_synced_at":"2025-03-29T19:04:50.110Z","etag":null,"topics":["git","github-pages","gradle","gradle-plugin","publish"],"latest_commit_sha":null,"homepage":null,"language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ajoberstar.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":"2016-11-05T20:30:25.000Z","updated_at":"2025-03-09T16:31:05.000Z","dependencies_parsed_at":"2022-08-14T22:50:09.856Z","dependency_job_id":"fea8d2e3-57cc-4831-aba4-235adca9605e","html_url":"https://github.com/ajoberstar/gradle-git-publish","commit_stats":{"total_commits":152,"total_committers":7,"mean_commits":"21.714285714285715","dds":"0.29605263157894735","last_synced_commit":"e9b625b50b28c17e4c50e2f6234156c4b28ef7ed"},"previous_names":[],"tags_count":67,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ajoberstar%2Fgradle-git-publish","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ajoberstar%2Fgradle-git-publish/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ajoberstar%2Fgradle-git-publish/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ajoberstar%2Fgradle-git-publish/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ajoberstar","download_url":"https://codeload.github.com/ajoberstar/gradle-git-publish/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247393569,"owners_count":20931812,"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","github-pages","gradle","gradle-plugin","publish"],"created_at":"2024-10-11T11:31:42.855Z","updated_at":"2025-04-05T20:06:53.238Z","avatar_url":"https://github.com/ajoberstar.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# gradle-git-publish\n\n[![CI](https://github.com/ajoberstar/gradle-git-publish/actions/workflows/ci.yaml/badge.svg)](https://github.com/ajoberstar/gradle-git-publish/actions/workflows/ci.yaml)\n\n\u003e [!NOTE]\n\u003e As of 3.0.1, gradle-git-publish is published to Maven Central\n\n## Getting Help or Contributing\n\n\u003e [!IMPORTANT]\n\u003e I consider this plugin feature complete and don't spend a lot of time on maintenance due to other time commitments. While, I will eventually get to issues or PRs raised, do not expect a timely response. I'm not trying to be rude or dismissive, I only get back to this project periodically (on the order of _months_, in many cases). Please set your expectations appropriately as you file issues or open PRs.\n\nPlease use the repo's [issues](https://github.com/ajoberstar/gradle-git-publish/issues) for all questions, bug reports, and feature requests.\n\n## Why do you care?\n\nGit is immensely popular and being able to publish to it as part of a build process can be very valuable, for example to publish a blog or project documentation to GitHub Pages.\n\n## What is it?\n\n`gradle-git-publish` is a [Gradle](http://gradle.org) plugin, `org.ajoberstar.git-publish`, which publishes files to a\nremote Git repository's branch.\n\n## Usage\n\nSee the [Release Notes](https://github.com/ajoberstar/gradle-git-publish/releases) for updates on changes and compatibility with Java and Gradle versions.\n\n\u003e [!NOTE]\n\u003e As of 5.0.0, the plugin uses the Git CLI for all behavior. `git` binary must be on the `PATH`.\n\u003e\n\u003e Git 2.28.0 or higher is required.\n\u003e\n\u003e If you relied on Grgit's authentication, such as `GRGIT_USER`, use the new `username` and `password` properties on the `GitPublication`. See the configuration documentation below.\n\n### Applying the Plugin\n\n```groovy\nplugins {\n    id 'org.ajoberstar.git-publish' version '\u003cversion\u003e'\n}\n```\n\n### Configuration\n\n**NOTE:** In general, there are no default values here. The main exception is that the `repoUri` and `referenceRepoUri` will be automatically set to your project's git repo's origin and root dir, respectively.\n\n```groovy\ngitPublish {\n    // where to publish to (repo must exist)\n    repoUri = 'git@github.com:ajoberstar/test-repo.git'\n    // (or 'https://github.com/ajoberstar/test-repo.git', depending on authentication)\n\n    // where to fetch from prior to fetching from the remote (i.e. a local repo to save time)\n    referenceRepoUri = 'file:///home/human/projects/test-repo/'\n\n    // branch will be created if it doesn't exist\n    branch = 'gh-pages'\n  \n    // if set, a shallow clone will be performed instead of pulling all history\n    fetchDepth = null\n\n    // generally, you don't need to touch this\n    repoDir = file(\"$buildDir/somewhere-else\") // defaults to $buildDir/gitPublish\n\n    // what to publish, this is a standard CopySpec\n    contents {\n        from 'src/pages'\n        from(javadoc) {\n            into 'api'\n        }\n    }\n\n    // what to keep in the existing branch (include=keep)\n    preserve {\n        include '1.0.0/**'\n        exclude '1.0.0/temp.txt'\n    }\n\n    // message used when committing changes\n    commitMessage = 'Publishing a new page' // defaults to 'Generated by gradle-git-publish'\n    \n    // for signing commits, omit to use the default from your gitconfig\n    sign = false\n    \n    // if you need to provide credentials, set both of these\n    // use an external source, such as an environment variable\n    username = 'dont-harcode'\n    password = 'dont-hardcode'\n}\n```\n\nAs of v4.1.0, you can now configure multiple publications (e.g. to target different repositories or branches).\n\n```groovy\ngitPublish {\n    commitMessage = 'My favorite commit message' // configures the main publication\n\n    publications {\n        // main\n        main {\n            branch = 'great-branch' // alternatively can configure at the top-level of the gitPublish block\n            // ... any other config from the gitPublish block ...\n        }\n\n        other {\n            branch = 'some-branch' // may need branch.set('some-branch')\n            // ... any other config from the gitPublish block ...\n        }\n    }\n}\n```\n\n### Tasks and Execution\n\nGenerally, you'll just run `gitPublishPush`, but there is a series of four tasks that happen in order.\n\n- `gitPublishReset` - Clones/updates the working repo to the latest commit on the `repoUri` `branch` head. All files not included by the `preserve` filters will be deleted and staged.\n- `gitPublishCopy` - Copies any files defined in the `contents` CopySpec into the working repo.\n- `gitPublishCommit` - Commits all changes to the working repo.\n- `gitPublishPush` - If changes were committed, pushed them to the `repoUri`.\n\nEach publication gets its own set of tasks, with a general `gitPublishPushAll` if you want to push all publications to their respective repos/branches.\n\nAs is common in Gradle, the `main` publication is not indicated in task names (e.g. for `main` `gitPublishCommit` and for `other` `gitPublishOtherCommit`).\n\n### Avoiding Extra Copy\n\nIf you are generating a large site, you may want to directly generate it into the working repo to save an extra copy step. You can do this with task dependencies and referring to the `repoDir`.\n\n```groovy\njbakeTask {\n    outputDir gitPublish.repoDir\n    dependsOn gitPublishReset\n}\n\ngitPublishCommit.dependsOn jbakeTask\n```\n\n## Migrating from org.ajoberstar.github-pages\n\nThe following table should help translate settings you used in `org.ajoberstar.github-pages` to this plugin's format. Additionally reference the Configuration section above for more information on the current feature set.\n\n| org.ajoberstar.github-pages | org.ajoberstar.git-publish  | Comment                                                                                              |\n| --------------------------- | --------------------------- | ---------------------------------------------------------------------------------------------------- |\n| `repoUri`                   | `repoUri`                   | Used to allow any Object (which would be lazily unpacked to a String). Now requires a String.        |\n| `targetBranch`              | `branch`                    | The old plugin defaulted to `gh-pages`, the new one has no default. This must be a String.           |\n| `workingPath`               | `repoDir`                   | Used to allow any Object and called `file()` on it for you. Now expects a File.                      |\n| `pages`                     | `contents`                  | Just a name change.                                                                                  |\n| `deleteExistingFiles`       | `preserve`                  | If previously `true` (the default), do nothing. If previously `false`, `preserve { include '**/*' }` |\n| `commitMessage`             | `commitMessage`             | Just copy from the old value.                                                                        |\n| `credentials`               | env variable or system prop | `GRGIT_USER` environment variable or `org.ajoberstar.grgit.auth.username` system property.           |\n\nUse the `gitPublishPush` task as replacement for the `publishGhPages` task.\n\n## Finding versions\n\n### Newest versions are on Maven Central\n\nAs of 3.0.1, gradle-git-publish is published to Maven Central.\n\nThis project is no longer directly published to the Gradle Plugin Portal, but since the portal proxies Maven Central you can still access it through the portal. The only side effect is that [the portal](https://plugins.gradle.org/plugin/org.ajoberstar.git-publish) will no longer list the latest version. Use this repo or [search.maven.org](https://search.maven.org/search?q=g:org.ajoberstar.git-publish) to find the latest version.\n\n### Old versions from Bintray/JCenter\n\nThis project was previously uploaded to JCenter, which was deprecated in 2021.\n\nIn the event that JCenter is unavailable and acess to past versions is needed, I've made a Maven repo available in [bintray-backup](https://github.com/ajoberstar/bintray-backup). Add the following to your repositories to use it.\n\n```groovy\nmaven {\n  name = 'ajoberstar-backup'\n  url = 'https://ajoberstar.org/bintray-backup/'\n}\n```\n\nMade possible by [lacasseio/bintray-helper](https://github.com/lacasseio/bintray-helper) in case you have a similar need to pull your old Bintray artifacts.\n\n## Acknowledgements\n\nThanks to all of the [contributors](https://github.com/ajoberstar/gradle-git-publish/graphs/contributors).\n\nI also want to acknowledge [Peter Ledbrook](https://github.com/pledbrook) for the initial\nidea and code for the plugin.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fajoberstar%2Fgradle-git-publish","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fajoberstar%2Fgradle-git-publish","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fajoberstar%2Fgradle-git-publish/lists"}