Skip to content

Automated Release

Automated Release #216

Workflow file for this run

# SPDX-FileCopyrightText: The ilo Authors
# SPDX-License-Identifier: 0BSD
name: Automated Release
on:
schedule:
- cron: 45 3 * * MON
workflow_dispatch:
jobs:
prepare:
name: Prepare Release
runs-on: ubuntu-latest
outputs:
commit_count: ${{ steps.commits.outputs.count }}
release_version: ${{ steps.release.outputs.version }}
previous_version: ${{ steps.last_release.outputs.tag }}
release_url: ${{ steps.create_release.outputs.upload_url }}
build_timestamp: ${{ steps.timestamp.outputs.iso8601 }}
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 -- src/main/java pom.xml)" >> $GITHUB_OUTPUT
- id: release
name: Create Release Version
if: steps.commits.outputs.count > 0
run: echo "version=$(date +'%Y.%-m.%-d')" >> $GITHUB_OUTPUT
- name: Build Timestamp
id: timestamp
run: echo "iso8601=$(date --utc --iso-8601=seconds)" >> $GITHUB_OUTPUT
build:
name: Build on ${{ matrix.os }}
needs: prepare
runs-on: ${{ matrix.os }}
strategy:
matrix:
os:
- ubuntu-latest
- macos-latest
- windows-latest
steps:
- id: checkout
name: Clone Git Repository
if: needs.prepare.outputs.commit_count > 0
uses: actions/checkout@v4
- id: graal
name: GraalVM Setup
if: needs.prepare.outputs.commit_count > 0
uses: graalvm/setup-graalvm@v1
with:
version: latest
java-version: 21
github-token: ${{ secrets.GITHUB_TOKEN }}
- id: cache
name: Cache Maven Repository
if: needs.prepare.outputs.commit_count > 0
uses: actions/cache@v4
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-
- id: gpg
name: GPG Key
if: needs.prepare.outputs.commit_count > 0
uses: timheuer/[email protected]
with:
fileName: signing.key.asc
fileDir: ${{ github.workspace}}
encodedString: ${{ secrets.GPG_SECRET_KEY_BASE64 }}
- id: verify
if: needs.prepare.outputs.commit_count > 0
name: Verify Project
run: >
mvn
--batch-mode
--activate-profiles release
--define revision=${{ needs.prepare.outputs.release_version }}
--define skipNativeBuild=false
--define sign.keyFile=signing.key.asc
--define sign.keyPass=${{ secrets.GPG_SECRET_KEY_PASSWORD }}
--define project.build.outputTimestamp=${{ needs.prepare.outputs.build_timestamp }}
verify
- id: upload-java
name: Upload JVM Artifact
if: needs.prepare.outputs.commit_count > 0 && runner.os == 'Linux'
uses: actions/upload-artifact@v4
with:
name: jvm
path: ./target/ilo-*-jvm*
- id: upload-linux
name: Upload Linux Artifact
if: needs.prepare.outputs.commit_count > 0 && runner.os == 'Linux'
uses: actions/upload-artifact@v4
with:
name: linux
path: ./target/ilo-*-linux*
- id: upload-mac
name: Upload Mac Artifact
if: needs.prepare.outputs.commit_count > 0 && runner.os == 'macOS'
uses: actions/upload-artifact@v4
with:
name: mac
path: ./target/ilo-*-mac*
- id: upload-windows
name: Upload Windows Artifact
if: needs.prepare.outputs.commit_count > 0 && runner.os == 'Windows'
uses: actions/upload-artifact@v4
with:
name: windows
path: ./target/ilo-*-windows*
release:
name: GitHub Release
needs: [prepare, build]
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- id: checkout
name: Clone Git Repository
if: needs.prepare.outputs.commit_count > 0
uses: actions/checkout@v4
with:
fetch-depth: 0
- id: download
name: Download Artifacts
if: needs.prepare.outputs.commit_count > 0
uses: actions/download-artifact@v4
with:
path: artifacts
- id: create_release
name: Create Release
if: needs.prepare.outputs.commit_count > 0
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ needs.prepare.outputs.release_version }}
name: ${{ needs.prepare.outputs.release_version }}
token: ${{ secrets.GITHUB_TOKEN }}
draft: false
prerelease: false
generate_release_notes: true
files: |
artifacts/jvm/ilo-${{ needs.prepare.outputs.release_version }}-jvm.tar.gz
artifacts/jvm/ilo-${{ needs.prepare.outputs.release_version }}-jvm.tar.gz.asc
artifacts/jvm/ilo-${{ needs.prepare.outputs.release_version }}-jvm.tar.gz.sha512
artifacts/linux/ilo-${{ needs.prepare.outputs.release_version }}-linux.tar.gz
artifacts/linux/ilo-${{ needs.prepare.outputs.release_version }}-linux.tar.gz.asc
artifacts/linux/ilo-${{ needs.prepare.outputs.release_version }}-linux.tar.gz.sha512
artifacts/mac/ilo-${{ needs.prepare.outputs.release_version }}-mac.tar.gz
artifacts/mac/ilo-${{ needs.prepare.outputs.release_version }}-mac.tar.gz.asc
artifacts/mac/ilo-${{ needs.prepare.outputs.release_version }}-mac.tar.gz.sha512
artifacts/windows/ilo-${{ needs.prepare.outputs.release_version }}-windows.tar.gz
artifacts/windows/ilo-${{ needs.prepare.outputs.release_version }}-windows.tar.gz.asc
artifacts/windows/ilo-${{ needs.prepare.outputs.release_version }}-windows.tar.gz.sha512
- id: email
name: Send Mail
if: needs.prepare.outputs.commit_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 ${{ needs.prepare.outputs.release_version }} published
body: See https://github.com/metio/ilo/releases/tag/${{ needs.prepare.outputs.release_version }} for details.
to: [email protected]
from: ${{ secrets.MAIL_SENDER }}
- id: matrix
name: Send Matrix Message
if: needs.prepare.outputs.commit_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 [${{ needs.prepare.outputs.release_version }}](https://github.com/metio/ilo/releases/tag/${{ needs.prepare.outputs.release_version }}) published
server: matrix.org