-
Notifications
You must be signed in to change notification settings - Fork 14
74 lines (65 loc) · 2.67 KB
/
Copy pathrelease.yml
File metadata and controls
74 lines (65 loc) · 2.67 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
name: Release
on:
release:
types: [published]
workflow_dispatch:
inputs:
tag:
description: 'Existing release tag to attach rebuilt JARs to'
required: true
type: string
permissions:
contents: write
jobs:
attach-jar:
name: Build + attach JARs to release
runs-on: ubuntu-latest
steps:
- name: Checkout (release tag)
uses: actions/checkout@v4
with:
ref: ${{ github.event.release.tag_name || inputs.tag }}
fetch-depth: 0
- name: Set up JDK 21
uses: actions/setup-java@v4
with:
java-version: '21'
distribution: 'temurin'
- name: Set up Gradle
uses: gradle/actions/setup-gradle@v4
- name: Verify tag matches project version
run: |
TAG="${{ github.event.release.tag_name || inputs.tag }}"
TAG_VERSION="${TAG#v}"
GRADLE_VERSION=$(grep -E "^\s*version\s*=?\s*['\"]" build.gradle | head -n1 | sed -E "s/.*['\"]([^'\"]+)['\"].*/\1/")
echo "release tag: $TAG"
echo "tag version: $TAG_VERSION"
echo "gradle version: $GRADLE_VERSION"
if [ "$TAG_VERSION" != "$GRADLE_VERSION" ]; then
echo "::error::Release tag version ($TAG_VERSION) does not match root build.gradle version ($GRADLE_VERSION). Bump build.gradle before tagging, or retag."
exit 1
fi
- name: Build shadow plugin + api artifacts (skip tests — already run on the tagged commit by build.yml)
run: ./gradlew --no-daemon :plugin:shadowJar :api:build
- name: Resolve artifact paths
id: paths
run: |
# Skip the dev-only -thin jar; only the shaded fat jar ships.
PLUGIN=$(ls plugin/build/libs/AbstractMenus-*.jar | grep -v -- '-thin\.jar$' | head -n1)
API_BIN=$(ls api/build/libs/AbstractMenus-api-*.jar | grep -v 'sources\|javadoc' | head -n1)
API_SRC=$(ls api/build/libs/AbstractMenus-api-*-sources.jar | head -n1)
API_DOC=$(ls api/build/libs/AbstractMenus-api-*-javadoc.jar | head -n1)
echo "plugin=$PLUGIN" >> "$GITHUB_OUTPUT"
echo "api_bin=$API_BIN" >> "$GITHUB_OUTPUT"
echo "api_src=$API_SRC" >> "$GITHUB_OUTPUT"
echo "api_doc=$API_DOC" >> "$GITHUB_OUTPUT"
- name: Attach JARs to release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ github.event.release.tag_name || inputs.tag }}
files: |
${{ steps.paths.outputs.plugin }}
${{ steps.paths.outputs.api_bin }}
${{ steps.paths.outputs.api_src }}
${{ steps.paths.outputs.api_doc }}
fail_on_unmatched_files: true