Skip to content

Commit 8e6e1c4

Browse files
committed
Update workflow
1 parent 951de4b commit 8e6e1c4

File tree

1 file changed

+32
-23
lines changed

1 file changed

+32
-23
lines changed

.github/workflows/build.yml

Lines changed: 32 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,40 @@
1-
name: build
1+
name: Build
22
on:
3+
pull_request:
4+
workflow_dispatch:
35
push:
46
branches:
57
- main
68
jobs:
79
build:
10+
permissions:
11+
contents: read
12+
packages: write
813
runs-on: ubuntu-latest
914
steps:
10-
- name: checkout
11-
uses: actions/checkout@v3
12-
- name: setup
13-
uses: actions/setup-java@v3
14-
with:
15-
java-version: 8
16-
distribution: adopt
17-
- name: cache
18-
uses: actions/cache@v3
19-
with:
20-
path: ~/.m2/repository
21-
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
22-
restore-keys: |
23-
${{ runner.os }}-maven-
24-
- name: build
25-
run: mvn install
26-
- name: artifact
27-
uses: actions/upload-artifact@v4
28-
with:
29-
name: MatchShare.jar
30-
path: target/MatchShare-1.0.0-SNAPSHOT.jar
31-
if-no-files-found: error
15+
- id: checkout
16+
name: Checkout
17+
uses: actions/checkout@v4
18+
with:
19+
fetch-depth: 0
20+
- id: setup-java
21+
name: Setup Java
22+
uses: actions/setup-java@v4
23+
with:
24+
java-version: 21
25+
distribution: temurin
26+
# Configures gradle with caching
27+
- name: Setup Gradle
28+
uses: gradle/actions/setup-gradle@v4
29+
# Run "gradlew publish" for origin/dev and "gradlew build" for PRs or elsewhere
30+
- name: Execute Gradle ${{ (github.repository == 'applenick/MatchShare' && github.ref == 'refs/heads/dev') && 'Publish' || 'Build' }}
31+
run: ./gradlew ${{ (github.repository == 'applenick/MatchShare' && github.ref == 'refs/heads/dev') && 'publish' || 'build' }}
32+
env:
33+
GITHUB_TOKEN: ${{ (github.repository == 'applenick/MatchShare' && github.ref == 'refs/heads/dev') && secrets.GITHUB_TOKEN || '' }}
34+
- id: artifact
35+
name: Upload Jar
36+
uses: actions/upload-artifact@v4
37+
with:
38+
name: MatchShare.jar
39+
path: build/libs/MatchShare.jar
40+
if-no-files-found: error

0 commit comments

Comments
 (0)