Build and Release #26
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
name: Build and Release | |
on: | |
workflow_dispatch | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout Git Repository | |
uses: actions/checkout@v2 | |
- name: Validate Gradle wrapper | |
uses: gradle/wrapper-validation-action@v1 | |
- name: Cache Gradle | |
uses: actions/cache@v2 | |
with: | |
path: | | |
~/.gradle/caches | |
~/.gradle/wrapper | |
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties', '**/gradle.properties') }} | |
restore-keys: | | |
${{ runner.os }}-gradle- | |
- name: Set up JDK | |
uses: actions/[email protected] | |
with: | |
distribution: 'temurin' | |
java-version: '17' | |
- name: Configure Git User Details | |
run: git config --global user.email "[email protected]" && git config --global user.name "Github Actions" | |
- name: Give Permissions | |
run: chmod u+x ./gradlew | |
- name: Build | |
run: ./gradlew build --stacktrace | |
- name: Set outputs | |
id: vars1 | |
run: | |
echo "::set-output name=sha_short::$(git rev-parse --short HEAD)" | |
- name: Get Latest Tag | |
id: vars2 | |
uses: oprypin/find-latest-tag@v1 | |
with: | |
repository: ProjectEdenGG/Titan | |
releases-only: true | |
- name: Delete previous tag/release | |
id: delete-release | |
uses: dev-drprasad/[email protected] | |
with: | |
delete_release: true | |
tag_name: ${{ steps.vars2.outputs.tag }} | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Create Release | |
id: create-new-release | |
uses: actions/create-release@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
tag_name: ${{ steps.vars1.outputs.sha_short }} | |
release_name: Titan ${{ steps.vars1.outputs.sha_short }} | |
- name: Upload Release Assets | |
uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ steps.create-new-release.outputs.upload_url }} | |
asset_path: ./build/libs/titan.jar | |
asset_name: titan.jar | |
asset_content_type: jar |