Skip to content

Update GitHub actions #1

Update GitHub actions

Update GitHub actions #1

Workflow file for this run

name: ci
permissions:
contents: write
on:
push:
branches:
- '**'
tags:
- '**'
paths:
- 'src/**'
- 'build.gradle'
- 'settings.gradle'
- 'gradle.properties'
- 'gradle/**'
- 'gradlew'
- 'gradlew.bat'
- '.github/workflows/**'
jobs:
build:
runs-on: ubuntu-24.04
steps:
- name: Checkout
uses: actions/checkout@v6
with:
# Fetch all history for tag changelog generation.
fetch-depth: 0
- name: Setup Java 25
uses: actions/setup-java@v5
with:
distribution: 'temurin'
java-version: '25'
- name: Get Short Identifier
id: short-sha
shell: bash
run: echo "sha=${GITHUB_SHA::7}" >> "$GITHUB_OUTPUT"
- name: Build Snapshot
id: build
if: ${{ !startsWith(github.ref, 'refs/tags/') }}
env:
VERSION_IDENTIFIER: SNAPSHOT+${{ steps.short-sha.outputs.sha }}
run: ./gradlew build githubActionOutput --stacktrace
- name: GitHub Action Artifact
if: ${{ !startsWith(github.ref, 'refs/tags/') }}
uses: actions/upload-artifact@v7
with:
name: ${{ steps.build.outputs.artifact_name }}
path: ${{ steps.build.outputs.artifact_path }}
- name: Maven Publish
id: publish
if: ${{ startsWith(github.ref, 'refs/tags/') }}
env:
ARCHIVE_ENDPOINT: ${{ secrets.TEACON_ARCHIVE_ENDPOINT }}
ARCHIVE_ACCESS_KEY: ${{ secrets.TEACON_ARCHIVE_ACCESS_KEY }}
ARCHIVE_SECRET_KEY: ${{ secrets.TEACON_ARCHIVE_SECRET_KEY }}
run: ./gradlew -Dorg.gradle.s3.endpoint=$ARCHIVE_ENDPOINT publishReleasePublicationToTeaconRepository githubActionOutput
- name: Generate Changelog
id: changelog
if: ${{ startsWith(github.ref, 'refs/tags/') }}
shell: bash
env:
CURRENT: ${{ github.ref }}
ARTIFACT_GIT_TAG: ${{ steps.publish.outputs.artifact_git_tag }}
# Special thanks to this post on Stack Overflow regarding change set between two tags:
# https://stackoverflow.com/questions/12082981
# Do note that actions/checkout will enter detach mode by default, so you won't have
# access to HEAD ref. Use GitHub-Action-supplied `github.ref` instead.
# We use Bash parameter expansion to do find-and-replace.
# https://www.gnu.org/software/bash/manual/html_node/Shell-Parameter-Expansion.html
# Also we cannot use git rev-list because it always prepend "commit <hash>"
# See https://stackoverflow.com/questions/36927089/
run: |
current_tag=${CURRENT/refs\/tags\//}
test "$current_tag" = "$ARTIFACT_GIT_TAG"
last_tag=$(git describe --tags --abbrev=0 "$current_tag"^ 2>/dev/null || echo)
if [ -z "$last_tag" ]; then changelog=$(git log --pretty="format:%H: %s")
else changelog=$(git log --pretty="format:%H: %s" "${last_tag}..$current_tag"); fi
echo "value<<EOF"$'\n'"Change set since ${last_tag:-the beginning}:"$'\n'"$changelog"$'\n'"EOF" >> "$GITHUB_OUTPUT"
- name: Prepare Release Asset
id: release-asset
if: ${{ startsWith(github.ref, 'refs/tags/') }}
shell: bash
env:
ARTIFACT_PATH: ${{ steps.publish.outputs.artifact_path }}
ARTIFACT_PUBLISH_NAME: ${{ steps.publish.outputs.artifact_publish_name }}
run: |
release_asset_path="$RUNNER_TEMP/$ARTIFACT_PUBLISH_NAME"
cp "$ARTIFACT_PATH" "$release_asset_path"
echo "path=$release_asset_path" >> "$GITHUB_OUTPUT"
- name: GitHub Release
if: ${{ startsWith(github.ref, 'refs/tags/') }}
uses: softprops/action-gh-release@v3
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
name: ${{ github.ref_name }}
tag_name: ${{ github.ref_name }}
body: ${{ steps.changelog.outputs.value }}
files: ${{ steps.release-asset.outputs.path }}
overwrite_files: true