-
Notifications
You must be signed in to change notification settings - Fork 15
127 lines (110 loc) · 4.84 KB
/
release.yml
File metadata and controls
127 lines (110 loc) · 4.84 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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
name: Perform release
env:
JAVA_VERSION: 17
on:
pull_request_target:
types:
- closed
branches:
- main
paths:
- .github/project.yml
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
permissions:
attestations: write
id-token: write
contents: write
discussions: write
issues: write
pull-requests: write
defaults:
run:
shell: bash
jobs:
release:
runs-on: ubuntu-latest
# Verifies that the PR was merged into main, that the PR only runs in the docling-java repo (not a fork), and that the PR branch is NOT from a fork.
if: (github.event.pull_request.merged == true) && (github.repository == 'docling-project/docling-java') && (github.event.pull_request.head.repo.full_name == 'docling-project/docling-java')
steps:
- uses: actions/create-github-app-token@29824e69f54612133e76f7eaac726eef6c875baf # v2.2.1
id: app-token
with:
app-id: ${{ vars.DOCLING_JAVA_CI_APP_ID }}
private-key: ${{ secrets.DOCLING_JAVA_CI_PRIVATE_KEY }}
permission-pull-requests: write
permission-contents: write
permission-issues: write
- name: Checkout before
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
ref: ${{ github.event.pull_request.base.sha }}
token: ${{ steps.app-token.outputs.token }}
fetch-depth: 0
- name: Verify only project.yml was changed
id: verify-files
run: |
FILES_CHANGED=$(curl -s -H "Authorization: token ${{ steps.app-token.outputs.token }}" \
"https://api.github.com/repos/${{ github.repository }}/pulls/${{ github.event.pull_request.number }}/files" | \
jq -r '.[].filename')
if [ "$(echo "$FILES_CHANGED" | wc -l)" -ne 1 ] || [ "$FILES_CHANGED" != ".github/project.yml" ]; then
echo "Warning: Expected only .github/project.yml to be changed, but found:"
echo "$FILES_CHANGED"
echo "Skipping release process."
echo "should_release=false" >> $GITHUB_OUTPUT
else
echo "✓ Verified that only .github/project.yml was changed"
echo "should_release=true" >> $GITHUB_OUTPUT
fi
- name: Capture previous release version
if: steps.verify-files.outputs.should_release == 'true'
run: echo "PREVIOUS_VERSION=$(yq '.release.previous-version' .github/project.yml)" >> $GITHUB_ENV
- name: Capture current version
if: steps.verify-files.outputs.should_release == 'true'
run: echo "CURRENT_VERSION=$(yq '.release.current-version' .github/project.yml)" >> $GITHUB_ENV
- name: Setup Java
if: steps.verify-files.outputs.should_release == 'true'
uses: actions/setup-java@be666c2fcd27ec809703dec50e508c2fdc7f6654 # v5.2.0
with:
java-version: ${{ env.JAVA_VERSION }}
distribution: temurin
- name: Setup Gradle
if: steps.verify-files.outputs.should_release == 'true'
uses: gradle/actions/setup-gradle@0723195856401067f7a2779048b490ace7a47d7c # v5.0.2
- name: Build artifacts
if: steps.verify-files.outputs.should_release == 'true'
run: ./gradlew --no-daemon -Pjava.version=${{ env.JAVA_VERSION }} publish
- name: Tag release
if: steps.verify-files.outputs.should_release == 'true'
env:
JRELEASER_TAG_NAME: "v${{ env.CURRENT_VERSION }}"
run: |
git tag ${{ env.JRELEASER_TAG_NAME }}
git push origin ${{ env.JRELEASER_TAG_NAME }}
- name: Release
if: steps.verify-files.outputs.should_release == 'true'
uses: jreleaser/release-action@90ac653bb9c79d11179e65d81499f3f34527dcd5 # v2.5.0
env:
JRELEASER_MAVENCENTRAL_USERNAME: ${{ secrets.CENTRAL_USERNAME }}
JRELEASER_MAVENCENTRAL_PASSWORD: ${{ secrets.CENTRAL_PASSWORD }}
JRELEASER_GITHUB_TOKEN: ${{ steps.app-token.outputs.token }}
JRELEASER_GPG_PASSPHRASE: ${{ secrets.JRELEASER_GPG_PASSPHRASE }}
JRELEASER_GPG_PUBLIC_KEY: ${{ secrets.JRELEASER_GPG_PUBLIC_KEY }}
JRELEASER_GPG_SECRET_KEY: ${{ secrets.JRELEASER_GPG_SECRET_KEY }}
JRELEASER_DISCORD_WEBHOOK: ${{ secrets.RELEASES_DISCORD_WEBHOOK }}
JRELEASER_DRY_RUN: ${{ inputs.dryrun }}
JRELEASER_TAG_NAME: "v${{ env.CURRENT_VERSION }}"
JRELEASER_PREVIOUS_TAG_NAME: "v${{ env.PREVIOUS_VERSION }}"
JRELEASER_PROJECT_VERSION: ${{ env.CURRENT_VERSION }}
with:
setup-java: false
# Persist logs
- name: JReleaser release output
if: always()
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0
with:
name: jreleaser-release
path: |
build/jreleaser/trace.log
build/jreleaser/output.properties