From 6b9d1976965848f4ad3cb13acaeba38ce10ba718 Mon Sep 17 00:00:00 2001 From: Raycoms Date: Sun, 18 Aug 2024 09:44:21 +0200 Subject: [PATCH] github actions --- .github/workflows/build.yaml | 30 ++ .github/workflows/release.yml | 27 ++ .teamcity/patches/buildTypes/Beta_Release.kts | 58 --- .teamcity/pom.xml | 104 ----- .teamcity/settings.kts | 379 ------------------ 5 files changed, 57 insertions(+), 541 deletions(-) create mode 100644 .github/workflows/build.yaml create mode 100644 .github/workflows/release.yml delete mode 100644 .teamcity/patches/buildTypes/Beta_Release.kts delete mode 100644 .teamcity/pom.xml delete mode 100644 .teamcity/settings.kts diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml new file mode 100644 index 0000000000..e44ea7e26e --- /dev/null +++ b/.github/workflows/build.yaml @@ -0,0 +1,30 @@ +name: Build and Test PRs or General Branches + +on: + pull_request: + types: + - synchronize + - opened + - ready_for_review + - reopened + push: + branches: + - 'feature/**' + - 'bugfix/**' + - 'hotfix/**' + - 'fix/**' + - 'features/**' + workflow_dispatch: + +permissions: + contents: write + statuses: write + +jobs: + release: + uses: ldtteam/operapublicacreator/.github/workflows/gradle.build.yaml@ng7 + with: + java: 21 + secrets: + CROWDIN_API_KEY: ${{ secrets.CROWDIN_API_KEY }} + GRADLE_ENCRYPTION_KEY: ${{ secrets.GRADLE_ENCRYPTION_KEY }} \ No newline at end of file diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000000..4c5b568d78 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,27 @@ +name: Release + +on: + push: + branches: [ + "version/*", + "release/*", + "testing/*", + ] + +permissions: + contents: write + statuses: write + +jobs: + release: + uses: ldtteam/operapublicacreator/.github/workflows/gradle.publish.yaml@ng7 + with: + java: 21 + curse_release_type: ${{ contains(github.ref, 'release') && 'release' || 'beta' }} + secrets: + DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }} + MAVEN_USER: ${{ secrets.MAVEN_USER }} + MAVEN_PASSWORD: ${{ secrets.MAVEN_PASSWORD }} + CROWDIN_API_KEY: ${{ secrets.CROWDIN_API_KEY }} + CURSE_API_KEY: ${{ secrets.CURSE_API_KEY }} + GRADLE_ENCRYPTION_KEY: ${{ secrets.GRADLE_ENCRYPTION_KEY }} \ No newline at end of file diff --git a/.teamcity/patches/buildTypes/Beta_Release.kts b/.teamcity/patches/buildTypes/Beta_Release.kts deleted file mode 100644 index 6812b67962..0000000000 --- a/.teamcity/patches/buildTypes/Beta_Release.kts +++ /dev/null @@ -1,58 +0,0 @@ -package patches.buildTypes - -import jetbrains.buildServer.configs.kotlin.v2019_2.* -import jetbrains.buildServer.configs.kotlin.v2019_2.buildSteps.gradle -import jetbrains.buildServer.configs.kotlin.v2019_2.triggers.ScheduleTrigger -import jetbrains.buildServer.configs.kotlin.v2019_2.triggers.schedule -import jetbrains.buildServer.configs.kotlin.v2019_2.ui.* - -/* -This patch script was generated by TeamCity on settings change in UI. -To apply the patch, change the buildType with id = 'Beta_Release' -accordingly, and delete the patch script. -*/ -changeBuildType(RelativeId("Beta_Release")) { - vcs { - - check(branchFilter == "+:*") { - "Unexpected option value: branchFilter = $branchFilter" - } - branchFilter = "+:*" - } - - expectSteps { - gradle { - name = "Compile" - id = "RUNNER_9" - tasks = "build createChangelog curseforge publish" - buildFile = "build.gradle" - enableStacktrace = true - param("org.jfrog.artifactory.selectedDeployableServer.deployReleaseText", "%Project.Type%") - param("org.jfrog.artifactory.selectedDeployableServer.publishBuildInfo", "true") - param("org.jfrog.artifactory.selectedDeployableServer.defaultModuleVersionConfiguration", "GLOBAL") - param("org.jfrog.artifactory.selectedDeployableServer.urlId", "2") - param("org.jfrog.artifactory.selectedDeployableServer.envVarsExcludePatterns", "*password*,*secret*") - param("org.jfrog.artifactory.selectedDeployableServer.resolvingRepo", "modding") - param("org.jfrog.artifactory.selectedDeployableServer.deployReleaseFlag", "true") - param("org.jfrog.artifactory.selectedDeployableServer.targetRepo", "libraries") - } - } - steps { - check(stepsOrder == arrayListOf("RUNNER_85", "RUNNER_9")) { - "Unexpected build steps order: $stepsOrder" - } - stepsOrder = arrayListOf("RUNNER_9") - } - - triggers { - add { - schedule { - id = "TRIGGER_14" - schedulingPolicy = weekly { - dayOfWeek = ScheduleTrigger.DAY.Saturday - } - triggerBuild = always() - } - } - } -} diff --git a/.teamcity/pom.xml b/.teamcity/pom.xml deleted file mode 100644 index 8d8963874f..0000000000 --- a/.teamcity/pom.xml +++ /dev/null @@ -1,104 +0,0 @@ - - - 4.0.0 - LetSDevTogether_Structurize Config DSL Script - LetSDevTogether_Structurize - LetSDevTogether_Structurize_dsl - 1.0-SNAPSHOT - - - org.jetbrains.teamcity - configs-dsl-kotlin-parent - 1.0-SNAPSHOT - - - - - jetbrains-all - https://download.jetbrains.com/teamcity-repository - - true - - - - teamcity-server - https://buildsystem.ldtteam.com/app/dsl-plugins-repository - - true - - - - - - - JetBrains - https://download.jetbrains.com/teamcity-repository - - - - - ${basedir} - - - kotlin-maven-plugin - org.jetbrains.kotlin - ${kotlin.version} - - - - - compile - process-sources - - compile - - - - test-compile - process-test-sources - - test-compile - - - - - - org.jetbrains.teamcity - teamcity-configs-maven-plugin - ${teamcity.dsl.version} - - kotlin - target/generated-configs - - - - - - - - org.jetbrains.teamcity - configs-dsl-kotlin - ${teamcity.dsl.version} - compile - - - org.jetbrains.teamcity - configs-dsl-kotlin-plugins - 1.0-SNAPSHOT - pom - compile - - - org.jetbrains.kotlin - kotlin-stdlib-jdk8 - ${kotlin.version} - compile - - - org.jetbrains.kotlin - kotlin-script-runtime - ${kotlin.version} - compile - - - \ No newline at end of file diff --git a/.teamcity/settings.kts b/.teamcity/settings.kts deleted file mode 100644 index 078b55ce57..0000000000 --- a/.teamcity/settings.kts +++ /dev/null @@ -1,379 +0,0 @@ -import jetbrains.buildServer.configs.kotlin.v2019_2.* -import jetbrains.buildServer.configs.kotlin.v2019_2.buildFeatures.commitStatusPublisher -import jetbrains.buildServer.configs.kotlin.v2019_2.buildFeatures.vcsLabeling -import jetbrains.buildServer.configs.kotlin.v2019_2.buildSteps.GradleBuildStep -import jetbrains.buildServer.configs.kotlin.v2019_2.buildSteps.gradle -import jetbrains.buildServer.configs.kotlin.v2019_2.projectFeatures.githubIssues -import jetbrains.buildServer.configs.kotlin.v2019_2.triggers.schedule -import jetbrains.buildServer.configs.kotlin.v2019_2.triggers.vcs - -/* -The settings script is an entry point for defining a TeamCity -project hierarchy. The script should contain a single call to the -project() function with a Project instance or an init function as -an argument. - -VcsRoots, BuildTypes, Templates, and subprojects can be -registered inside the project using the vcsRoot(), buildType(), -template(), and subProject() methods respectively. - -To debug settings scripts in command-line, run the - - mvnDebug org.jetbrains.teamcity:teamcity-configs-maven-plugin:generate - -command and attach your debugger to the port 8000. - -To debug in IntelliJ Idea, open the 'Maven Projects' tool window (View --> Tool Windows -> Maven Projects), find the generate task node -(Plugins -> teamcity-configs -> teamcity-configs:generate), the -'Debug' option is available in the context menu for the task. -*/ - -version = "2021.2" - -project { - description = "The Structurize Minecraft Mod" - - params { - param("env.JDK_VERSION", "jdk17") - param("Project.Type", "mods") - param("env.Version.Patch", "0") - param("env.Version.Suffix", "") - param("env.Version.Major", "1") - text("env.Version", "%env.Version.Major%.%env.Version.Minor%.%env.Version.Patch%%env.Version.Suffix%", label = "Version", description = "The version of the project.", display = ParameterDisplay.HIDDEN, allowEmpty = true) - param("Current Minecraft Version", "main") - text("Repository", "ldtteam/structurize", label = "Repository", description = "The repository for structurize.", readOnly = true, allowEmpty = true) - param("env.Version.Minor", "0") - param("Upsource.Project.Id", "structurize") - param("Default.Branch", "version/main") - param("env.GRADLE_VERSION", "7.3") - param("filename.prefix", "structurize") - } - - features { - githubIssues { - id = "PROJECT_EXT_22" - displayName = "ldtteam/structurize" - repositoryURL = "https://github.com/ldtteam/structurize" - authType = accessToken { - accessToken = "credentialsJSON:47381468-aceb-4992-93c9-1ccd4d7aa67f" - } - } - } - subProjectsOrder = arrayListOf(RelativeId("Release"), RelativeId("UpgradeBetaRelease"), RelativeId("Beta"), RelativeId("OfficialPublications"), RelativeId("Branches"), RelativeId("PullRequests_2")) - - subProject(Release) - subProject(UpgradeBetaRelease) - subProject(Beta) - subProject(OfficialPublications) - subProject(Branches) - subProject(PullRequests_2) -} - -object Beta : Project({ - name = "Beta" - description = "Beta version builds of structurize" - - buildType(Beta_Release) - - params { - text("env.crowdinKey", "credentialsJSON:57fbe4f4-13dd-4c72-b6b3-3cc1e3a8240e", label = "Crowdin key", description = "The API key for crowdin to pull translations", allowEmpty = true) - param("Current Minecraft Version", "main") - param("env.GRADLE_VERSION", "7.3") - param("Default.Branch", "version/%Current Minecraft Version%") - param("VCS.Branches", "+:refs/heads/version/(*)") - param("env.CURSERELEASETYPE", "beta") - param("env.Version.Suffix", "-BETA") - } -}) - -object Beta_Release : BuildType({ - templates(AbsoluteId("LetSDevTogether_BuildWithRelease")) - name = "Release" - description = "Releases the mod as Beta to CurseForge" - - allowExternalStatus = true - - params { - param("env.Version.Patch", "${OfficialPublications_CommonB.depParamRefs.buildNumber}") - } - - steps { - gradle { - name = "Compile" - id = "RUNNER_9" - tasks = "build createChangelog curseforge publish" - buildFile = "build.gradle" - enableStacktrace = true - param("org.jfrog.artifactory.selectedDeployableServer.deployReleaseText", "%Project.Type%") - param("org.jfrog.artifactory.selectedDeployableServer.publishBuildInfo", "true") - param("org.jfrog.artifactory.selectedDeployableServer.defaultModuleVersionConfiguration", "GLOBAL") - param("org.jfrog.artifactory.selectedDeployableServer.urlId", "2") - param("org.jfrog.artifactory.selectedDeployableServer.envVarsExcludePatterns", "*password*,*secret*") - param("org.jfrog.artifactory.selectedDeployableServer.resolvingRepo", "modding") - param("org.jfrog.artifactory.selectedDeployableServer.deployReleaseFlag", "true") - param("org.jfrog.artifactory.selectedDeployableServer.targetRepo", "libraries") - } - stepsOrder = arrayListOf("RUNNER_85", "RUNNER_9") - } - - features { - vcsLabeling { - id = "BUILD_EXT_11" - vcsRootId = "${DslContext.settingsRoot.id}" - labelingPattern = "%env.Version%" - successfulOnly = true - branchFilter = "" - } - commitStatusPublisher { - id = "BUILD_EXT_15" - enabled = false - vcsRootExtId = "${DslContext.settingsRoot.id}" - publisher = upsource { - serverUrl = "https://code-analysis.ldtteam.com" - projectId = "%Upsource.Project.Id%" - userName = "upsource" - password = "credentialsJSON:f19631a7-1bc1-4a66-88a0-dc2b9cd36734" - } - } - } - - dependencies { - snapshot(OfficialPublications_CommonB) { - reuseBuilds = ReuseBuilds.NO - onDependencyFailure = FailureAction.FAIL_TO_START - } - } -}) - -object Release : Project({ - name = "Release" - description = "Release version builds of structurize" - - buildType(Release_Release) - - params { - text("env.crowdinKey", "credentialsJSON:57fbe4f4-13dd-4c72-b6b3-3cc1e3a8240e", label = "Crowdin key", description = "The API key for crowdin to pull translations", allowEmpty = true) - param("Default.Branch", "version/%Current Minecraft Version%") - param("VCS.Branches", "+:refs/heads/release/(*)") - param("env.CURSERELEASETYPE", "release") - param("env.Version.Suffix", "-RELEASE") - } -}) - -object Release_Release : BuildType({ - templates(AbsoluteId("LetSDevTogether_BuildWithRelease")) - name = "Release" - description = "Releases the mod as Release to CurseForge" - - allowExternalStatus = true - - params { - param("env.Version.Patch", "${OfficialPublications_CommonB.depParamRefs.buildNumber}") - } - - steps { - gradle { - name = "Compile" - id = "RUNNER_9" - tasks = "build createChangelog curseforge publish" - buildFile = "build.gradle" - enableStacktrace = true - param("org.jfrog.artifactory.selectedDeployableServer.deployReleaseText", "%Project.Type%") - param("org.jfrog.artifactory.selectedDeployableServer.publishBuildInfo", "true") - param("org.jfrog.artifactory.selectedDeployableServer.defaultModuleVersionConfiguration", "GLOBAL") - param("org.jfrog.artifactory.selectedDeployableServer.urlId", "2") - param("org.jfrog.artifactory.selectedDeployableServer.envVarsExcludePatterns", "*password*,*secret*") - param("org.jfrog.artifactory.selectedDeployableServer.resolvingRepo", "modding") - param("org.jfrog.artifactory.selectedDeployableServer.deployReleaseFlag", "true") - param("org.jfrog.artifactory.selectedDeployableServer.targetRepo", "libraries") - } - stepsOrder = arrayListOf("RUNNER_85", "RUNNER_9") - } - - features { - vcsLabeling { - id = "BUILD_EXT_11" - vcsRootId = "${DslContext.settingsRoot.id}" - labelingPattern = "%env.Version%" - successfulOnly = true - branchFilter = "" - } - commitStatusPublisher { - id = "BUILD_EXT_15" - enabled = false - vcsRootExtId = "${DslContext.settingsRoot.id}" - publisher = upsource { - serverUrl = "https://code-analysis.ldtteam.com" - projectId = "%Upsource.Project.Id%" - userName = "upsource" - password = "credentialsJSON:f19631a7-1bc1-4a66-88a0-dc2b9cd36734" - } - } - } - - dependencies { - snapshot(OfficialPublications_CommonB) { - reuseBuilds = ReuseBuilds.NO - onDependencyFailure = FailureAction.FAIL_TO_START - } - } -}) - -object Branches : Project({ - name = "Branches" - description = "All none release branches." - - buildType(Branches_Common) - buildType(Branches_Build) - - params { - text("Default.Branch", "version/%Current Minecraft Version%", label = "Default branch", description = "The default branch for branch builds", allowEmpty = true) - param("VCS.Branches", """ - +:refs/heads/(*) - -:refs/heads/version/* - -:refs/heads/release/* - -:refs/pull/*/head - -:refs/heads/CI/* - """.trimIndent()) - param("env.Version.Suffix", "-PERSONAL") - } - - cleanup { - baseRule { - all(days = 60) - } - } -}) - -object Branches_Build : BuildType({ - templates(AbsoluteId("LetSDevTogether_Build")) - name = "Build" - description = "Builds the branch without testing." - - params { - param("Project.Type", "mods") - param("env.Version.Patch", "${Branches_Common.depParamRefs.buildNumber}") - } - - triggers { - vcs { - id = "vcsTrigger" - } - } - - dependencies { - snapshot(Branches_Common) { - reuseBuilds = ReuseBuilds.NO - onDependencyFailure = FailureAction.FAIL_TO_START - } - } - - disableSettings("BUILD_EXT_14") -}) - -object Branches_Common : BuildType({ - templates(AbsoluteId("LetSDevTogether_CommonBuildCounter")) - name = "Common Build Counter" - description = "Tracks the amount of builds run for branches" -}) - - -object OfficialPublications : Project({ - name = "Official Publications" - description = "Holds projects and builds related to official publications" - - buildType(OfficialPublications_CommonB) -}) - -object OfficialPublications_CommonB : BuildType({ - templates(AbsoluteId("LetSDevTogether_CommonBuildCounter")) - name = "Common Build Counter" - description = "Represents the version counter within Structurize for official releases." -}) - - -object PullRequests_2 : Project({ - name = "Pull Requests" - description = "All open pull requests" - - buildType(PullRequests_2_BuildAndTest) - buildType(PullRequests_2_CommonBuildCounter) - - params { - text("Default.Branch", "version/%Current Minecraft Version%", label = "Default branch", description = "The default branch for pull requests.", allowEmpty = false) - param("VCS.Branches", """ - -:refs/heads/* - +:refs/pull/(*)/head - -:refs/heads/(CI/*) - """.trimIndent()) - param("env.Version", "%env.Version.Major%.%env.Version.Minor%.%build.counter%-PR") - } - - cleanup { - baseRule { - all(days = 60) - } - } -}) - -object PullRequests_2_BuildAndTest : BuildType({ - templates(AbsoluteId("LetSDevTogether_BuildWithTesting")) - name = "Build and Test" - description = "Builds and Tests the pull request." - - artifactRules = """ - +:build\libs\*.jar => build\libs - +:build\distributions\mods-*.zip => build\distributions - """.trimIndent() - - params { - param("env.Version.Patch", "${PullRequests_2_CommonBuildCounter.depParamRefs.buildNumber}") - param("env.Version.Suffix", "-PR") - } - - features { - feature { - id = "com.ldtteam.teamcity.github.commenting.GithubCommentingBuildFeature" - type = "com.ldtteam.teamcity.github.commenting.GithubCommentingBuildFeature" - param("privateKey", "-----") - param("appId", "154983") - param("branch", "%teamcity.build.branch%") - } - } - - dependencies { - snapshot(PullRequests_2_CommonBuildCounter) { - onDependencyFailure = FailureAction.FAIL_TO_START - } - } - - disableSettings("BUILD_EXT_15") -}) - -object PullRequests_2_CommonBuildCounter : BuildType({ - templates(AbsoluteId("LetSDevTogether_CommonBuildCounter")) - name = "Common Build Counter" - description = "Defines version numbers uniquely over all Pull Request builds" -}) - -object UpgradeBetaRelease : Project({ - name = "Upgrade Beta -> Release" - description = "Upgrades the current Beta to Release" - - buildType(UpgradeBetaRelease_UpgradeBetaRelease) -}) - -object UpgradeBetaRelease_UpgradeBetaRelease : BuildType({ - templates(AbsoluteId("LetSDevTogether_Upgrade")) - name = "Upgrade Beta -> Release" - description = "Upgrades the current Beta to Release." - - params { - param("Source.Branch", "version") - param("Default.Branch", "release/%Current Minecraft Version%") - param("VCS.Branches", "+:refs/heads/release/(*)") - param("Target.Branch", "release") - param("env.Version", "%env.Version.Major%.%env.Version.Minor%.%build.counter%-RELEASE") - } -})