117 lines
4.3 KiB
YAML
117 lines
4.3 KiB
YAML
name: Release
|
|
|
|
on:
|
|
workflow_call:
|
|
inputs:
|
|
JAVA_VERSION:
|
|
default: 17
|
|
description: Java version to use
|
|
required: false
|
|
type: string
|
|
FAIL_FOR_NO_CHANGES:
|
|
default: true
|
|
description: Fail if there were no changes to release
|
|
required: false
|
|
type: boolean
|
|
DATABASE_FILES:
|
|
default: ''
|
|
description: Whether to handle database files
|
|
required: false
|
|
type: string
|
|
RELEASE_TYPE:
|
|
default: ''
|
|
description: Type of release (service, library, plugin, or catalog)
|
|
required: false
|
|
type: string
|
|
secrets:
|
|
CI_BOT_USERNAME:
|
|
required: true
|
|
CI_BOT_TOKEN:
|
|
required: true
|
|
|
|
jobs:
|
|
release:
|
|
runs-on: ubuntu-latest
|
|
outputs:
|
|
project-name: ${{ steps.project.outputs.name }}
|
|
release-version: ${{ steps.project.outputs.version }}
|
|
has-changes: ${{ steps.project.outputs.change }}
|
|
steps:
|
|
- name: Checkout repository
|
|
uses: actions/checkout@v4
|
|
with:
|
|
fetch-depth: 1
|
|
token: ${{ secrets.CI_BOT_TOKEN }}
|
|
- name: Set git credentials
|
|
run: |
|
|
git config --global user.name "${{ vars.BOT_NAME }}"
|
|
git config --global user.email "${{ vars.BOT_EMAIL }}"
|
|
echo "Set Git name: ${{ vars.BOT_NAME }}"
|
|
echo "Set Git email: ${{ vars.BOT_EMAIL }}"
|
|
- name: Extract project information
|
|
id: project
|
|
run: |
|
|
NAME=$(awk -F '=' '/^rootProject\.name/ { gsub(/[[:space:]]*/,"",$2); gsub(/"/,"",$2); print $2 }' settings.gradle.kts)
|
|
if [ -z "$NAME" ]; then
|
|
echo "Error: No application name found in settings.gradle.kts" >&2
|
|
exit 1
|
|
fi
|
|
VERSION=$(awk -F '=' '/^version[[:space:]]*=/{ gsub(/[[:space:]]*/,"",$2); sub(/-SNAPSHOT$/,"",$2); print $2 }' gradle.properties)
|
|
if [ -z "$VERSION" ]; then
|
|
echo "Error: No version found in gradle.properties" >&2
|
|
exit 1
|
|
fi
|
|
CHANGE="false"
|
|
if [[ $(git log -1 --pretty=%B) != *"[RELEASE] - Bump version"* ]]; then
|
|
CHANGE="true"
|
|
fi
|
|
echo "name=$NAME" >> $GITHUB_OUTPUT
|
|
echo "Extracted application name: $NAME"
|
|
echo "version=$VERSION" >> $GITHUB_OUTPUT
|
|
echo "Extracted application version: $VERSION"
|
|
echo "change=$CHANGE" >> $GITHUB_OUTPUT
|
|
echo "Has changes to release? $CHANGE"
|
|
- name: Fail workflow if there are no changes
|
|
if: steps.project.outputs.change == 'false' && inputs.FAIL_FOR_NO_CHANGES == true
|
|
run: |
|
|
echo "No changes to release, failing..."
|
|
exit 1
|
|
|
|
|
|
finalise-publish-container:
|
|
needs: release
|
|
# if: needs.release.outputs.has-changes == 'true' && inputs.TYPE == 'service'
|
|
uses: aura-ascend/common-workflows/.gitea/workflows/publish-container.yaml@master
|
|
with:
|
|
JAVA_VERSION: ${{ inputs.JAVA_VERSION }}
|
|
# PROJECT_VERSION: ${{ needs.release.outputs.release-version }}
|
|
PROJECT_VERSION: "v${{ needs.release.outputs.release-version }}"
|
|
PROJECT_NAME: ${{ needs.release.outputs.project-name }}
|
|
secrets:
|
|
CI_BOT_USERNAME: ${{ secrets.CI_BOT_USERNAME }}
|
|
CI_BOT_TOKEN: ${{ secrets.CI_BOT_TOKEN }}
|
|
|
|
# finalise-publish-artifact:
|
|
# needs: release
|
|
# if: needs.release.outputs.has-changes == 'true' && (inputs.TYPE == 'library' || inputs.TYPE == 'catalog')
|
|
# uses: aura-ascend/common-workflows/.gitea/workflows/publish-artifact.yaml@master
|
|
# with:
|
|
# JAVA_VERSION: ${{ inputs.JAVA_VERSION }}
|
|
# BRANCH_REFERENCE: "v${{ needs.release.outputs.release-version }}"
|
|
# GRADLE_TASK: publish
|
|
# secrets:
|
|
# CI_BOT_USERNAME: ${{ secrets.CI_BOT_USERNAME }}
|
|
# CI_BOT_TOKEN: ${{ secrets.CI_BOT_TOKEN }}
|
|
#
|
|
# finalise-publish-plugin:
|
|
# needs: release
|
|
# if: needs.release.outputs.has-changes == 'true' && inputs.TYPE == 'plugin'
|
|
# uses: aura-ascend/common-workflows/.gitea/workflows/publish-artifact.yaml@master
|
|
# with:
|
|
# JAVA_VERSION: ${{ inputs.JAVA_VERSION }}
|
|
# BRANCH_REFERENCE: "v${{ needs.release.outputs.release-version }}"
|
|
# GRADLE_TASK: publishAllPublicationsToGitHubPackagesRepository
|
|
# secrets:
|
|
# CI_BOT_USERNAME: ${{ secrets.CI_BOT_USERNAME }}
|
|
# CI_BOT_TOKEN: ${{ secrets.CI_BOT_TOKEN }}
|