Automated Release #59
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# SPDX-FileCopyrightText: The javapoet-type-guesser Authors | |
# SPDX-License-Identifier: 0BSD | |
name: Automated Release | |
on: | |
schedule: | |
- cron: 45 3 * * THU | |
workflow_dispatch: | |
jobs: | |
publish: | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write | |
steps: | |
- id: checkout | |
name: Clone Git Repository | |
uses: actions/checkout@v3 | |
- id: commits | |
name: Count Commits | |
run: echo "count=$(git rev-list --count HEAD --since='last week')" >> $GITHUB_OUTPUT | |
- id: release | |
name: Create Release Version | |
if: steps.commits.outputs.count > 0 | |
run: echo "version=$(date +'%Y.%-m.%-d')" >> $GITHUB_OUTPUT | |
- id: sha | |
name: Last Commit | |
if: steps.commits.outputs.count > 0 | |
run: echo "sha=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT | |
- id: timestamp | |
name: Build Timestamp | |
if: steps.commits.outputs.count > 0 | |
run: echo "iso8601=$(date --utc --iso-8601=seconds)" >> $GITHUB_OUTPUT | |
- id: setup-java | |
name: Set up Java | |
if: steps.commits.outputs.count > 0 | |
uses: actions/setup-java@v3 | |
with: | |
java-version: 17 | |
java-package: jdk | |
architecture: x64 | |
distribution: temurin | |
server-id: ossrh | |
server-username: MAVEN_CENTRAL_USERNAME | |
server-password: MAVEN_CENTRAL_TOKEN | |
- id: cache | |
name: Cache Dependencies | |
if: steps.commits.outputs.count > 0 | |
uses: actions/cache@v3 | |
with: | |
path: ~/.m2/repository | |
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} | |
restore-keys: | | |
${{ runner.os }}-maven- | |
- 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 }} | |
- id: deploy-maven | |
name: Deploy Maven Artifact | |
if: steps.commits.outputs.count > 0 | |
run: | | |
mvn \ | |
--batch-mode \ | |
--activate-profiles release \ | |
--define scmTag=${{ steps.sha.outputs.sha }} \ | |
--define pgp.secretkey=keyfile:signing.key.asc \ | |
--define pgp.passphrase=literal:${{ secrets.GPG_SECRET_KEY_PASSWORD }} \ | |
--define project.build.outputTimestamp=${{ steps.timestamp.outputs.iso8601 }} \ | |
deploy | |
env: | |
MAVEN_CENTRAL_USERNAME: ${{ secrets.MAVEN_CENTRAL_USERNAME }} | |
MAVEN_CENTRAL_TOKEN: ${{ secrets.MAVEN_CENTRAL_TOKEN }} | |
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" | |
- id: create_release | |
name: Create Release | |
if: steps.commits.outputs.count > 0 | |
uses: softprops/action-gh-release@v1 | |
with: | |
tag_name: ${{ steps.release.outputs.version }} | |
name: ${{ steps.release.outputs.version }} | |
token: ${{ secrets.GITHUB_TOKEN }} | |
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. | |
to: ${{ secrets.MAIL_RECIPIENT }} | |
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: ${{ secrets.MATRIX_SERVER }} |