From 47e8d8478a1c4d57256e7507868c869015942bd7 Mon Sep 17 00:00:00 2001 From: Matyrobbrt Date: Sun, 21 Jan 2024 22:42:19 +0100 Subject: [PATCH] Setup CI --- .github/workflows/build-prs.yml | 23 +++++++++++++++++++++++ .github/workflows/build.yml | 29 ----------------------------- .github/workflows/publish-prs.yml | 29 +++++++++++++++++++++++++++++ .github/workflows/release.yml | 25 +++++++++++++++++++++++++ build.gradle.kts | 14 ++++++++------ 5 files changed, 85 insertions(+), 35 deletions(-) create mode 100644 .github/workflows/build-prs.yml delete mode 100644 .github/workflows/build.yml create mode 100644 .github/workflows/publish-prs.yml create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/build-prs.yml b/.github/workflows/build-prs.yml new file mode 100644 index 0000000..83ac74d --- /dev/null +++ b/.github/workflows/build-prs.yml @@ -0,0 +1,23 @@ +# File generated by the GradleUtils `setupGitHubActionsWorkflows` task, avoid modifying it directly +# The template can be found at https://github.com/neoforged/GradleUtils/blob/44d9e09cfa2c6032b84ac40495ea5ab7d64fe521/src/actionsTemplate/resources/.github/workflows/build-prs.yml + +name: Build and test PRs + +on: + pull_request: + types: + - synchronize + - opened + - ready_for_review + - reopened + push: + branches: + - 'feature/**' + workflow_dispatch: + +jobs: + build: + uses: neoforged/actions/.github/workflows/build-prs.yml@main + with: + java: 17 + gradle_tasks: build diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml deleted file mode 100644 index 4f7619c..0000000 --- a/.github/workflows/build.yml +++ /dev/null @@ -1,29 +0,0 @@ -name: Build -on: [push, pull_request, merge_group] -jobs: - build: - runs-on: ubuntu-22.04 - steps: - - uses: actions/checkout@v3 - with: - fetch-depth: 0 - - uses: actions/setup-java@v3 - with: - distribution: 'microsoft' - java-version: '17' - - uses: gradle/wrapper-validation-action@v1 - - name: Setup Gradle - uses: gradle/gradle-build-action@v2 - with: - gradle-home-cache-cleanup: true - gradle-home-cache-excludes: | - gradle.properties - - name: Setup gradle.properties - env: - GRADLE_PROPERTIES: ${{ vars.GRADLE_PROPERTIES }} - shell: bash - run: | - mkdir -p ~/.gradle/ - echo "GRADLE_USER_HOME=${HOME}/.gradle" >> $GITHUB_ENV - echo "${GRADLE_PROPERTIES}" > ~/.gradle/gradle.properties - - run: ./gradlew build --stacktrace diff --git a/.github/workflows/publish-prs.yml b/.github/workflows/publish-prs.yml new file mode 100644 index 0000000..7ea5f9f --- /dev/null +++ b/.github/workflows/publish-prs.yml @@ -0,0 +1,29 @@ +# File generated by the GradleUtils `setupGitHubActionsWorkflows` task, avoid modifying it directly +# The template can be found at https://github.com/neoforged/GradleUtils/blob/44d9e09cfa2c6032b84ac40495ea5ab7d64fe521/src/actionsTemplate/resources/.github/workflows/publish-prs.yml + +name: Publish PRs to GitHub Packages + +on: + workflow_run: + workflows: [Build and test PRs] + types: + - completed + issue_comment: + types: + - edited + pull_request_target: + types: + - opened + +permissions: + packages: write + +jobs: + publish-prs: + if: false # Option not enabled when the workflows were generated + uses: neoforged/actions/.github/workflows/publish-prs.yml@main + with: + artifact_base_path: dev/su5ed/sinytra/fabric-loader/ + secrets: + PR_PUBLISHING_GH_APP_ID: ${{ secrets.PR_PUBLISHING_GH_APP_ID }} + PR_PUBLISHING_GH_APP_KEY: ${{ secrets.PR_PUBLISHING_GH_APP_KEY }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..00c9367 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,25 @@ +# File generated by the GradleUtils `setupGitHubActionsWorkflows` task, avoid modifying it directly +# The template can be found at https://github.com/neoforged/GradleUtils/blob/44d9e09cfa2c6032b84ac40495ea5ab7d64fe521/src/actionsTemplate/resources/.github/workflows/release.yml + +name: Release + +on: + push: + branches: + - '1.*' + +permissions: + contents: read + statuses: write + +jobs: + release: + uses: neoforged/actions/.github/workflows/gradle-publish.yml@main + with: + java: 17 + pre_gradle_tasks: build + gradle_tasks: publish + secrets: + DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }} + MAVEN_USER: ${{ secrets.MAVEN_USERNAME }} + MAVEN_PASSWORD: ${{ secrets.MAVEN_PASSWORD }} diff --git a/build.gradle.kts b/build.gradle.kts index 742f457..2c8d886 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -17,9 +17,9 @@ import kotlin.io.path.writeText plugins { java `maven-publish` - id("me.qoomon.git-versioning") version "6.3.+" id("org.cadixdev.licenser") version "0.6.1" id("com.github.johnrengelman.shadow") version "8.1.1" + id("net.neoforged.gradleutils").version("3.0.0-alpha.10") // Used for mapping tools only, provides TSRG writer on top of mappings-io id("dev.architectury.loom") version "1.6-SNAPSHOT" apply false } @@ -32,12 +32,14 @@ val versionYarn: String by project group = "dev.su5ed.sinytra" version = "0.0.0-SNAPSHOT" -gitVersioning.apply { - rev { - version = - "\${describe.tag.version.major}.\${describe.tag.version.minor}.\${describe.tag.version.patch.plus.describe.distance}+$versionLoaderUpstream+$versionMc" +gradleutils.version { + branches { + suffixBranch() + suffixExemptedBranch("1.20.1") } } +version = "${gradleutils.version}+$versionLoaderUpstream+$versionMc" +println("Version: $version") license { header("HEADER") @@ -249,4 +251,4 @@ open class GenerateMergedMappingsTask : DefaultTask() { StandardOpenOption.TRUNCATE_EXISTING ) } -} \ No newline at end of file +}