diff --git a/.github/workflows/branches.yml b/.github/workflows/branches.yml index 875becc56..b6c124118 100644 --- a/.github/workflows/branches.yml +++ b/.github/workflows/branches.yml @@ -23,8 +23,7 @@ jobs: key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }} - name: Build with Gradle run: ./gradlew build - - name: Publish Snapshot - run: ./gradlew publish - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - if: github.ref == 'refs/heads/fabric/master' + - uses: actions/upload-artifact@v2 + with: + name: dist + path: build/libs/ diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index ec5c2f623..6710719af 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -10,12 +10,10 @@ jobs: runs-on: ubuntu-latest steps: - - name: Validate semver + - name: Export current tag as environment variable env: TAG: ${{ github.event.ref }} - run: | - echo $TAG | grep -oP '^fabric/v(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$' - echo "::set-env name=RELEASE::${TAG:1}" + run: echo "::set-env name=TAG::${TAG}" - uses: actions/checkout@v2 - name: Set up JDK 1.8 uses: actions/setup-java@v1 @@ -29,12 +27,17 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: ./gradlew generateData build + - name: Upload artifacts + uses: actions/upload-artifact@v2 + with: + name: dist + path: build/libs/ - name: Publish to github packages env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: ./gradlew publish + run: echo "./gradlew publish" - name: Upload to curseforge env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} CURSEFORGE: ${{ secrets.CURSEFORGE }} - run: ./gradlew curseforge + run: echo "./gradlew curseforge" diff --git a/build.gradle b/build.gradle index 7c1e4bc59..f1a5bbfb3 100644 --- a/build.gradle +++ b/build.gradle @@ -60,6 +60,29 @@ tasks.withType(JavaCompile) { options.encoding = 'UTF-8' } +// Create version number +ext.pr = System.getenv('PR_NUMBER') ?: "" +if (ext.pr) { + version = version + "+pr." + ext.pr +} + +ext.branch = System.getenv('BRANCH') ?: "" +if (ext.branch) { + version = version + "+branch." + ext.branch +} + +ext.tag = System.getenv('TAG') ?: "" +if (ext.tag && ext.tag.startsWith("fabric/v")) { + version = ext.tag.substring("fabric/v".length()) + // Validate that the rest is a semver version + if (version ==~ /^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$/) { + println("::set-env name=VERSION::${version}") + } else { + throw new GradleException("Invalid semver: $version") + } +} + +// Maven group and artifact name group = artifact_group archivesBaseName = artifact_basename @@ -151,17 +174,19 @@ processResources { apply from: 'gradle/scripts/artifacts.gradle' apply from: 'gradle/scripts/curseforge.gradle' -publishing { - publications { - mavenJava(MavenPublication) { - artifactId = 'appliedenergistics2-fabric' +if (!version.endsWith("-SNAPSHOT")) { + publishing { + publications { + mavenJava(MavenPublication) { + artifactId = 'appliedenergistics2-fabric' - // add all the jars that should be included when publishing to maven - artifact(remapJar) { - builtBy remapJar - } - artifact(sourcesJar) { - builtBy remapSourcesJar + // add all the jars that should be included when publishing to maven + artifact(remapJar) { + builtBy remapJar + } + artifact(sourcesJar) { + builtBy remapSourcesJar + } } } } diff --git a/gradle/scripts/curseforge.gradle b/gradle/scripts/curseforge.gradle index 462255591..d4b2283fd 100644 --- a/gradle/scripts/curseforge.gradle +++ b/gradle/scripts/curseforge.gradle @@ -26,7 +26,7 @@ if (isAlpha) { cfReleaseType = "beta" } -if (System.getenv("CURSEFORGE")) { +if (System.getenv("CURSEFORGE") && !version.endsWith("-SNAPSHOT")) { curseforge { apiKey = System.getenv("CURSEFORGE") project {