Main Build #101
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
name: Main Build | |
on: | |
# If you push to master|main this will trigger a stable release. Else, a snapshot. | |
push: | |
branches: | |
- master | |
- main | |
- development | |
- release/** | |
workflow_dispatch: | |
# Reusable workflow : Usually called by a `snapshot` workflow | |
workflow_call: | |
env: | |
SNAPSHOT: ${{ github.ref_name != 'main' && github.ref_name != 'master' }} | |
PROJECT_NAME: Ortus Lucee Extensions - ORM | |
EXTENSION_SLUG: ortus-orm-extension | |
AWS_BUCKETNAME: downloads.ortussolutions.com | |
ARTIFACTS_DIRECTORY: artifacts | |
jobs: | |
security: | |
uses: ./.github/workflows/security.yml | |
secrets: inherit | |
tests: | |
if: "!contains(github.event.head_commit.message, '[ci skip]')" | |
uses: ./.github/workflows/tests.yml | |
format: | |
if: "!contains(github.event.head_commit.message, '[ci skip]') && github.ref_name != 'main' && github.ref_name != 'master'" | |
uses: ./.github/workflows/format.yml | |
release: | |
runs-on: ubuntu-latest | |
needs: [ tests ] | |
if: "!contains(github.event.head_commit.message, '[ci skip]')" | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up JDK | |
uses: actions/setup-java@v4 | |
with: | |
java-version: '8' | |
distribution: 'temurin' | |
- name: Read version | |
id: current_version | |
run: | | |
export PACKAGE_VERSION=$( cat box.json | jq '.version' -r ) | |
echo "EXTENSION_VERSION=$PACKAGE_VERSION" >> $GITHUB_ENV | |
echo "BRANCH=master" >> $GITHUB_ENV | |
echo "BUILD_VERSION=$PACKAGE_VERSION" >> $GITHUB_ENV | |
if [ $SNAPSHOT == 'true' ] | |
then | |
echo "BUILD_VERSION=$PACKAGE_VERSION.${{ github.run_number}}-snapshot" >> $GITHUB_ENV | |
fi | |
- name: Check changelog for this version | |
if: env.SNAPSHOT == 'false' | |
id: changelog_check | |
run: | | |
if grep -q "${{ env.EXTENSION_VERSION }}" CHANGELOG.md;then | |
echo "HAS_VERSION=true" >> $GITHUB_OUTPUT | |
else | |
echo "HAS_VERSION=false" >> $GITHUB_OUTPUT | |
fi | |
- name: Update changelog [unreleased] with latest version | |
uses: thomaseizinger/[email protected] | |
if: "steps.changelog_check.outputs.HAS_VERSION == 'false' && env.SNAPSHOT == 'false'" | |
with: | |
changelogPath: ./CHANGELOG.md | |
tag: ${{ env.EXTENSION_VERSION }} | |
- name: Commit Changelog | |
uses: EndBug/[email protected] | |
if: "steps.changelog_check.outputs.HAS_VERSION == 'false' && env.SNAPSHOT == 'false'" | |
with: | |
author_name: Github Actions | |
author_email: [email protected] | |
message: 'π DOC: Finalized changelog for v${{ env.EXTENSION_VERSION }} - [ci skip]' | |
add: CHANGELOG.md | |
- name: Set temporary (snapshot) version in pom.xml | |
if: env.SNAPSHOT == 'true' | |
run: sed -i -e "s/${{ env.EXTENSION_VERSION }}/${{ env.BUILD_VERSION }}/g" pom.xml | |
- name: Generate Javadocs | |
if: env.SNAPSHOT == 'false' | |
run: mvn --batch-mode -f pom.xml javadoc:javadoc | |
- name: Upload API Docs to S3 | |
uses: jakejarvis/s3-sync-action@master | |
if: env.SNAPSHOT == 'false' | |
with: | |
args: --acl public-read | |
env: | |
AWS_S3_BUCKET: ${{ secrets.AWS_APIDOCS_BUCKET }} | |
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY }} | |
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_ACCESS_SECRET }} | |
SOURCE_DIR: "target/apidocs" | |
DEST_DIR: "lucee/hibernate-extension/${{ env.BUILD_VERSION }}/" | |
- name: Build with Maven | |
run: mvn --batch-mode -f pom.xml package | |
- name: Upload Artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: ortus_orm_${{ env.BUILD_VERSION }}.lex | |
path: target/*.lex | |
- run: | | |
mkdir .tmp/ | |
mv target/*.lex .tmp/ | |
- name: Upload Artifact to S3 | |
uses: jakejarvis/s3-sync-action@master | |
with: | |
args: --acl public-read | |
env: | |
AWS_S3_BUCKET: ${{ secrets.AWS_DOWNLOADS_BUCKET }} | |
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY }} | |
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_ACCESS_SECRET }} | |
SOURCE_DIR: ".tmp/" | |
DEST_DIR: "ortussolutions/lucee-extensions/ortus-orm/${{ env.BUILD_VERSION }}/" | |
- name: Setup CommandBox | |
uses: Ortus-Solutions/setup-commandbox@main | |
with: | |
forgeboxAPIKey: ${{ secrets.FORGEBOX_API_TOKEN }} | |
- run: | | |
box package set version=${{ env.BUILD_VERSION }} | |
box package set location="https://s3.amazonaws.com/${{ env.AWS_BUCKETNAME }}/ortussolutions/lucee-extensions/ortus-orm/${{ env.BUILD_VERSION }}/ortus_orm_${{ env.BUILD_VERSION }}.lex" | |
box publish | |
- name: Tag Version | |
uses: rickstaa/[email protected] | |
if: env.SNAPSHOT == 'false' | |
with: | |
tag: "v${{ env.BUILD_VERSION }}" | |
force_push_tag: true | |
tag_exists_error: false | |
message: "Release v${{ env.BUILD_VERSION }}" | |
- name: Check whether a Slack Webhook is Configured | |
id: webhook_configured | |
env: | |
WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} | |
run: | | |
echo "HAS_WEBHOOK=${{ env.WEBHOOK_URL != '' }}" >> $GITHUB_OUTPUT | |
- name: Inform Slack | |
if: ${{ steps.webhook_configured.outputs.HAS_WEBHOOK == 'true' && failure() }} | |
uses: rtCamp/action-slack-notify@v2 | |
env: | |
SLACK_CHANNEL: ortus-hibernate-extension | |
SLACK_COLOR: ${{ job.status }} # or a specific color like 'green' or '#ff00ff' | |
SLACK_ICON_EMOJI: ":bell:" | |
SLACK_MESSAGE: '${{ env.EXTENSION_SLUG }} v${{ env.BUILD_VERSION }} ( ${{ github.ref_name }} ) failed :cry:' | |
SLACK_TITLE: "${{ env.PACKAGE_NAME }} Build" | |
SLACK_USERNAME: CI | |
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_URL }} |