Skip to content

Update gradle.yml

Update gradle.yml #27

Workflow file for this run

# This workflow will build a Java project with Gradle
# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-gradle
name: Java CI with Gradle
on:
push:
branches:
- main
- early-adopter
pull_request:
branches:
- main
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up JDK 19
uses: actions/setup-java@v3
with:
distribution: 'oracle'
java-version: '19'
cache: 'gradle'
- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: Build with Gradle
run: ./gradlew build
- name: Creating the jar file
run: ./gradlew jar
- name: Upload artifact
uses: actions/upload-artifact@v3
with:
path: ./releases/*.jar
name: Downloadable Extension File
- name: Get previous tag for the branch
id: get_previous_tag
run: |
if [[ "${{ github.ref }}" == "refs/heads/main" ]]; then
PREFIX="main_"
else
PREFIX="early_adopter_"
fi
PREVIOUS_TAG=$(curl -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
https://api.github.com/repos/${{ github.repository }}/git/refs/tags \
| jq -r ".[] | select(.ref | startswith(\"refs/tags/${PREFIX}\")) | .ref" \
| sort -V | tail -n 1 | sed "s|refs/tags/||")
# Check if we found a tag
if [[ -z "$PREVIOUS_TAG" ]]; then
echo "No previous tag found for prefix ${PREFIX}."
echo "PREVIOUS_TAG=" >> $GITHUB_ENV
else
echo "PREVIOUS_TAG=$PREVIOUS_TAG" >> $GITHUB_ENV
fi
- name: Delete the previous tag
if: env.PREVIOUS_TAG != ''
run: |
curl -X DELETE \
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
"https://api.github.com/repos/${{ github.repository }}/git/refs/tags/${{ env.PREVIOUS_TAG }}"
- name: Extract version
id: get_version
run: |
VERSION=$(grep "^version=" src/main/resources/extension.properties | awk -F'=' '{print $2}')
echo "VERSION=$VERSION" >> $GITHUB_ENV
- name: Set release tag based on branch
id: vars
run: |
if [[ "${{ github.ref }}" == "refs/heads/main" ]]; then
echo "RELEASE_TAG=main_${VERSION}_by_github" >> $GITHUB_ENV
else
echo "RELEASE_TAG=early_adopter_${VERSION}_by_github" >> $GITHUB_ENV
fi
- name: Release
uses: irsdl/[email protected]
with:
tag: ${{ env.RELEASE_TAG }}
body: "This jar file has been built by GitHub automatically.\nYou can view the latest version number in the [extension.properties](../../blob/main/src/main/resources/extension.properties) file."
allowUpdates: true
artifacts: "releases/*.jar"
draft: false