forked from ayunami2000/ayunViaProxyEagUtils
-
Notifications
You must be signed in to change notification settings - Fork 1
74 lines (61 loc) · 2.59 KB
/
gradle.yml
File metadata and controls
74 lines (61 loc) · 2.59 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
on:
workflow_dispatch:
push:
branches: [ main ]
paths: [ src/**, build.gradle.kts, settings.gradle.kts ]
permissions:
contents: write
actions: read
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-java@v4
with:
distribution: temurin
java-version: 21
- uses: gradle/actions/setup-gradle@v4
- run: |
gradle wrapper
chmod +x ./gradlew
./gradlew jar
- id: vars
run: |
echo "COMMIT_HASH=$(git rev-parse --short HEAD)" >> "$GITHUB_OUTPUT"
./gradlew -q printVars | sed 's/ = /=/g' >> "$GITHUB_OUTPUT"
- id: ghck
run: |
CODE=$(curl -s -o /dev/null -w "%{http_code}" \
-H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
-H "X-GitHub-Api-Version: 2022-11-28" \
"https://api.github.com/repos/${{ github.repository }}/releases/tags/v${{ steps.vars.outputs.VERS }}")
if [ "$CODE" = "200" ]; then
echo "EXISTS=true" >> "$GITHUB_OUTPUT"
else
echo "EXISTS=false" >> "$GITHUB_OUTPUT"
fi
- id: dist
run: |
echo "TAG_NAME=${{ format('v{0}{1}', steps.vars.outputs.VERS, steps.ghck.outputs.EXISTS == 'true' && format('+{0}', steps.vars.outputs.COMMIT_HASH) || '') }}" >> "$GITHUB_OUTPUT"
echo "REL_NAME=${{ format('{0}{1}', steps.ghck.outputs.EXISTS == 'true' && 'Snapshot ' || 'v', steps.ghck.outputs.EXISTS == 'true' && steps.vars.outputs.COMMIT_HASH || steps.vars.outputs.VERS) }}" >> "$GITHUB_OUTPUT"
echo "ART_NAME=${{ format('{0}{1}.jar', steps.vars.outputs.AFCT, steps.ghck.outputs.EXISTS == 'true' && format('+{0}', steps.vars.outputs.COMMIT_HASH) || '') }}" >> "$GITHUB_OUTPUT"
- run: |
mkdir -p dist
cp "./build/libs/${{ steps.vars.outputs.AFCT }}.jar" ./dist/${{ steps.dist.outputs.ART_NAME }}
- uses: actions/upload-artifact@v4
with:
path: dist/${{ steps.dist.outputs.ART_NAME }}
name: ${{ steps.dist.outputs.ART_NAME }}
- if: github.event_name == 'push' && github.ref == 'refs/heads/main'
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ steps.dist.outputs.TAG_NAME }}
name: ${{ steps.dist.outputs.REL_NAME }}
files: dist/${{ steps.dist.outputs.ART_NAME }}
prerelease: ${{ steps.ghck.outputs.EXISTS == 'true' }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}