Fix for workflow (3) #4
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: Set execute permissions for Gradle wrapper | |
run: chmod +x ./gradlew | |
- name: Set TAG_NAME and JAR_NAME environment variable | |
run: | | |
echo "TAG_NAME=${GITHUB_REF#refs/tags/release_}" >> $GITHUB_ENV | |
echo "JAR_NAME=c3pu-$TAG_NAME.jar" >> $GITHUB_ENV | |
env: | |
GITHUB_REF: ${{ github.ref }} | |
- name: Build with Gradle | |
run: ./gradlew build | |
- name: Rename JAR File | |
run: mv build/libs/c3pu-*.jar build/libs/${{ env.JAR_NAME }} | |
- 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/${{ env.JAR_NAME }} | |
asset_name: ${{ env.JAR_NAME }} | |
asset_content_type: application/java-archive |