Merge pull request #129 from ndigitals/develop #70
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: release-build | |
on: | |
workflow_dispatch: | |
push: | |
branches: | |
- main | |
env: | |
OLS_VERSION: 1.7.18 | |
PHP_STABLE_VERSION: '8.2.12' | |
REGISTRY: ghcr.io | |
jobs: | |
buildx: | |
runs-on: self-hosted | |
strategy: | |
fail-fast: false | |
matrix: | |
PHP_VERSION: ['8.0.30','8.1.24','8.2.12'] | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 # Required due to the way Git works, without it this action won't be able to find any or the correct tags | |
# https://github.com/marketplace/actions/docker-setup-buildx | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
# https://github.com/marketplace/actions/docker-login | |
- name: Login to GitHub Packages | |
uses: docker/login-action@v3 | |
with: | |
registry: ${{ env.REGISTRY }} | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
logout: false | |
# https://github.com/orgs/community/discussions/26625#discussioncomment-3252582 | |
- name: Determine OLS Major/Minor Version | |
id: ols-version | |
run: | | |
_0=$(echo ${{ env.OLS_VERSION }} | cut -d. -f1) | |
_1=$(echo ${{ env.OLS_VERSION }} | cut -d. -f2) | |
echo "_0=$_0" >> $GITHUB_OUTPUT | |
echo "_1=$_1" >> $GITHUB_OUTPUT | |
# https://github.com/orgs/community/discussions/26625#discussioncomment-3252582 | |
- name: Determine PHP Major/Minor Version | |
id: php-version | |
run: | | |
_0=$(echo ${{ matrix.PHP_VERSION }} | cut -d. -f1) | |
_1=$(echo ${{ matrix.PHP_VERSION }} | cut -d. -f2) | |
echo "_0=$_0" >> $GITHUB_OUTPUT | |
echo "_1=$_1" >> $GITHUB_OUTPUT | |
# https://github.com/marketplace/actions/build-and-push-docker-images | |
- name: Build and Push Docker Image | |
uses: docker/build-push-action@v5 | |
if: matrix.PHP_VERSION != env.PHP_STABLE_VERSION | |
with: | |
context: template | |
platforms: linux/arm64 | |
provenance: false | |
build-args: | | |
OLS_VERSION=${{ env.OLS_VERSION }} | |
PHP_VERSION=${{ matrix.PHP_VERSION }} | |
PHP_MAJOR_VERSION=${{ steps.php-version.outputs._0 }} | |
PHP_MINOR_VERSION=${{ steps.php-version.outputs._1 }} | |
push: true | |
tags: | | |
${{ env.REGISTRY }}/ndigitals/openlitespeed:${{ env.OLS_VERSION }}-lsphp${{ steps.php-version.outputs._0 }}${{ steps.php-version.outputs._1 }} | |
${{ env.REGISTRY }}/ndigitals/openlitespeed:${{ steps.ols-version.outputs._0 }}.${{ steps.ols-version.outputs._1 }}-lsphp${{ steps.php-version.outputs._0 }}${{ steps.php-version.outputs._1 }} | |
${{ env.REGISTRY }}/ndigitals/openlitespeed:${{ steps.ols-version.outputs._0 }}-lsphp${{ steps.php-version.outputs._0 }}${{ steps.php-version.outputs._1 }} | |
${{ env.REGISTRY }}/ndigitals/openlitespeed:lsphp${{ steps.php-version.outputs._0 }}${{ steps.php-version.outputs._1 }} | |
no-cache: ${{ github.event_name == 'workflow_dispatch' && true || false }} | |
cache-from: type=registry,ref=${{ env.REGISTRY }}/ndigitals/openlitespeed:latest | |
cache-to: type=inline | |
# https://github.com/marketplace/actions/build-and-push-docker-images | |
- name: Build and Push Docker Image - latest | |
uses: docker/build-push-action@v5 | |
if: matrix.PHP_VERSION == env.PHP_STABLE_VERSION | |
with: | |
context: template | |
platforms: linux/arm64 | |
provenance: false | |
build-args: | | |
OLS_VERSION=${{ env.OLS_VERSION }} | |
PHP_VERSION=${{ matrix.PHP_VERSION }} | |
PHP_MAJOR_VERSION=${{ steps.php-version.outputs._0 }} | |
PHP_MINOR_VERSION=${{ steps.php-version.outputs._1 }} | |
push: true | |
tags: | | |
${{ env.REGISTRY }}/ndigitals/openlitespeed:${{ env.OLS_VERSION }}-lsphp${{ steps.php-version.outputs._0 }}${{ steps.php-version.outputs._1 }} | |
${{ env.REGISTRY }}/ndigitals/openlitespeed:${{ steps.ols-version.outputs._0 }}.${{ steps.ols-version.outputs._1 }}-lsphp${{ steps.php-version.outputs._0 }}${{ steps.php-version.outputs._1 }} | |
${{ env.REGISTRY }}/ndigitals/openlitespeed:${{ steps.ols-version.outputs._0 }}-lsphp${{ steps.php-version.outputs._0 }}${{ steps.php-version.outputs._1 }} | |
${{ env.REGISTRY }}/ndigitals/openlitespeed:lsphp${{ steps.php-version.outputs._0 }}${{ steps.php-version.outputs._1 }} | |
${{ env.REGISTRY }}/ndigitals/openlitespeed:latest | |
no-cache: ${{ github.event_name == 'workflow_dispatch' && true || false }} | |
cache-from: type=registry,ref=${{ env.REGISTRY }}/ndigitals/openlitespeed:latest | |
cache-to: type=inline | |
# https://github.com/marketplace/actions/semver-conventional-commits | |
- name: Get Versions | |
id: semver | |
uses: ietf-tools/semver-action@v1 | |
if: matrix.PHP_VERSION == env.PHP_STABLE_VERSION && github.event_name == 'push' | |
with: | |
token: ${{ github.token }} | |
branch: main | |
- name: Create Release Name | |
id: release-name | |
if: matrix.PHP_VERSION == env.PHP_STABLE_VERSION && github.event_name == 'push' | |
run: | | |
RELEASE_NAME=$(echo ${{ steps.semver.outputs.nextStrict }} Release) | |
echo "RELEASE_NAME=$RELEASE_NAME" >> $GITHUB_OUTPUT | |
# https://github.com/marketplace/actions/universal-changelog-generator | |
- name: Generate a Changelog | |
id: changelog | |
uses: mrchief/[email protected] | |
if: matrix.PHP_VERSION == env.PHP_STABLE_VERSION && github.event_name == 'push' | |
with: | |
previousReleaseTagNameOrSha: ${{ steps.semver.outputs.current }} | |
nextReleaseTagName: 'main' | |
nextReleaseName: ${{ steps.release-name.outputs.RELEASE_NAME }} | |
# https://github.com/marketplace/actions/create-release | |
- name: Create Release | |
uses: ncipollo/[email protected] | |
if: matrix.PHP_VERSION == env.PHP_STABLE_VERSION && github.event_name == 'push' | |
with: | |
name: ${{ steps.release-name.outputs.RELEASE_NAME }} | |
tag: ${{ steps.semver.outputs.next }} | |
commit: ${{ github.sha }} | |
body: ${{ steps.changelog.outputs.changelog }} | |