Skip to content

Commit

Permalink
Why can't you just be normal TeamCity
Browse files Browse the repository at this point in the history
  • Loading branch information
octylFractal committed Jun 25, 2024
1 parent c2905d7 commit 77f07ad
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 39 deletions.
26 changes: 0 additions & 26 deletions .github/workflows/gradle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,29 +33,3 @@ jobs:
with:
name: reports for ${{ matrix.os }}
path: '**/build/reports/**'
deploy:
name: Deploy lin-bus to Artifactory
needs: build
runs-on: ubuntu-latest
if: github.ref_name == 'master' || (github.ref_type == 'tag' && startsWith(github.ref_name, 'v'))
steps:
- uses: actions/checkout@v4
with:
lfs: true

- name: Set up JDK
uses: actions/setup-java@v4
with:
java-version: 17
distribution: 'temurin'

- name: Setup Gradle
uses: gradle/actions/setup-gradle@v3

- name: Deploy to Artifactory
shell: bash
env:
ORG_GRADLE_PROJECT_artifactory_contextUrl: ${{ secrets.ARTIFACTORY_CONTEXTURL }}
ORG_GRADLE_PROJECT_artifactory_user: ${{ secrets.ARTIFACTORY_USER }}
ORG_GRADLE_PROJECT_artifactory_password: ${{ secrets.ARTIFACTORY_PASSWORD }}
run: ./gradlew publishToMavenLocal artifactoryPublish -s
59 changes: 47 additions & 12 deletions .teamcity/_Self/LinBus.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package _Self

import jetbrains.buildServer.configs.kotlin.*
import jetbrains.buildServer.configs.kotlin.buildFeatures.commitStatusPublisher
import jetbrains.buildServer.configs.kotlin.buildFeatures.sshAgent
import jetbrains.buildServer.configs.kotlin.buildSteps.GradleBuildStep
import jetbrains.buildServer.configs.kotlin.buildSteps.gradle
import jetbrains.buildServer.configs.kotlin.buildSteps.script
Expand Down Expand Up @@ -46,6 +47,41 @@ object Build : BuildType({
}
})

const val ARTIFACTORY_PARAMS = "-Partifactory_contextUrl=%artifactory.contextUrl% " +
"-Partifactory_user=%artifactory.user% " +
"-Partifactory_password=%artifactory.password%"

object DeployNormal : BuildType({
id = RelativeId("DeployNormal")
name = "DeployNormal"
description = "Make a normal deployment of the project."

vcs {
root(DslContext.settingsRoot)
branchFilter = "+:<default>"
}

triggers {
vcs {
}
}

dependencies {
snapshot(Build) {
onDependencyFailure = FailureAction.FAIL_TO_START
}
}

steps {
configuredGradle {
name = "Publish"
tasks = "publishToMavenLocal artifactoryPublish"
gradleParams = ARTIFACTORY_PARAMS
}
}
})


object Release : BuildType({
id = RelativeId("Release")
name = "Release"
Expand All @@ -68,33 +104,32 @@ object Release : BuildType({
}

steps {
script {
name = "Setup git for push"
scriptContent = """
set -e
git config --global credential.helper store
echo "https://git:%git.github.token.push%@github.com" > ~/.git-credentials
""".trimIndent()
}
configuredGradle {
name = "Switch to release version"
tasks = "changeSnapshotToRelease"
}
configuredGradle {
name = "Publish release version"
tasks = "publishToMavenLocal artifactoryPublish"
gradleParams = "-Partifactory_contextUrl=%artifactory.contextUrl% " +
"-Partifactory_user=%artifactory.user% " +
"-Partifactory_password=%artifactory.password%"
}
script {
name = "Push release version commit"
scriptContent = """
set -e
git push origin master --tags
""".trimIndent()
gradleParams = ARTIFACTORY_PARAMS
}
configuredGradle {
name = "Switch to next snapshot version"
tasks = "changeReleaseToNextSnapshot"
}
script {
name = "Push snapshot version commit"
name = "Push version commits"
scriptContent = """
set -e
git push
git push origin master --tags
""".trimIndent()
}
}
Expand Down
2 changes: 2 additions & 0 deletions .teamcity/settings.kts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import _Self.Build
import _Self.DeployNormal
import _Self.Release
import jetbrains.buildServer.configs.kotlin.project
import jetbrains.buildServer.configs.kotlin.version
Expand All @@ -20,5 +21,6 @@ version = "2024.03"

project {
buildType(Build)
buildType(DeployNormal)
buildType(Release)
}
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
plugins {
id("org.enginehub.lin-bus.publishing")
id("org.enginehub.lin-bus.release")
id("org.enginehub.lin-bus.publishing")
}

0 comments on commit 77f07ad

Please sign in to comment.