forked from GrimAnticheat/Grim
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create gradle.yml to autobuild when change made to 2.0
- Loading branch information
Showing
1 changed file
with
102 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
# 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 Java project with Gradle and cache/restore any dependencies to improve the workflow execution time | ||
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-java-with-gradle | ||
|
||
name: Java CI with Gradle | ||
|
||
on: | ||
push: | ||
branches: [ "2.0" ] | ||
pull_request: | ||
branches: [ "2.0" ] | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: write | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Set up JDK 21 | ||
uses: actions/setup-java@v4 | ||
with: | ||
java-version: '21' | ||
distribution: 'temurin' | ||
|
||
# Configure Gradle for optimal use in GitHub Actions, including caching of downloaded dependencies. | ||
# See: https://github.com/gradle/actions/blob/main/setup-gradle/README.md | ||
- name: Setup Gradle | ||
uses: gradle/actions/setup-gradle@dbbdc275be76ac10734476cc723d82dfe7ec6eda | ||
|
||
- name: Build with Gradle Wrapper | ||
run: ./gradlew build | ||
|
||
- name: Get current datetime | ||
id: datetime | ||
run: echo "datetime=$(date +'%Y-%m-%d-%H%M%S')" >> $GITHUB_OUTPUT | ||
|
||
- name: Delete previous dev release | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
run: | | ||
previous_release_id=$(curl -s -H "Authorization: token $GITHUB_TOKEN" \ | ||
"https://api.github.com/repos/${{ github.repository }}/releases/tags/dev" | jq -r .id) | ||
if [ "$previous_release_id" != "null" ]; then | ||
curl -X DELETE -H "Authorization: token $GITHUB_TOKEN" \ | ||
"https://api.github.com/repos/${{ github.repository }}/releases/$previous_release_id" | ||
git push --delete origin dev || true | ||
fi | ||
- name: Create new dev release | ||
id: create_release | ||
uses: actions/create-release@v1 | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
with: | ||
tag_name: dev | ||
release_name: Dev Build ${{ steps.datetime.outputs.datetime }} | ||
body: | | ||
This is an automated dev build of the master branch. | ||
Build date: ${{ steps.datetime.outputs.datetime }} | ||
draft: false | ||
prerelease: true | ||
|
||
- name: Find JAR file | ||
id: find_jar | ||
run: | | ||
JAR_PATH=$(find ./build/libs -name "*-all.jar" | head -n 1) | ||
echo "jar_path=$JAR_PATH" >> $GITHUB_OUTPUT | ||
echo "jar_name=$(basename $JAR_PATH)" >> $GITHUB_OUTPUT | ||
- name: Upload artifact | ||
uses: actions/upload-release-asset@v1 | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
with: | ||
upload_url: ${{ steps.create_release.outputs.upload_url }} | ||
asset_path: ${{ steps.find_jar.outputs.jar_path }} | ||
asset_name: TGM-${{ steps.datetime.outputs.datetime }}-dev-build.jar | ||
asset_content_type: application/java-archive | ||
|
||
dependency-submission: | ||
|
||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: write | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Set up JDK 21 | ||
uses: actions/setup-java@v4 | ||
with: | ||
java-version: '21' | ||
distribution: 'temurin' | ||
|
||
# Generates and submits a dependency graph, enabling Dependabot Alerts for all project dependencies. | ||
# See: https://github.com/gradle/actions/blob/main/dependency-submission/README.md | ||
- name: Generate and submit dependency graph | ||
uses: gradle/actions/dependency-submission@dbbdc275be76ac10734476cc723d82dfe7ec6eda |