Skip to content

Automated Release

Automated Release #81

Workflow file for this run

# SPDX-FileCopyrightText: The memoization.java Authors
# SPDX-License-Identifier: 0BSD
name: Automated Release
on:
schedule:
- cron: 35 5 * * MON
workflow_dispatch:
jobs:
publish:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- id: checkout
name: Clone Git Repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- 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 -- pom.xml memoization-core/pom.xml memoization-core/src/main/java memoization-jdk/pom.xml memoization-jdk/src/main/java memoization-jool/pom.xml memoization-jool/src/main/java memoization-lambda/pom.xml memoization-lambda/src/main/java memoization-rxjava/pom.xml memoization-rxjava/src/main/java)" >> $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
uses: ./.github/actions/managed-maven
if: steps.commits.outputs.count > 0
- id: gpg
name: GPG Key
if: steps.commits.outputs.count > 0
uses: timheuer/base64-to-file@v1
with:
fileName: signing.key.asc
fileDir: ${{ github.workspace }}
encodedString: ${{ secrets.GPG_SECRET_KEY_BASE64 }}
- id: pom-version
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: 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:${{ steps.gpg.outputs.filePath }}
--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 }}