Skip to content

Commit 3dfb671

Browse files
committed
add GitHub Actions workflow for build and release process
1 parent 36c7123 commit 3dfb671

1 file changed

Lines changed: 76 additions & 0 deletions

File tree

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
name: Build and Release
2+
3+
on:
4+
push:
5+
tags:
6+
- "v*"
7+
workflow_dispatch:
8+
inputs:
9+
version:
10+
description: "Release version (e.g., v1.0.0)"
11+
required: true
12+
default: "v1.0.0"
13+
14+
jobs:
15+
build:
16+
runs-on: ubuntu-latest
17+
18+
steps:
19+
- name: Checkout code
20+
uses: actions/checkout@v4
21+
22+
- name: Set up JDK 22
23+
uses: actions/setup-java@v4
24+
with:
25+
java-version: "22"
26+
distribution: "temurin"
27+
28+
- name: Cache Maven dependencies
29+
uses: actions/cache@v4
30+
with:
31+
path: ~/.m2
32+
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
33+
restore-keys: ${{ runner.os }}-m2
34+
35+
- name: Build with Maven
36+
run: mvn clean package
37+
38+
- name: Get version from pom.xml
39+
id: get_version
40+
run: |
41+
VERSION=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)
42+
echo "version=$VERSION" >> $GITHUB_OUTPUT
43+
echo "jar_name=lukittu-simple-$VERSION.jar" >> $GITHUB_OUTPUT
44+
45+
- name: Create Release
46+
id: create_release
47+
uses: actions/create-release@v1
48+
env:
49+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
50+
with:
51+
tag_name: ${{ github.event.inputs.version || github.ref_name }}
52+
release_name: Release ${{ github.event.inputs.version || github.ref_name }}
53+
body: |
54+
## Changes
55+
- Built from commit ${{ github.sha }}
56+
57+
## Download
58+
Download the JAR file from the assets below.
59+
draft: false
60+
prerelease: false
61+
62+
- name: Upload JAR to Release
63+
uses: actions/upload-release-asset@v1
64+
env:
65+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
66+
with:
67+
upload_url: ${{ steps.create_release.outputs.upload_url }}
68+
asset_path: target/${{ steps.get_version.outputs.jar_name }}
69+
asset_name: ${{ steps.get_version.outputs.jar_name }}
70+
asset_content_type: application/java-archive
71+
72+
- name: Upload JAR as Artifact
73+
uses: actions/upload-artifact@v4
74+
with:
75+
name: lukittu-simple-jar
76+
path: target/${{ steps.get_version.outputs.jar_name }}

0 commit comments

Comments
 (0)