Skip to content

Release

Release #712

Workflow file for this run

name: Release
on:
push:
branches:
- main
- development
tags:
- v*
workflow_dispatch:
inputs:
version:
required: true
# Cancel running builds if another push to branch is made while this build is running
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
env:
BOXLANG_VERSION: 1.0.0-20
IMAGE_VERSION: 1.0.0
# if 'development' it's true, then it's a snapshot build
SNAPSHOT: ${{ github.ref == 'refs/heads/development' }}
BUILD_ID: ${{ github.run_number }}
jobs:
#############################################
# Build Snapshot or Final Release
#############################################
build:
name: Build & Publish Release
runs-on: ubuntu-latest
permissions:
checks: write
contents: write
strategy:
matrix:
include:
# Alpine builds
# Disabling CLI builds temporarily
- BUILD_IMAGE_DOCKERFILE: builds/base/JDK21.Dockerfile
BUILD_IMAGE_TAG: cli
- BUILD_IMAGE_DOCKERFILE: builds/base/JDK21.Web.Dockerfile
BUILD_IMAGE_TAG: miniserver
- BUILD_IMAGE_DOCKERFILE: builds/base/Alpine.JDK21.Dockerfile
BUILD_IMAGE_TAG: cli-alpine
- BUILD_IMAGE_DOCKERFILE: builds/base/Alpine.JDK21.Web.Dockerfile
BUILD_IMAGE_TAG: miniserver-alpine
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up QEMU
uses: docker/setup-qemu-action@master
with:
platforms: all
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@master
- name: Setup Builds
id: setup
env:
DOCKER_IMAGE: ortussolutions/boxlang
BUILD_IMAGE_TAG: ${{ matrix.BUILD_IMAGE_TAG }}
run: |
# Tag Builds
if [[ $GITHUB_REF == refs/tags/* ]]; then
if [[ $BUILD_IMAGE_TAG == latest ]]; then
BUILD_IMAGE_TAG="${GITHUB_REF#refs/tags/v}"
else
BUILD_IMAGE_TAG="${BUILD_IMAGE_TAG}-${GITHUB_REF#refs/tags/v}"
fi
elif [[ $GITHUB_REF == 'refs/heads/development' ]]; then
# Snapshot builds
BUILD_IMAGE_TAG="${BUILD_IMAGE_TAG}-snapshot"
fi
TAGS="${DOCKER_IMAGE}:${BUILD_IMAGE_TAG}"
if [[ ${BUILD_IMAGE_TAG} == *"alpine"* ]]; then
ARCH_PLATFORMS=linux/amd64
else
ARCH_PLATFORMS=linux/amd64,linux/arm64/v8
fi
# Set output parameters.
echo "arch_platforms=${ARCH_PLATFORMS}" >> $GITHUB_ENV
echo "image_version=${IMAGE_VERSION}" >> $GITHUB_ENV
echo "boxlang_version=${BOXLANG_VERSION}" >> $GITHUB_ENV
echo "IMAGE_TAG=${TAGS}" >> $GITHUB_ENV
- name: DockerHub Login
if: github.event_name != 'pull_request'
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
# - name: Test
# env:
# boxlang_VERSION: ${{ env.BOXLANG_VERSION }}
# DOCKER_BUILDKIT: 1
# COMPOSE_DOCKER_CLI_BUILD: 1
# BUILD_IMAGE_DOCKERFILE: ${{ matrix.BUILD_IMAGE_DOCKERFILE }}
# run: |
# docker compose -f docker-compose.test.yml up --build --exit-code-from sut
# docker compose -f docker-compose.secret-test.yml up --build --exit-code-from sut
- name: Build Final
uses: docker/build-push-action@v5
env:
DOCKER_BUILDKIT: 1
with:
provenance: false
builder: ${{ steps.buildx.outputs.name }}
context: .
file: ${{ matrix.BUILD_IMAGE_DOCKERFILE }}
build-args: BOXLANG_VERSION=${{ env.boxlang_version }}
platforms: ${{ env.arch_platforms }}
push: true
tags: ${{ env.IMAGE_TAG }}
#############################################
# Build Snapshot or Final Release
#############################################
artifacts:
name: Publish Release Artifacts
if: github.ref != 'refs/heads/development'
runs-on: ubuntu-latest
permissions:
checks: write
contents: write
needs: build
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Update changelog [unreleased] with latest version
uses: thomaseizinger/[email protected]
if: env.SNAPSHOT == 'false'
with:
changelogPath: ./changelog.md
tag: v${{ env.IMAGE_VERSION }}
- name: Fix Markdown Linting
run: |
npm install -g markdownlint-cli
markdownlint changelog.md --fix
- name: Commit Changelog [unreleased] with latest version
uses: EndBug/[email protected]
if: env.SNAPSHOT == 'false'
with:
author_name: Github Actions
author_email: [email protected]
message: "Finalized changelog for v${{ env.IMAGE_VERSION }}"
add: changelog.md
- name: Tag Version
uses: rickstaa/[email protected]
if: env.SNAPSHOT == 'false'
with:
tag: "v${{ env.IMAGE_VERSION }}"
force_push_tag: true
message: "Latest Release v${{ env.IMAGE_VERSION }}"
- name: Create Github Release
uses: taiki-e/[email protected]
continue-on-error: true
if: env.SNAPSHOT == 'false'
id: create_release
with:
title: ${{ env.IMAGE_VERSION }}
changelog: changelog.md
token: ${{ secrets.GITHUB_TOKEN }}
ref: refs/tags/v${{ env.IMAGE_VERSION }}