-
Notifications
You must be signed in to change notification settings - Fork 0
87 lines (86 loc) · 3.28 KB
/
publish.yml
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
# SPDX-FileCopyrightText: The maven-parent Authors
# SPDX-License-Identifier: 0BSD
name: Perform Release
on:
schedule:
- cron: 15 1 * * FRI
workflow_dispatch:
jobs:
publish:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- id: checkout
name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: ./.github/actions/managed-pom
- id: last_release
name: Fetch last release info
run: echo "tag=$(gh release view --json tagName --jq '.tagName')" >> $GITHUB_OUTPUT
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- id: commits
name: Count Commits
run: echo "count=$(git rev-list --count ${{ steps.last_release.outputs.tag }}..HEAD)" >> $GITHUB_OUTPUT
- id: release
name: Create release version
if: steps.commits.outputs.count > 0
run: echo "version=$(date +'%Y.%-m.%-d')" >> $GITHUB_OUTPUT
- name: Set release version
if: steps.commits.outputs.count > 0
run: mvn --batch-mode --define newVersion=${{ steps.release.outputs.version }} --define generateBackupPoms=false versions:set
- id: gpg
name: GPG Key
if: steps.commits.outputs.count > 0
uses: timheuer/[email protected]
with:
fileName: signing.key.asc
fileDir: ${{ github.workspace}}
encodedString: ${{ secrets.GPG_SECRET_KEY_BASE64 }}
- name: Publish to Maven Central
if: steps.commits.outputs.count > 0
run: >
mvn
--batch-mode
--activate-profiles release
--define sign.keyFile=${{ github.workspace}}/signing.key.asc
--define sign.keyPass=${{ secrets.GPG_SECRET_KEY_PASSWORD }}
deploy
env:
MAVEN_CENTRAL_USERNAME: ${{ secrets.MAVEN_CENTRAL_USERNAME }}
MAVEN_CENTRAL_TOKEN: ${{ secrets.MAVEN_CENTRAL_TOKEN }}
- id: create_release
name: Create Release
if: steps.commits.outputs.count > 0
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ steps.release.outputs.version }}
name: ${{ steps.release.outputs.version }}
draft: false
prerelease: false
generate_release_notes: true
- id: mail
name: Send Mail
if: steps.commits.outputs.count > 0
uses: dawidd6/action-send-mail@v3
with:
server_address: ${{ secrets.MAIL_SERVER }}
server_port: ${{ secrets.MAIL_PORT }}
username: ${{ secrets.MAIL_USERNAME }}
password: ${{ secrets.MAIL_PASSWORD }}
subject: ${{ github.event.repository.name }} version ${{ steps.release.outputs.version }} published
body: See ${{ steps.create_release.outputs.url }} for details.
from: ${{ secrets.MAIL_SENDER }}
- id: matrix
name: Send Matrix Message
if: steps.commits.outputs.count > 0
uses: s3krit/[email protected]
with:
room_id: ${{ secrets.MATRIX_ROOM_ID }}
access_token: ${{ secrets.MATRIX_ACCESS_TOKEN }}
message: ${{ github.event.repository.name }} version [${{ steps.release.outputs.version }}](${{ steps.create_release.outputs.url }}) published
server: matrix.org