Skip to content

Commit 790b21a

Browse files
authored
Create main.yml
1 parent 505b796 commit 790b21a

1 file changed

Lines changed: 55 additions & 0 deletions

File tree

.github/workflows/main.yml

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
name: Java CI with Maven
2+
3+
on:
4+
push:
5+
branches: ["main"]
6+
7+
permissions:
8+
contents: write
9+
10+
jobs:
11+
build:
12+
runs-on: ubuntu-latest
13+
14+
steps:
15+
- name: Checkout repository
16+
uses: actions/checkout@v4
17+
18+
- name: Set up JDK 24
19+
uses: actions/setup-java@v4
20+
with:
21+
java-version: "24"
22+
distribution: temurin
23+
cache: maven
24+
25+
- name: Build with Maven
26+
run: mvn -B package --file pom.xml
27+
28+
- name: Locate Jar File
29+
id: locate_jar
30+
run: |
31+
# Find the jar file in the target directory
32+
jar_path=$(find target -maxdepth 1 -type f -name '*.jar')
33+
echo "Jar file found: ${jar_path}"
34+
echo "JAR_PATH=${jar_path}" >> $GITHUB_ENV
35+
36+
- name: Create GitHub Release
37+
id: create_release
38+
uses: actions/create-release@v1
39+
env:
40+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
41+
with:
42+
tag_name: release-${{ github.sha }}
43+
release_name: Release ${{ github.sha }}
44+
draft: false
45+
prerelease: false
46+
47+
- name: Upload Release Asset
48+
uses: actions/upload-release-asset@v1
49+
env:
50+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
51+
with:
52+
upload_url: ${{ steps.create_release.outputs.upload_url }}
53+
asset_path: ${{ env.JAR_PATH }}
54+
asset_name: template.jar
55+
asset_content_type: application/java-archive

0 commit comments

Comments
 (0)