-
Notifications
You must be signed in to change notification settings - Fork 0
60 lines (59 loc) · 2.41 KB
/
Copy pathpublish-workflow.yml
File metadata and controls
60 lines (59 loc) · 2.41 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
name: Publish
on:
push:
branches: ['master', 'main']
tags:
- "v[0-9]+.[0-9]+.[0-9]+"
jobs:
build:
uses: ./.github/workflows/build-workflow.yml
release:
needs: build
name: Create Release
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v7
with:
fetch-depth: 0
fetch-tags: true
- uses: gradle/actions/setup-gradle@v6
- name: Download build
uses: actions/download-artifact@v8
with:
name: build
path: build
- name: Extract release notes
run: |
if [ "${{ github.ref_type }}" = "tag" ]; then
./gradlew getChangelog --console=plain -q --no-header --project-version="${{ needs.build.outputs.version }}" --output-file=build/release-notes.md
else
./gradlew getChangelog --console=plain -q --no-header --unreleased --output-file=build/release-notes.md
fi
- name: Create GitHub release for tag
if: ${{ github.ref_type == 'tag' }}
run: gh release create "${{ github.ref_name }}" build/*.jar --title "${{ needs.build.outputs.version }}" --notes-file build/release-notes.md
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Update latest-snapshot pre-release
if: ${{ github.ref_type == 'branch' }}
run: |
gh release delete latest-snapshot --yes --cleanup-tag || true
gh release create latest-snapshot build/*.jar --title "${{ needs.build.outputs.version }}" --prerelease --notes-file build/release-notes.md --target "${{ github.sha }}"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Check for tagged release
id: check_tag
run: |
if git tag --points-at HEAD | grep -qE '^v[0-9]+\.[0-9]+\.[0-9]+$'; then
echo "is_release_tag=true" >> "$GITHUB_OUTPUT"
else
echo "is_release_tag=false" >> "$GITHUB_OUTPUT"
fi
- name: Gradle Publish
# Both a branch push and its accompanying tag push trigger this workflow from the
# same release. Skip the branch-triggered run when it's also sitting on a release
# tag, so only the tag-triggered run publishes (avoids a duplicate-version 409).
if: ${{ !(github.ref_type == 'branch' && steps.check_tag.outputs.is_release_tag == 'true') }}
run: ./gradlew publish
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}