Bump actions/create-release from 1 to 1.1.4
[reguloj.git] / .github / workflows / release.yml
blob6289f275796dcfb25fd680ab947b972f892fa175
1 name: Perform Release
2 on:
3   schedule:
4     - cron:  '35 7 * * TUE'
5 env:
6   JAVA: 16
7 jobs:
8   build:
9     runs-on: ubuntu-latest
10     steps:
11       - uses: actions/checkout@v2.3.4
12       - name: Set up JDK 16
13         uses: actions/setup-java@v2
14         with:
15           java-version: ${{ env.JAVA }}
16           distribution: 'adopt'
17           server-id: ossrh
18           server-username: MAVEN_CENTRAL_USERNAME
19           server-password: MAVEN_CENTRAL_TOKEN
20       - uses: actions/cache@v2.1.5
21         with:
22           path: ~/.m2/repository
23           key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
24           restore-keys: |
25             ${{ runner.os }}-maven-
26       - name: Create Release Version
27         id: release
28         run: echo "::set-output name=version::$(date +'%Y.%-m.%-d')"
29       - name: Count commits in last week
30         id: commits
31         run: echo "::set-output name=count::$(git rev-list --count HEAD --since='last Tuesday')"
32       - name: Set release version
33         run: mvn --batch-mode versions:set -DnewVersion=${{ steps.release.outputs.version }} -DgenerateBackupPoms=false
34       - id: gpg
35         name: GPG Key
36         run: echo "${{ secrets.GPG_SECRET_KEY_BASE64 }}" | base64 --decode > $GITHUB_WORKSPACE/signing.key.asc
37       - name: Publish to Maven Central
38         if: steps.commits.outputs.count > 0
39         run: MAVEN_OPTS="--add-opens=java.base/java.util=ALL-UNNAMED --add-opens=java.base/java.lang.reflect=ALL-UNNAMED --add-opens=java.base/java.text=ALL-UNNAMED --add-opens=java.desktop/java.awt.font=ALL-UNNAMED" mvn --batch-mode --activate-profiles release verify deploy -Dpgp.secretkey=keyfile:$GITHUB_WORKSPACE/signing.key.asc -Dpgp.passphrase=literal:${{ secrets.GPG_SECRET_KEY_PASSWORD }}
40         env:
41           MAVEN_CENTRAL_USERNAME: ${{ secrets.MAVEN_CENTRAL_USERNAME }}
42           MAVEN_CENTRAL_TOKEN: ${{ secrets.MAVEN_CENTRAL_TOKEN }}
43       - name: Create Release
44         if: steps.commits.outputs.count > 0
45         id: create_release
46         uses: actions/create-release@v1.1.4
47         env:
48           GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
49         with:
50           tag_name: ${{ steps.release.outputs.version }}
51           release_name: Release ${{ steps.release.outputs.version }}
52           draft: false
53           prerelease: false
54           body: |
55             Automated release, see [commits](https://github.com/metio/reguloj/commits/${{ steps.release.outputs.version }}) for changes. **Requires at least Java ${{ env.JAVA }}**.
57             Include this project as a Maven dependency:
58             ```xml
59             <dependency>
60               <groupId>wtf.metio.reguloj</groupId>
61               <artifactId>reguloj</artifactId>
62               <version>${{ steps.release.outputs.version }}</version>
63             </dependency>
64             ```
66             Or like this in case you are using Gradle (Kotlin):
67             ```kotlin
68             dependencies {
69                 implementation("wtf.metio.reguloj:reguloj:${{ steps.release.outputs.version }}") {
70                     because("we want to use a lightweight rule engine")
71                 }
72             }
73             ```
74             Take a look the [information](https://search.maven.org/artifact/wtf.metio.reguloj/reguloj/${{ steps.release.outputs.version }}/jar) available at Maven Central for other build tools.
75       - name: Send Mail
76         if: steps.commits.outputs.count > 0
77         uses: dawidd6/action-send-mail@v3.1.0
78         with:
79           server_address: ${{ secrets.MAIL_SERVER }}
80           server_port: ${{ secrets.MAIL_PORT }}
81           username: ${{ secrets.MAIL_USERNAME }}
82           password: ${{ secrets.MAIL_PASSWORD }}
83           subject: reguloj release ${{ steps.release.outputs.version }}
84           body: See https://github.com/metio/reguloj/releases/tag/${{ steps.release.outputs.version }} for details.
85           to: reguloj@metio.groups.io
86           from: ${{ secrets.MAIL_SENDER }}
87       - id: matrix
88         name: Send Matrix Message
89         uses: s3krit/matrix-message-action@v0.0.3
90         with:
91           room_id: ${{ secrets.MATRIX_ROOM_ID }}
92           access_token: ${{ secrets.MATRIX_ACCESS_TOKEN }}
93           message: "release [${{ steps.release.outputs.version }}](https://github.com/metio/reguloj/releases/tag/${{ steps.release.outputs.version }}) published"
94           server: "matrix.org"