|
7 | 7 | - cron: 27 4 * * TUE
|
8 | 8 | workflow_dispatch:
|
9 | 9 | jobs:
|
10 |
| - build: |
| 10 | + publish: |
11 | 11 | runs-on: ubuntu-latest
|
| 12 | + permissions: |
| 13 | + contents: write |
12 | 14 | steps:
|
13 |
| - - uses: actions/checkout@v3 |
14 |
| - - name: Set up Java |
| 15 | + - id: checkout |
| 16 | + name: Clone Git Repository |
| 17 | + uses: actions/checkout@v3 |
| 18 | + - id: commits |
| 19 | + name: Count Commits |
| 20 | + run: echo "count=$(git rev-list --count HEAD --since='last Tuesday')" >> $GITHUB_OUTPUT |
| 21 | + - id: release |
| 22 | + name: Create Release Version |
| 23 | + if: steps.commits.outputs.count > 0 |
| 24 | + run: echo "version=$(date +'%Y.%-m.%-d')" >> $GITHUB_OUTPUT |
| 25 | + - id: sha |
| 26 | + name: Last Commit |
| 27 | + if: steps.commits.outputs.count > 0 |
| 28 | + run: echo "sha=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT |
| 29 | + - id: timestamp |
| 30 | + name: Build Timestamp |
| 31 | + if: steps.commits.outputs.count > 0 |
| 32 | + run: echo "iso8601=$(date --utc --iso-8601=seconds)" >> $GITHUB_OUTPUT |
| 33 | + - id: setup-java |
| 34 | + name: Set up Java |
| 35 | + if: steps.commits.outputs.count > 0 |
15 | 36 | uses: actions/setup-java@v3
|
16 | 37 | with:
|
17 | 38 | java-version: 17
|
| 39 | + java-package: jdk |
| 40 | + architecture: x64 |
18 | 41 | distribution: temurin
|
19 | 42 | server-id: ossrh
|
20 | 43 | server-username: MAVEN_CENTRAL_USERNAME
|
21 | 44 | server-password: MAVEN_CENTRAL_TOKEN
|
22 |
| - - uses: actions/cache@v3 |
| 45 | + - id: cache |
| 46 | + name: Cache Dependencies |
| 47 | + if: steps.commits.outputs.count > 0 |
| 48 | + uses: actions/cache@v3 |
23 | 49 | with:
|
24 | 50 | path: ~/.m2/repository
|
25 | 51 | key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
|
26 | 52 | restore-keys: |
|
27 | 53 | ${{ runner.os }}-maven-
|
28 |
| - - name: Create release version |
29 |
| - id: release |
30 |
| - run: echo "::set-output name=version::$(date +'%Y.%-m.%-d')" |
31 |
| - - name: Count commits in last week |
32 |
| - id: commits |
33 |
| - run: echo "::set-output name=count::$(git rev-list --count HEAD --since='last Tuesday')" |
34 |
| - - name: Set release version |
35 |
| - run: mvn --batch-mode versions:set -DnewVersion=${{ steps.release.outputs.version }} -DgenerateBackupPoms=false |
36 | 54 | - id: gpg
|
37 |
| - if: steps.commits.outputs.count > 0 |
38 | 55 | name: GPG Key
|
39 |
| - run: echo "${{ secrets.GPG_SECRET_KEY_BASE64 }}" | base64 --decode > $GITHUB_WORKSPACE/signing.key.asc |
40 |
| - - name: Publish to Maven Central |
41 | 56 | if: steps.commits.outputs.count > 0
|
42 |
| - run: mvn --batch-mode --activate-profiles release deploy -Dpgp.secretkey=keyfile:$GITHUB_WORKSPACE/signing.key.asc -Dpgp.passphrase=literal:${{ secrets.GPG_SECRET_KEY_PASSWORD }} |
| 57 | + |
| 58 | + with: |
| 59 | + fileName: signing.key.asc |
| 60 | + fileDir: ${{ github.workspace}} |
| 61 | + encodedString: ${{ secrets.GPG_SECRET_KEY_BASE64 }} |
| 62 | + - id: pom-version |
| 63 | + name: Set Release Version |
| 64 | + if: steps.commits.outputs.count > 0 |
| 65 | + run: mvn --batch-mode --define newVersion=${{ steps.release.outputs.version }} --define generateBackupPoms=false versions:set |
| 66 | + - id: deploy-maven |
| 67 | + name: Deploy Maven Artifact |
| 68 | + if: steps.commits.outputs.count > 0 |
| 69 | + run: | |
| 70 | + mvn \ |
| 71 | + --batch-mode \ |
| 72 | + --activate-profiles release \ |
| 73 | + --define scmTag=${{ steps.sha.outputs.sha }} \ |
| 74 | + --define pgp.secretkey=keyfile:${{ steps.gpg.outputs.filePath }} \ |
| 75 | + --define pgp.passphrase=literal:${{ secrets.GPG_SECRET_KEY_PASSWORD }} \ |
| 76 | + --define project.build.outputTimestamp=${{ steps.timestamp.outputs.iso8601 }} \ |
| 77 | + deploy |
43 | 78 | env:
|
44 | 79 | MAVEN_CENTRAL_USERNAME: ${{ secrets.MAVEN_CENTRAL_USERNAME }}
|
45 | 80 | MAVEN_CENTRAL_TOKEN: ${{ secrets.MAVEN_CENTRAL_TOKEN }}
|
46 |
| - - name: Create Release |
| 81 | + 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" |
| 82 | + - id: create_release |
| 83 | + name: Create Release |
47 | 84 | if: steps.commits.outputs.count > 0
|
48 |
| - id: create_release |
49 |
| - |
50 |
| - env: |
51 |
| - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 85 | + uses: softprops/action-gh-release@v1 |
52 | 86 | with:
|
53 | 87 | tag_name: ${{ steps.release.outputs.version }}
|
54 |
| - release_name: ${{ steps.release.outputs.version }} |
| 88 | + name: ${{ steps.release.outputs.version }} |
| 89 | + token: ${{ secrets.GITHUB_TOKEN }} |
55 | 90 | draft: false
|
56 | 91 | prerelease: false
|
57 |
| - body: | |
58 |
| - Automated release, see [commits](https://github.com/metio/storage-units/commits/${{ steps.release.outputs.version }}) for changes. |
| 92 | + generate_release_notes: true |
| 93 | + - id: mail |
| 94 | + name: Send Mail |
| 95 | + if: steps.commits.outputs.count > 0 |
| 96 | + |
| 97 | + with: |
| 98 | + server_address: ${{ secrets.MAIL_SERVER }} |
| 99 | + server_port: ${{ secrets.MAIL_PORT }} |
| 100 | + username: ${{ secrets.MAIL_USERNAME }} |
| 101 | + password: ${{ secrets.MAIL_PASSWORD }} |
| 102 | + subject: ${{ github.event.repository.name }} version ${{ steps.release.outputs.version }} published |
| 103 | + body: See ${{ steps.create_release.outputs.url }} for details. |
| 104 | + |
| 105 | + from: ${{ secrets.MAIL_SENDER }} |
| 106 | + - id: matrix |
| 107 | + name: Send Matrix Message |
| 108 | + if: steps.commits.outputs.count > 0 |
| 109 | + |
| 110 | + with: |
| 111 | + room_id: ${{ secrets.MATRIX_ROOM_ID }} |
| 112 | + access_token: ${{ secrets.MATRIX_ACCESS_TOKEN }} |
| 113 | + message: ${{ github.event.repository.name }} version [${{ steps.release.outputs.version }}](${{ steps.create_release.outputs.url }}) published |
| 114 | + server: matrix.org |
0 commit comments