diff --git a/.github/workflows/publish-release.yml b/.github/workflows/publish-release.yml new file mode 100644 index 00000000..7245011f --- /dev/null +++ b/.github/workflows/publish-release.yml @@ -0,0 +1,38 @@ +name: Publish release + +on: + release: + types: [published] + +jobs: + publish-release: + runs-on: ubuntu-latest + + steps: + - name: Checkout latest code + uses: actions/checkout@v2 + + - name: Set up JDK 16 + uses: actions/setup-java@v2 + with: + distribution: 'adopt' + java-version: 16 + + - name: Setup build cache + uses: actions/cache@v2.1.6 + with: + path: ~/.gradle/caches + key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle.kts') }} + restore-keys: | + ${{ runner.os }}-gradle- + - name: Publish artifact + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + # The GITHUB_REF tag comes in the format 'refs/tags/xxx'. + # So if we split on '/' and take the 3rd value, we can get the release name. + run: | + NEW_VERSION=$(echo "${GITHUB_REF}" | cut -d "/" -f3) + echo "New version: ${NEW_VERSION}" + echo "Github username: ${GITHUB_ACTOR}" + ./gradlew -Pversion=${NEW_VERSION} publish \ No newline at end of file diff --git a/eco-api/build.gradle b/eco-api/build.gradle index f6107fec..51466aed 100644 --- a/eco-api/build.gradle +++ b/eco-api/build.gradle @@ -25,4 +25,15 @@ publishing { artifactId 'eco' } } + + repositories { + maven { + name = "GitHubPackages" + url = uri("https://maven.pkg.github.com/Auxilor/eco") + credentials { + username = System.getenv("GITHUB_ACTOR") + password = System.getenv("GITHUB_TOKEN") + } + } + } } \ No newline at end of file