Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/manual release #12

Merged
merged 8 commits into from
Aug 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
89 changes: 0 additions & 89 deletions .circleci/config.yml

This file was deleted.

25 changes: 25 additions & 0 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Pre Merge Checks

on:
push:
branches:
- main
pull_request:
branches:
- '*'

jobs:
gradle:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
# needed for FirstCommitHashTaskTest
fetch-depth: 0
- name: Cache
uses: gradle/gradle-build-action@v2
- name: Build
run: ./gradlew build
- name: Validate
run: ./gradlew check validatePlugins --continue
27 changes: 27 additions & 0 deletions .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Publish to Gradle Plugin Portal

on:
push:
tags:
- '*'

jobs:
gradle:
runs-on: ubuntu-latest
env:
GRADLE_PUBLISH_KEY: ${{ secrets.GRADLE_PUBLISH_KEY }}
GRADLE_PUBLISH_SECRET: ${{ secrets.GRADLE_PUBLISH_SECRET }}
steps:
- name: Checkout
uses: actions/checkout@v3
with:
# needed for FirstCommitHashTaskTest
fetch-depth: 0
- name: Cache
uses: gradle/gradle-build-action@v2
- name: Build
run: ./gradlew build
- name: Validate
run: ./gradlew validatePlugins --continue
- name: Publish
run: ./gradlew publishPlugins
25 changes: 25 additions & 0 deletions src/main/kotlin/com/liftric/octopusdeploy/OctopusDeployPlugin.kt
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import org.gradle.api.Project
internal const val extensionName = "octopus"

class OctopusDeployPlugin : Plugin<Project> {
@Suppress("UNUSED_VARIABLE")
override fun apply(project: Project) {
val extension = project.extensions.create(extensionName, OctopusDeployExtension::class.java, project)
extension.outputDir.apply {
Expand Down Expand Up @@ -59,6 +60,26 @@ class OctopusDeployPlugin : Plugin<Project> {
buildInformationAddition = extension.buildInformationAddition
}
}
val createBuildInformationMarkdownTask =
project.tasks.create("createBuildInformationMarkdown", CreateBuildInformationMarkdownTask::class.java)
.apply {
val task = this
project.afterEvaluate {
if (extension.generateChangelogSinceLastTag) {
dependsOn(commitsSinceLastTagTask)
}
commits = emptyList()
packageName.set(extension.packageName)
issueTrackerName.set(extension.issueTrackerName)
parseCommitsForJiraIssues.set(extension.parseCommitsForJiraIssues)
jiraBaseBrowseUrl.set(extension.jiraBaseBrowseUrl)
task.version.set(extension.version)
}
doFirst {
commits = commitsSinceLastTagTask.commits
buildInformationAddition = extension.buildInformationAddition
}
}
val uploadBuildInformationTask =
project.tasks.create("uploadBuildInformation", UploadBuildInformationTask::class.java).apply {
dependsOn(createBuildInformationTask)
Expand Down Expand Up @@ -94,6 +115,10 @@ class OctopusDeployPlugin : Plugin<Project> {
httpLogLevel.set(extension.httpLogLevel)
}
}
project.tasks.withType(CreateReleaseTask::class.java) {
apiKey.convention(extension.apiKey)
octopusUrl.convention(extension.serverUrl)
}
}
}

Expand Down
80 changes: 40 additions & 40 deletions src/main/kotlin/com/liftric/octopusdeploy/api/Progression.kt
Original file line number Diff line number Diff line change
Expand Up @@ -218,85 +218,85 @@ data class DeploymentDeploymentLinks(
)

