update project meta
[storage-units.git] / .github / workflows / release.yml
blobb439e838b1c1cad35f2481cc589203d8e0a797b9
1 # SPDX-FileCopyrightText: The Storage-Units Authors
2 # SPDX-License-Identifier: 0BSD
4 name: Automated Release
5 on:
6   schedule:
7     - cron:  27 4 * * TUE
8 jobs:
9   build:
10     runs-on: ubuntu-latest
11     steps:
12       - uses: actions/checkout@v3
13       - name: Set up Java
14         uses: actions/setup-java@v3
15         with:
16           java-version: 17
17           distribution: temurin
18           server-id: ossrh
19           server-username: MAVEN_CENTRAL_USERNAME
20           server-password: MAVEN_CENTRAL_TOKEN
21       - uses: actions/cache@v3
22         with:
23           path: ~/.m2/repository
24           key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
25           restore-keys: |
26             ${{ runner.os }}-maven-
27       - name: Create release version
28         id: release
29         run: echo "::set-output name=version::$(date +'%Y.%-m.%-d')"
30       - name: Count commits in last week
31         id: commits
32         run: echo "::set-output name=count::$(git rev-list --count HEAD --since='last Tuesday')"
33       - name: Set release version
34         run: mvn --batch-mode versions:set -DnewVersion=${{ steps.release.outputs.version }} -DgenerateBackupPoms=false
35       - id: gpg
36         if: steps.commits.outputs.count > 0
37         name: GPG Key
38         run: echo "${{ secrets.GPG_SECRET_KEY_BASE64 }}" | base64 --decode > $GITHUB_WORKSPACE/signing.key.asc
39       - name: Publish to Maven Central
40         if: steps.commits.outputs.count > 0
41         run: mvn --batch-mode --activate-profiles release deploy -Dpgp.secretkey=keyfile:$GITHUB_WORKSPACE/signing.key.asc -Dpgp.passphrase=literal:${{ secrets.GPG_SECRET_KEY_PASSWORD }}
42         env:
43           MAVEN_CENTRAL_USERNAME: ${{ secrets.MAVEN_CENTRAL_USERNAME }}
44           MAVEN_CENTRAL_TOKEN: ${{ secrets.MAVEN_CENTRAL_TOKEN }}
45       - name: Create Release
46         if: steps.commits.outputs.count > 0
47         id: create_release
48         uses: actions/create-release@v1.1.4
49         env:
50           GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
51         with:
52           tag_name: ${{ steps.release.outputs.version }}
53           release_name: ${{ steps.release.outputs.version }}
54           draft: false
55           prerelease: false
56           body: |
57             Automated release, see [commits](https://github.com/metio/storage-units/commits/${{ steps.release.outputs.version }}) for changes.