Merge pull request #138 from ortus-boxlang/development #28
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
# This workflow is used to build releases | |
# It can also be called by other workflows to reuse the release flow. | |
name: Release | |
on: | |
# If you push to main this will trigger a stable release | |
push: | |
branches: | |
- master | |
- main | |
# Reusable workflow : Usually called by a `snapshot` workflow | |
workflow_call: | |
inputs: | |
snapshot: | |
description: "Is this a snapshot build?" | |
required: false | |
default: false | |
type: boolean | |
# Manual Trigger for LTS Releases | |
workflow_dispatch: | |
inputs: | |
lts: | |
description: "The LTS marker" | |
required: false | |
default: false | |
type: boolean | |
env: | |
MODULE_ID: ${{ github.event.repository.name }} | |
SNAPSHOT: ${{ inputs.snapshot || false }} | |
JDK: 21 | |
GRADLE: 8.7 | |
BUILD_ID: ${{ github.run_number }} | |
LTS: ${{ inputs.lts || false }} | |
jobs: | |
############################################# | |
# Build Snapshot or Final Release | |
############################################# | |
build: | |
name: Build & Publish Release | |
runs-on: ubuntu-latest | |
permissions: | |
checks: write | |
contents: write | |
packages: write | |
steps: | |
- name: Checkout Repository | |
uses: actions/checkout@v4 | |
- name: Setup Java | |
uses: actions/setup-java@v4 | |
with: | |
distribution: "temurin" | |
java-version: ${{ env.JDK }} | |
- name: Setup Gradle | |
uses: gradle/actions/setup-gradle@v4 | |
with: | |
gradle-version: ${{ env.GRADLE }} | |
- name: Setup Environment Variables For Build Process | |
id: current_version | |
run: | | |
TMPVERSION=$(grep '^version=' gradle.properties | cut -d'=' -f2) | |
if [[ "${{ github.ref }}" == "refs/heads/development" ]]; then | |
# Replace existing prerelease identifier with -snapshot or append -snapshot if none exists | |
TMPVERSION=$(echo $TMPVERSION | sed 's/-.*$//')-snapshot | |
fi | |
echo "VERSION=$TMPVERSION" >> $GITHUB_ENV | |
# Branche | |
echo "Github Ref is $GITHUB_REF" | |
echo "BRANCH=main" >> $GITHUB_ENV | |
# Snapshot | |
if [ $GITHUB_REF == 'refs/heads/development' ] | |
then | |
echo "BRANCH=development" >> $GITHUB_ENV | |
fi | |
- name: Update changelog [unreleased] with latest version | |
uses: thomaseizinger/keep-a-changelog-new-release@2.0.0 | |
if: env.SNAPSHOT == 'false' | |
with: | |
changelogPath: ./changelog.md | |
tag: v${{ env.VERSION }} | |
- name: Build v${{ env.VERSION }} | |
run: | | |
npm install -g markdownlint-cli | |
markdownlint changelog.md --fix | |
gradle build -x test --stacktrace --console=plain | |
- name: Commit Changelog [unreleased] with latest version | |
uses: EndBug/add-and-commit@v9.1.4 | |
if: env.SNAPSHOT == 'false' | |
with: | |
author_name: Github Actions | |
author_email: info@ortussolutions.com | |
message: "Finalized changelog for v${{ env.VERSION }}" | |
add: changelog.md | |
- name: Tag Version | |
uses: rickstaa/action-create-tag@v1.7.2 | |
if: env.SNAPSHOT == 'false' | |
with: | |
tag: "v${{ env.VERSION }}" | |
force_push_tag: true | |
message: "Latest Release v${{ env.VERSION }}" | |
- name: Upload Build Artifacts | |
if: success() | |
uses: actions/upload-artifact@v4 | |
with: | |
name: boxlang-build | |
path: | | |
build/reports/tests/** | |
changelog.md | |
- name: Upload Distributions to S3 | |
uses: jakejarvis/s3-sync-action@master | |
with: | |
args: --acl public-read | |
env: | |
AWS_S3_BUCKET: "downloads.ortussolutions.com" | |
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY }} | |
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_ACCESS_SECRET }} | |
SOURCE_DIR: "build/distributions" | |
DEST_DIR: "ortussolutions/boxlang/${{ env.VERSION }}" | |
- name: Upload Evergreen Distributions to S3 | |
uses: jakejarvis/s3-sync-action@master | |
with: | |
args: --acl public-read | |
env: | |
AWS_S3_BUCKET: "downloads.ortussolutions.com" | |
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY }} | |
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_ACCESS_SECRET }} | |
SOURCE_DIR: "build/evergreen" | |
DEST_DIR: "ortussolutions/boxlang/" | |
- name: Upload API Docs to S3 | |
uses: jakejarvis/s3-sync-action@master | |
with: | |
args: --acl public-read | |
env: | |
AWS_S3_BUCKET: "apidocs.ortussolutions.com" | |
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY }} | |
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_ACCESS_SECRET }} | |
SOURCE_DIR: "build/docs/javadoc" | |
DEST_DIR: "boxlang/${{ env.VERSION }}" | |
# Publish to Maven Central + Github ONLY on Beta/Final Releases | |
- name: Publish Package (Maven+Github) | |
if: env.SNAPSHOT == 'false' | |
run: | | |
gradle publish --no-daemon --no-parallel | |
gradle publishAllPublicationsToCentralPortal | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
GPG_KEY: ${{ secrets.GPG_KEY }} | |
GPG_PASSWORD: ${{ secrets.GPG_PASSWORD }} | |
MAVEN_USERNAME: ${{ secrets.MAVEN_USERNAME }} | |
MAVEN_PASSWORD: ${{ secrets.MAVEN_PASSWORD }} | |
- name: Create Github Release | |
uses: taiki-e/create-gh-release-action@v1.8.0 | |
continue-on-error: true | |
if: env.SNAPSHOT == 'false' | |
id: create_release | |
with: | |
title: ${{ env.VERSION }} | |
changelog: changelog.md | |
token: ${{ secrets.GITHUB_TOKEN }} | |
ref: refs/tags/v${{ env.VERSION }} | |
- name: Inform Slack | |
if: ${{ always() }} | |
uses: rtCamp/action-slack-notify@v2 | |
env: | |
SLACK_CHANNEL: coding | |
SLACK_COLOR: ${{ job.status }} # or a specific color like 'green' or '#ff00ff' | |
SLACK_ICON_EMOJI: ":bell:" | |
SLACK_MESSAGE: "BoxLang ${{ env.VERSION }} Built with ${{ job.status }}!" | |
SLACK_TITLE: "BoxLang Build" | |
SLACK_USERNAME: CI | |
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_URL }} | |
########################################################################################## | |
# Prep Next Release | |
########################################################################################## | |
prep_next_release: | |
name: Prep Next Release | |
if: github.ref != 'refs/heads/development' | |
runs-on: ubuntu-latest | |
needs: [build] | |
permissions: | |
checks: write | |
contents: write | |
steps: | |
- name: Checkout Development Repository | |
uses: actions/checkout@v4 | |
if: env.LTS == 'false' | |
with: | |
ref: development | |
- name: Checkout LTS Repository | |
uses: actions/checkout@v4 | |
if: env.LTS == 'true' | |
- name: Download build artifacts | |
uses: actions/download-artifact@v4 | |
with: | |
name: boxlang-build | |
path: .tmp | |
- name: Setup Gradle | |
uses: gradle/actions/setup-gradle@v4 | |
with: | |
gradle-version: ${{ env.GRADLE }} | |
- name: Copy Changelog | |
run: | | |
cp .tmp/changelog.md changelog.md | |
- name: Bump Version | |
run: | | |
if [ $LTS == 'true' ] | |
then | |
gradle bumpPatchVersion --stacktrace --console=plain | |
else | |
gradle bumpBetaVersion --stacktrace --console=plain | |
fi | |
git pull | |
- name: Commit Version Bump | |
uses: EndBug/add-and-commit@v9.1.4 | |
with: | |
author_name: Github Actions | |
author_email: info@ortussolutions.com | |
message: "Version bump" | |
add: | | |
gradle.properties | |
changelog.md |