diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..5ace460 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,6 @@ +version: 2 +updates: + - package-ecosystem: "github-actions" + directory: "/" + schedule: + interval: "weekly" diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..5aa67b0 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,35 @@ +name: Release +concurrency: ci-${{ github.ref }} +on: + workflow_dispatch: +jobs: + build: + runs-on: ubuntu-22.04 + permissions: + contents: write + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + - uses: fregante/setup-git-user@v2 + - uses: actions/setup-java@v3 + with: + distribution: "temurin" + java-version: 17 + - name: Capture Version + run: | + echo "captured_version=$(./gradlew printVersionName | grep -Po '(?<=GRADLE_VERSION=\()(.*)(?=\))')" >> "$GITHUB_ENV" + id: capture_version + - name: Set Version + uses: rickstaa/action-create-tag@v1 + id: "tag_create" + with: + tag: ${{ env.captured_version }} + - uses: gradle/gradle-build-action@v2 + with: + arguments: build publish + cache-read-only: ${{ !startsWith(github.ref, 'refs/heads/1.') }} + env: + MAVEN_USER: github + MAVEN_PASSWORD: ${{ secrets.RELEASE_MAVEN_PASSWORD }} + MAVEN_URL: https://maven.lukebemish.dev/releases/ diff --git a/build.gradle b/build.gradle index 556bc64..f3eef4b 100644 --- a/build.gradle +++ b/build.gradle @@ -1,5 +1,6 @@ plugins { id 'java-gradle-plugin' + id 'maven-publish' } group = 'dev.lukebemish' @@ -12,4 +13,35 @@ gradlePlugin { implementationClass = 'dev.lukebemish.managedversioning.ManagedVersioningPlugin' } } -} \ No newline at end of file +} + +tasks.register('printVersionName') { + doLast{ + project.exec { + commandLine 'echo', "GRADLE_VERSION=(${project.version})" + } + } +} + +java.withSourcesJar() +java.withJavadocJar() +java.toolchain.languageVersion.set JavaLanguageVersion.of(17) + +processResources { + from rootProject.file('LICENSE') +} + +publishing { + repositories { + if (System.getenv('MAVEN_URL')) { + maven { + name = 'LukesMaven' + url = System.getenv('MAVEN_URL') + credentials { + username = System.getenv('MAVEN_USER') ?: '' + password = System.getenv('MAVEN_PASSWORD') ?: '' + } + } + } + } +} diff --git a/src/main/java/dev/lukebemish/managedversioning/ManagedVersioningExtension.java b/src/main/java/dev/lukebemish/managedversioning/ManagedVersioningExtension.java index b8a2e7b..d004079 100644 --- a/src/main/java/dev/lukebemish/managedversioning/ManagedVersioningExtension.java +++ b/src/main/java/dev/lukebemish/managedversioning/ManagedVersioningExtension.java @@ -37,6 +37,7 @@ public abstract class ManagedVersioningExtension { public ManagedVersioningExtension(Project project) { this.project = project; + this.getGitWorkingDir().convention(project.getLayout().getProjectDirectory()); this.getStagedChangesVersionSuffix().convention("dirty"); this.getUnstagedChangesVersionSuffix().convention("dirty"); this.gitHash = project.getProviders().of(GitValueSource.class, spec -> {