From 276ef87e37ef50bb5b15d75f6df783ade01ada0c Mon Sep 17 00:00:00 2001 From: wtlgo Date: Mon, 25 Jul 2022 09:51:47 +0300 Subject: [PATCH] Add CI versioning --- .github/workflows/build.yaml | 23 +++++++++++++---------- .github/workflows/release.yaml | 4 ++-- build.gradle | 18 +++++++++++++++--- 3 files changed, 30 insertions(+), 15 deletions(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 0f55a68..1dd4bfa 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -1,6 +1,6 @@ name: Java CI -on: [push] +on: [ push ] jobs: build: @@ -13,24 +13,27 @@ jobs: java-version: '17' distribution: 'adopt' + - name: Get Commit Data + id: commit + uses: pr-mpt/actions-commit-hash@v1 + - name: Validate Gradle wrapper uses: gradle/wrapper-validation-action@v1 - - name: Change wrapper permissions + - name: Change Wrapper Permissions run: chmod +x ./gradlew - - name: Setup Gradle + - name: Gradle Build uses: gradle/gradle-build-action@v2 - - - name: Execute Gradle Shaded Build - run: ./gradlew shadowJar - - - id: commit - uses: pr-mpt/actions-commit-hash@v1 + with: + arguments: shadowJar --scan + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + VERSION: dev-${{ steps.commit.outputs.short }} - uses: actions/upload-artifact@v3 with: - name: MikChanNoChat-${{ steps.commit.outputs.short }}.zip + name: MikChanNoChat-dev-${{ steps.commit.outputs.short }}.zip path: | build/libs/ LICENSE.txt diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index b60b824..a8bd603 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -39,9 +39,9 @@ jobs: publish: runs-on: ubuntu-latest - permissions: + permissions: contents: read - packages: write + packages: write steps: - uses: actions/checkout@v3 diff --git a/build.gradle b/build.gradle index 1e045d7..1915202 100644 --- a/build.gradle +++ b/build.gradle @@ -6,8 +6,20 @@ plugins { id "com.github.johnrengelman.shadow" version "7.1.2" } +if (hasProperty('buildScan')) { + buildScan { + termsOfServiceUrl = 'https://gradle.com/terms-of-service' + termsOfServiceAgree = 'yes' + } +} + +static def determineVersion(String defaultVersion) { + def envVersion = System.getenv("VERSION") + return envVersion == null ? defaultVersion : envVersion +} + group = 'dev.mikchan.mcnp' -version = '1.0.4' +version = determineVersion('1.0.4') repositories { mavenCentral() @@ -18,8 +30,8 @@ repositories { } maven { - name 'placeholderapi' - url 'https://repo.extendedclip.com/content/repositories/placeholderapi/' + name = 'placeholderapi' + url = 'https://repo.extendedclip.com/content/repositories/placeholderapi/' } }