Build and Release #23
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: Java CI with Gradle | |
on: | |
# push: | |
# branches: [ "main" ] | |
# pull_request: | |
# branches: [ "main" ] | |
workflow_dispatch: | |
inputs: | |
release_description: | |
description: "Description for the release" | |
required: true | |
default: "No description provided." | |
release_version: | |
description: "Version" | |
required: true | |
default: "<No version provided.>" | |
jobs: | |
# build: | |
# runs-on: ubuntu-latest | |
# permissions: | |
# contents: read | |
# | |
# steps: | |
# - uses: actions/checkout@v4 | |
# - name: Set up JDK 17 | |
# uses: actions/setup-java@v4 | |
# with: | |
# java-version: '17' | |
# distribution: 'temurin' | |
# | |
# - name: Setup Gradle | |
# uses: gradle/actions/setup-gradle@af1da67850ed9a4cedd57bfd976089dd991e2582 # v4.0.0 | |
# | |
# - name: Build with Gradle Wrapper | |
# run: chmod +x gradlew && ./gradlew build | |
# | |
# - name: Upload Build Artifact | |
# uses: actions/upload-artifact@v3 | |
# with: | |
# name: gradle-output | |
# path: build/libs/ | |
# | |
# dependency-submission: | |
# runs-on: ubuntu-latest | |
# permissions: | |
# contents: write | |
# | |
# steps: | |
# - uses: actions/checkout@v4 | |
# - name: Set up JDK 17 | |
# uses: actions/setup-java@v4 | |
# with: | |
# java-version: '17' | |
# distribution: 'temurin' | |
# | |
# - name: Generate and submit dependency graph | |
# uses: gradle/actions/dependency-submission@af1da67850ed9a4cedd57bfd976089dd991e2582 # v4.0.0 | |
publish-artifact: | |
if: github.event_name == 'workflow_dispatch' | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up JDK 17 | |
uses: actions/setup-java@v4 | |
with: | |
java-version: '17' | |
distribution: 'temurin' | |
- name: Setup Gradle | |
uses: gradle/actions/setup-gradle@af1da67850ed9a4cedd57bfd976089dd991e2582 | |
- name: Build with Gradle Wrapper | |
run: chmod +x gradlew && ./gradlew build | |
- name: Upload Build Artifact | |
uses: actions/upload-artifact@v3 | |
with: | |
name: gradle-output | |
path: build/libs/ | |
- name: Create GitHub Release | |
id: create_release | |
uses: actions/create-release@v1 | |
with: | |
tag_name: manual-release-${{ github.run_id }} | |
release_name: "Release v${{ github.event.inputs.release_version }}" | |
body: ${{ github.event.inputs.release_description }} | |
draft: false | |
prerelease: false | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
# - name: Debug Upload URL | |
# run: | | |
# echo "Upload URL: ${{ steps.create_release.outputs.upload_url }}" | |
- name: Upload All JAR Files | |
run: | | |
for file in build/libs/*.jar; do | |
echo "Uploading $file" | |
curl \ | |
-X POST \ | |
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \ | |
-H "Content-Type: application/java-archive" \ | |
--data-binary @"$file" \ | |
"${{ steps.create_release.outputs.upload_url }}?name=$(basename $file)" | |
done |