data class Task(
@get:JsonProperty("Id", required = true) @field:JsonProperty("Id", required = true)
val id: String,
@get:JsonProperty("Id") @field:JsonProperty("Id")
val id: String? = null,
nvima marked this conversation as resolved.
Show resolved Hide resolved

@get:JsonProperty("SpaceId", required = true) @field:JsonProperty("SpaceId", required = true)
val spaceID: String,
@get:JsonProperty("SpaceId") @field:JsonProperty("SpaceId")
val spaceID: String? = null,

@get:JsonProperty("Name", required = true) @field:JsonProperty("Name", required = true)
val name: String,
@get:JsonProperty("Name") @field:JsonProperty("Name")
val name: String? = null,

@get:JsonProperty("Description", required = true) @field:JsonProperty("Description", required = true)
val description: String,
@get:JsonProperty("Description") @field:JsonProperty("Description")
val description: String? = null,

@get:JsonProperty("Arguments", required = true) @field:JsonProperty("Arguments", required = true)
val arguments: Arguments,
@get:JsonProperty("Arguments") @field:JsonProperty("Arguments")
val arguments: Arguments? = null,

@get:JsonProperty("State", required = true) @field:JsonProperty("State", required = true)
val state: String,
@get:JsonProperty("State") @field:JsonProperty("State")
val state: String? = null,

@get:JsonProperty("QueueTime", required = true) @field:JsonProperty("QueueTime", required = true)
val queueTime: String,
@get:JsonProperty("QueueTime") @field:JsonProperty("QueueTime")
val queueTime: String? = null,

@get:JsonProperty("QueueTimeExpiry") @field:JsonProperty("QueueTimeExpiry")
val queueTimeExpiry: Any? = null,

@get:JsonProperty("StartTime", required = true) @field:JsonProperty("StartTime", required = true)
val startTime: String,
@get:JsonProperty("StartTime") @field:JsonProperty("StartTime")
val startTime: String? = null,

@get:JsonProperty("LastUpdatedTime", required = true) @field:JsonProperty("LastUpdatedTime", required = true)
val lastUpdatedTime: String,
@get:JsonProperty("LastUpdatedTime") @field:JsonProperty("LastUpdatedTime")
val lastUpdatedTime: String? = null,

@get:JsonProperty("CompletedTime") @field:JsonProperty("CompletedTime")
val completedTime: Any? = null,

@get:JsonProperty("ServerNode", required = true) @field:JsonProperty("ServerNode", required = true)
val serverNode: String,
@get:JsonProperty("ServerNode") @field:JsonProperty("ServerNode")
val serverNode: String? = null,

@get:JsonProperty("Duration", required = true) @field:JsonProperty("Duration", required = true)
val duration: String,
@get:JsonProperty("Duration") @field:JsonProperty("Duration")
val duration: String? = null,

@get:JsonProperty("ErrorMessage", required = true) @field:JsonProperty("ErrorMessage", required = true)
val errorMessage: String,
@get:JsonProperty("ErrorMessage") @field:JsonProperty("ErrorMessage")
val errorMessage: String? = null,

@get:JsonProperty("HasBeenPickedUpByProcessor", required = true) @field:JsonProperty(
@get:JsonProperty("HasBeenPickedUpByProcessor") @field:JsonProperty(
"HasBeenPickedUpByProcessor",
required = true
)
val hasBeenPickedUpByProcessor: Boolean,
val hasBeenPickedUpByProcessor: Boolean? = null,

@get:JsonProperty("IsCompleted", required = true) @field:JsonProperty("IsCompleted", required = true)
val isCompleted: Boolean,
@get:JsonProperty("IsCompleted") @field:JsonProperty("IsCompleted")
val isCompleted: Boolean? = null,

@get:JsonProperty("FinishedSuccessfully", required = true) @field:JsonProperty(
@get:JsonProperty("FinishedSuccessfully") @field:JsonProperty(
"FinishedSuccessfully",
required = true
)
val finishedSuccessfully: Boolean,
val finishedSuccessfully: Boolean? = null,

@get:JsonProperty("HasPendingInterruptions", required = true) @field:JsonProperty(
@get:JsonProperty("HasPendingInterruptions") @field:JsonProperty(
"HasPendingInterruptions",
required = true
)
val hasPendingInterruptions: Boolean,
val hasPendingInterruptions: Boolean? = null,

@get:JsonProperty("CanRerun", required = true) @field:JsonProperty("CanRerun", required = true)
val canRerun: Boolean,
@get:JsonProperty("CanRerun") @field:JsonProperty("CanRerun")
val canRerun: Boolean? = null,

@get:JsonProperty("HasWarningsOrErrors", required = true) @field:JsonProperty(
@get:JsonProperty("HasWarningsOrErrors") @field:JsonProperty(
"HasWarningsOrErrors",
required = true
)
val hasWarningsOrErrors: Boolean,
val hasWarningsOrErrors: Boolean? = null,

@get:JsonProperty("Links", required = true) @field:JsonProperty("Links", required = true)
val links: TaskLinks
@get:JsonProperty("Links") @field:JsonProperty("Links")
val links: TaskLinks? = null
)

data class Arguments(
@get:JsonProperty("DeploymentId", required = true) @field:JsonProperty("DeploymentId", required = true)
val deploymentID: String
@get:JsonProperty("DeploymentId") @field:JsonProperty("DeploymentId")
val deploymentID: String? = null
)

data class TaskLinks(
Expand Down
26 changes: 26 additions & 0 deletions src/main/kotlin/com/liftric/octopusdeploy/buildinformation.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package com.liftric.octopusdeploy

import com.liftric.octopusdeploy.api.CommitCli
import com.liftric.octopusdeploy.api.WorkItem

fun parseCommitsForJira(
commits: List<CommitCli>,
jiraBaseBrowseUrl: String
): List<WorkItem> {
val jiraIssues = commits
.mapNotNull { it.Comment }
.map { jiraKeyRegex.findAll(it).map { it.groupValues[1] }.toList() }
.flatten()
.toSet()
println("parseCommitsForJira: found $jiraIssues")
return jiraIssues.map {
WorkItem(
Id = it,
LinkUrl = "${jiraBaseBrowseUrl.removeSuffix("/")}/$it",
Description = "some placeholder text"
)
}
}

// from https://confluence.atlassian.com/stashkb/integrating-with-custom-jira-issue-key-313460921.html
private val jiraKeyRegex = Regex("((?<!([A-Z]{1,10})-?)[A-Z]+-\\d+)")
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,3 @@ interface Progressions {
}

fun Progression.anyOngoingTask(): Boolean = phases.any { it.deployments.any { it.task?.isCompleted == false } }

Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
package com.liftric.octopusdeploy.task

import com.liftric.octopusdeploy.api.BuildInformationCli
import com.liftric.octopusdeploy.api.CommitCli
import org.gradle.api.DefaultTask
import org.gradle.api.provider.Property
import org.gradle.api.tasks.Input
import org.gradle.api.tasks.Optional
import org.gradle.api.tasks.OutputFile
import org.gradle.kotlin.dsl.property
import java.io.File

abstract class AbstractBuildInformationTask : DefaultTask() {

@Input
val packageName: Property<String> = project.objects.property()

@Input
val version: Property<String> = project.objects.property()

@Input
lateinit var commits: List<CommitCli>

@Input
var buildInformationAddition: BuildInformationCli.() -> Unit = {}

@OutputFile
@Optional
var outputFile: File? = null

@Input
@Optional
val issueTrackerName: Property<String> = project.objects.property()

@Input
@Optional
val parseCommitsForJiraIssues: Property<Boolean> = project.objects.property()

@Input
@Optional
val jiraBaseBrowseUrl: Property<String> = project.objects.property()
}
Loading