Added git workflow for automatic release process. #1
Workflow file for this run
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 Java Application | |
on: | |
push: | |
tags: | |
- "release_*" # Trigger on tags with prefix release_ | |
jobs: | |
build_and_release: | |
runs-on: ubuntu-latest # Specifies the runner environment | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 # Checks out the repository code under $GITHUB_WORKSPACE | |
- name: Set up JDK 17 | |
uses: actions/setup-java@v3 | |
with: | |
java-version: "17" | |
distribution: "temurin" # AdoptOpenJDK builds from Eclipse Foundation | |
- name: Build with Gradle | |
run: ./gradlew build | |
- name: Rename JAR File | |
run: | | |
TAG_NAME=${GITHUB_REF#refs/tags/release_} | |
JAR_NAME=c3pu-$TAG_NAME.jar | |
mv build/libs/c3pu-*.jar build/libs/$JAR_NAME | |
env: | |
GITHUB_REF: ${{ github.ref }} | |
- name: Create Release | |
id: create_release | |
uses: actions/create-release@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
tag_name: ${{ github.ref }} | |
release_name: Release ${{ env.TAG_NAME }} | |
draft: false | |
prerelease: false | |
- name: Upload Release Asset | |
uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ steps.create_release.outputs.upload_url }} | |
asset_path: ./build/libs/$JAR_NAME | |
asset_name: $JAR_NAME | |
asset_content_type: application/java-archive |