From 9a8b313d8d61f9011027ef1e2d58c53bc4afe186 Mon Sep 17 00:00:00 2001 From: Matyrobbrt Date: Mon, 30 Oct 2023 16:09:04 +0200 Subject: [PATCH] Move to actions --- .github/workflows/build-prs.yml | 30 +++++++++ .github/workflows/publish.yml | 16 ----- .github/workflows/release.yml | 25 ++++++++ .teamcity/pom.xml | 104 -------------------------------- .teamcity/settings.kts | 71 ---------------------- Jenkinsfile | 93 ---------------------------- build.gradle | 16 ++++- 7 files changed, 69 insertions(+), 286 deletions(-) create mode 100644 .github/workflows/build-prs.yml delete mode 100644 .github/workflows/publish.yml create mode 100644 .github/workflows/release.yml delete mode 100644 .teamcity/pom.xml delete mode 100644 .teamcity/settings.kts delete mode 100644 Jenkinsfile diff --git a/.github/workflows/build-prs.yml b/.github/workflows/build-prs.yml new file mode 100644 index 0000000..764689e --- /dev/null +++ b/.github/workflows/build-prs.yml @@ -0,0 +1,30 @@ +name: Build and test PRs + +on: + pull_request: + types: + - synchronize + - opened + - ready_for_review + - reopened + +jobs: + build: + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v4 + with: + fetch-depth: 1000 + fetch-tags: true + + - name: Setup JDK 8 + uses: actions/setup-java@v2 + with: + java-version: '8' + distribution: 'temurin' + + - name: Build with Gradle + uses: gradle/gradle-build-action@v2 + with: + arguments: build \ No newline at end of file diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml deleted file mode 100644 index 6fa3f1d..0000000 --- a/.github/workflows/publish.yml +++ /dev/null @@ -1,16 +0,0 @@ -name: Publish - -on: - push: - branches: [ "master" ] - -permissions: - contents: read - -jobs: - build: - uses: MinecraftForge/SharedActions/.github/workflows/gradle.yml@main - with: - java: 8 - gradle_tasks: "publish" - artifact_name: "mergetool" diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..e4590ec --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,25 @@ +name: Release + +on: + push: + branches: [ "main" ] + +permissions: + contents: read + statuses: write + +jobs: + build: + uses: neoforged/actions/.github/workflows/gradle-publish.yml@main + with: + java: 8 + pre_gradle_tasks: 'licenseFormat build' + gradle_tasks: 'publish' + secrets: + DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }} + + MAVEN_USER: ${{ secrets.MAVEN_USER }} + MAVEN_PASSWORD: ${{ secrets.MAVEN_PASSWORD }} + + GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }} + GPG_KEY_PASSWORD: ${{ secrets.GPG_KEY_PASSWORD }} \ No newline at end of file diff --git a/.teamcity/pom.xml b/.teamcity/pom.xml deleted file mode 100644 index 6fac53d..0000000 --- a/.teamcity/pom.xml +++ /dev/null @@ -1,104 +0,0 @@ - - - 4.0.0 - MinecraftForge_neoforged_MergeTool Config DSL Script - MinecraftForge_neoforged_MergeTool - MinecraftForge_neoforged_MergeTool_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://teamcity.neoforged.net/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 9433c35..0000000 --- a/.teamcity/settings.kts +++ /dev/null @@ -1,71 +0,0 @@ -import jetbrains.buildServer.configs.kotlin.v2019_2.* -import jetbrains.buildServer.configs.kotlin.v2019_2.projectFeatures.githubIssues - -/* -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 { - - buildType(Build) - buildType(BuildSecondaryBranches) - buildType(PullRequests) - - params { - text("git_main_branch", "main", label = "Git Main Branch", description = "The git main or default branch to use in VCS operations.", display = ParameterDisplay.HIDDEN, allowEmpty = false) - text("github_repository_name", "MergeTool", label = "The github repository name. Used to connect to it in VCS Roots.", description = "This is the repository slug on github. So for example `MergeTool` or `MinecraftForge`. It is interpolated into the global VCS Roots.", display = ParameterDisplay.HIDDEN, allowEmpty = false) - text("env.PUBLISHED_JAVA_ARTIFACT_ID", "mergetool", label = "Published artifact id", description = "The maven coordinate artifact id that has been published by this build. Can not be empty.", allowEmpty = false) - text("env.PUBLISHED_JAVA_GROUP", "net.neoforged", label = "Published group", description = "The maven coordinate group that has been published by this build. Can not be empty.", allowEmpty = false) - text("docker_jdk_version", "8", label = "JDK version", description = "The version of the JDK to use during execution of tasks in a JDK.", display = ParameterDisplay.HIDDEN, allowEmpty = false) - text("docker_gradle_version", "8.4", label = "Gradle version", description = "The version of Gradle to use during execution of Gradle tasks.", display = ParameterDisplay.HIDDEN, allowEmpty = false) - } - - features { - githubIssues { - id = "MergeTool__IssueTracker" - displayName = "neoforged/MergeTool" - repositoryURL = "https://github.com/neoforged/MergeTool" - } - } -} - -object Build : BuildType({ - templates(AbsoluteId("MinecraftForge_SetupGradleUtilsCiEnvironmen"), AbsoluteId("MinecraftForge_BuildWithDiscordNotifications"), AbsoluteId("MinecraftForge_BuildMainBranches"), AbsoluteId("MinecraftForge_BuildUsingGradle"), AbsoluteId("MinecraftForge_PublishProjectUsingGradle"), AbsoluteId("MinecraftForge_TriggersStaticFilesWebpageGenerator")) - id("MergeTool__Build") - name = "Build" - description = "Builds and Publishes the main branches of the project." -}) - -object BuildSecondaryBranches : BuildType({ - templates(AbsoluteId("MinecraftForge_ExcludesBuildingDefaultBranch"), AbsoluteId("MinecraftForge_SetupGradleUtilsCiEnvironmen"), AbsoluteId("MinecraftForge_BuildWithDiscordNotifications"), AbsoluteId("MinecraftForge_BuildMainBranches"), AbsoluteId("MinecraftForge_BuildUsingGradle")) - id("MergeTool__BuildSecondaryBranches") - name = "Build - Secondary Branches" - description = "Builds and Publishes the secondary branches of the project." -}) - -object PullRequests : BuildType({ - templates(AbsoluteId("MinecraftForge_BuildPullRequests"), AbsoluteId("MinecraftForge_SetupGradleUtilsCiEnvironmen"), AbsoluteId("MinecraftForge_BuildWithDiscordNotifications"), AbsoluteId("MinecraftForge_BuildUsingGradle")) - id("MergeTool__PullRequests") - name = "Pull Requests" - description = "Builds pull requests for the project" -}) diff --git a/Jenkinsfile b/Jenkinsfile deleted file mode 100644 index 33765da..0000000 --- a/Jenkinsfile +++ /dev/null @@ -1,93 +0,0 @@ -@Library('forge-shared-library')_ - -pipeline { - agent { - docker { - image 'gradle:jdk8' - args '-v gradlecache:/gradlecache' - } - } - environment { - GRADLE_ARGS = '-Dorg.gradle.daemon.idletimeout=5000' - DISCORD_WEBHOOK = credentials('forge-discord-jenkins-webhook') - DISCORD_PREFIX = "Job: MergeTool Branch: ${BRANCH_NAME} Build: #${BUILD_NUMBER}" - JENKINS_HEAD = 'https://wiki.jenkins-ci.org/download/attachments/2916393/headshot.png' - } - - stages { - stage('fetch') { - steps { - checkout scm - } - } - stage('notify_start') { - when { - not { - changeRequest() - } - } - steps { - discordSend( - title: "${DISCORD_PREFIX} Started", - successful: true, - result: 'ABORTED', //White border - thumbnail: JENKINS_HEAD, - webhookURL: DISCORD_WEBHOOK - ) - } - } - stage('buildandtest') { - steps { - withGradle { - sh './gradlew ${GRADLE_ARGS} --refresh-dependencies --continue build test' - } - script { - env.MYGROUP = sh(returnStdout: true, script: './gradlew properties -q | grep "group:" | awk \'{print $2}\'').trim() - env.MYARTIFACT = sh(returnStdout: true, script: './gradlew properties -q | grep "name:" | awk \'{print $2}\'').trim() - env.MYVERSION = sh(returnStdout: true, script: './gradlew properties -q | grep "version:" | awk \'{print $2}\'').trim() - } - } - post { - success { - writeChangelog(currentBuild, 'build/changelog.txt') - archiveArtifacts artifacts: 'build/changelog.txt', fingerprint: false - } - } - } - stage('publish') { - when { - not { - changeRequest() - } - } - steps { - withCredentials([usernamePassword(credentialsId: 'maven-forge-user', usernameVariable: 'MAVEN_USER', passwordVariable: 'MAVEN_PASSWORD')]) { - withGradle { - sh './gradlew ${GRADLE_ARGS} publish' - } - } - } - post { - success { - build job: 'filegenerator', parameters: [string(name: 'COMMAND', value: "promote ${env.MYGROUP}:${env.MYARTIFACT} ${env.MYVERSION} latest")], propagate: false, wait: false - } - } - } - } - post { - always { - script { - if (env.CHANGE_ID == null) { // This is unset for non-PRs - discordSend( - title: "${DISCORD_PREFIX} Finished ${currentBuild.currentResult}", - description: '```\n' + getChanges(currentBuild) + '\n```', - successful: currentBuild.resultIsBetterOrEqualTo("SUCCESS"), - result: currentBuild.currentResult, - thumbnail: JENKINS_HEAD, - webhookURL: DISCORD_WEBHOOK - ) - } - } - } - } -} diff --git a/build.gradle b/build.gradle index 7a07bc2..851131c 100644 --- a/build.gradle +++ b/build.gradle @@ -8,6 +8,7 @@ plugins { id 'com.github.johnrengelman.shadow' version '8.1.1' id 'com.github.ben-manes.versions' version '0.47.0' id 'net.neoforged.gradleutils' version '2.+' + id 'signing' } group = 'net.neoforged' @@ -128,8 +129,10 @@ publishing { developers { developer { - id = 'LexManos' - name = 'Lex Manos' + id = 'neoforged' + name = 'NeoForged' + email = 'contact@neoforged.net' + url = 'https://github.com/NeoForged/' } } } @@ -139,6 +142,15 @@ publishing { } } +if (System.getenv('GPG_PRIVATE_KEY')) { + signing { + final signingKey = System.getenv('GPG_PRIVATE_KEY') ?: '' + final signingPassword = System.getenv('GPG_KEY_PASSWORD') ?: '' + useInMemoryPgpKeys(signingKey, signingPassword) + sign publishing.publications.mavenJava + } +} + changelog { fromTag '2.0' }