Skip to content

gradle-publish

gradle-publish #65

# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.
# This workflow will build a package using Gradle and then publish it to GitHub packages when a release is created
# For more information see: https://github.com/actions/setup-java/blob/main/docs/advanced-usage.md#Publishing-using-gradle
name: Gradle Package
on:
push:
tags:
- 'v[0-9]+.[0-9]+.[0-9]+'
repository_dispatch:
types:
- gradle-publish
jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout@v3
- name: Set up JDK 17
uses: actions/setup-java@v2
with:
java-version: '17'
distribution: 'temurin'
- name: Restore gradle.properties
env:
GITHUB_USER: arhacc
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
shell: bash
run: |
echo "github_maven_user=${GITHUB_USER}" > gradle.properties
echo "github_maven_password=${GITHUB_TOKEN}" >> gradle.properties
- name: Create Tag
run : |
git remote update
git pull
./gradlew release
last_tag_pushed=$(git ls-remote --tags origin | awk -F/ '{print $3}' | sort -V | tail -n1)
last_tag_valid=$(echo "$last_tag_pushed" | sed 's/[^0-9]*$//')
echo "LAST_TAG_PUSHED=$last_tag_valid" >> $GITHUB_ENV
- name: Publish to GitHub Packages
uses: gradle/gradle-build-action@67421db6bd0bf253fb4bd25b31ebb98943c375e1
with:
arguments: "publish -Pversion=$LAST_TAG_PUSHED"