From 4eb22b48fd92faa628db2aa87c8f5e4cba6bdb0e Mon Sep 17 00:00:00 2001 From: Sekwah Date: Tue, 19 Nov 2024 00:27:54 +0000 Subject: [PATCH] chore: switch to using env BREAKING CHANGE: This is a complete recode, features may be missing or different, if there are issues please open an issue on github or contact us about it on discord. --- .github/workflows/release-please.yml | 2 ++ .github/workflows/snapshots.yml | 2 +- build.gradle | 15 +++++++++++++++ discord.gradle | 5 ----- 4 files changed, 18 insertions(+), 6 deletions(-) diff --git a/.github/workflows/release-please.yml b/.github/workflows/release-please.yml index 2a570d28..5daa4bcf 100644 --- a/.github/workflows/release-please.yml +++ b/.github/workflows/release-please.yml @@ -7,6 +7,7 @@ name: release-please jobs: release-please: runs-on: ubuntu-latest + environment: release outputs: release_created: ${{ steps.release.outputs.release_created }} upload_url: ${{ steps.release.outputs.upload_url }} @@ -28,6 +29,7 @@ jobs: release-task: [curseforge, discordupload, modrinth] needs: release-please runs-on: ubuntu-latest + environment: release if: ${{ needs.release-please.outputs.release_created }} steps: - uses: actions/checkout@v3 diff --git a/.github/workflows/snapshots.yml b/.github/workflows/snapshots.yml index c2530da4..7356f981 100644 --- a/.github/workflows/snapshots.yml +++ b/.github/workflows/snapshots.yml @@ -34,4 +34,4 @@ jobs: DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }} run: | # Build - ./gradlew build + ./gradlew build discordupload diff --git a/build.gradle b/build.gradle index e9ccd177..702de139 100644 --- a/build.gradle +++ b/build.gradle @@ -51,6 +51,18 @@ allprojects { apply from: 'env-variables.gradle' +def branch = System.getenv("GITHUB_REF") +def snapshotName = null; +if(branch != null) { + branch = branch.replace('refs/heads/', '') +} + +def isRelease = System.getenv("IS_RELEASE") == "true" + +def githubSha = System.getenv("GITHUB_SHA") +def shaRef = githubSha != null ? "-${githubSha.substring(0, 8)}" : "" +snapshotName = (branch == null || branch.startsWith("release-please")) ? "SNAPSHOT" : branch + archivesBaseName = "Advanced-Portals" group = 'com.sekwah.advancedportals' def versionString = (file('./version.txt').text + (isRelease ? "" : "-${snapshotName}${shaRef}")).replaceAll('\n', '').replaceAll('\r', '') @@ -184,3 +196,6 @@ idea { } } } + +apply from: 'curse.gradle' +apply from: 'discord.gradle' diff --git a/discord.gradle b/discord.gradle index 093ff84b..0aeb03ca 100644 --- a/discord.gradle +++ b/discord.gradle @@ -17,11 +17,6 @@ buildscript { apply from: 'env-variables.gradle' -/** For pre-releases and testers to be able to try the latest commits if they want. - * If the builds start exceeding 8MB then we may want to upload to s3 instead and periodically clear. - * TODO possibly add a task that announces when builds are made? - * Though add a note that it may take a while for Curse to approve the files. - */ task discordupload { dependsOn(jar) doLast {