Skip to content

Build/Push Release

Build/Push Release #57

Workflow file for this run

#*******************************************************************************
# buidRelease.yml
#
# Workflow to build a Maiko release that is pushed to github.
# For linux: release assets are built/pushed for X86_64, aarch64 and arm7vl.
# For macOS: release assets are built/pushed for X86_64 and aarch64 as well as
# a set of universal binaries.
# For Windows: not supported
#
# Note release pushed to github automatically includes source code assets
# in tar and zip formats.
#
# 2022-01-16 by Frank Halasz based on earlier workflow called buildDocker.yml
# Updated 2023-06-06: Remove docker image push; increase build efficeincy for linux
#
# Copyright 2022-2023 by Interlisp.org
#
#
# ******************************************************************************
name: 'Build/Push Release'
# Run this workflow on ...
on:
workflow_dispatch:
inputs:
draft:
description: "Mark this as a draft release"
type: choice
options:
- 'false'
- 'true'
force:
description: "Force build even if build already successfully completed for this commit"
type: choice
options:
- 'false'
- 'true'
workflow_call:
secrets:
DOCKER_USERNAME:
required: true
DOCKER_PASSWORD:
required: true
outputs:
successful:
description: "'True' if maiko build completed successully"
value: ${{ jobs.complete.outputs.build_successful }}
inputs:
draft:
description: "Mark this as a draft release"
required: false
type: string
default: 'false'
force:
description: "Force build even if build already successfully completed for this commit"
required: false
type: string
default: 'false'
defaults:
run:
shell: bash
# 3 separate jobs here that can run in parallel
#
# 1. Linux: Build a multiplatform Linux Docker file system (not saved) and use
# results to build/push Linux release assets.
#
# 2. MacOs: Build maiko for MacOS (x86_64, aarch64, and universal) then create
# and push release assets.
#
# 3. Windows: Build maiko for cygwin and SDL (x86_64). Build is done within the
# cygwin-maiko-builder Docker image by building a new docker files system (and
# not a docker container) which is used to build/push Windows(cygwin) assets.
#
jobs:
######################################################################################
# Regularize the inputs so they can be referenced the same way whether they are
# the result of a workflow_dispatch or a workflow_call
inputs:
runs-on: ubuntu-latest
outputs:
draft: ${{ steps.one.outputs.draft }}
force: ${{ steps.one.outputs.force }}
linux: ${{ steps.one.outputs.linux }}
macos: ${{ steps.one.outputs.macos }}
windows: ${{ steps.one.outputs.windows }}
steps:
- id: one
run: >
if [ '${{ toJSON(inputs) }}' = 'null' ];
then
echo "workflow_dispatch";
echo "draft=${{ github.event.inputs.draft }}" >> $GITHUB_OUTPUT;
echo "force=${{ github.event.inputs.force }}" >> $GITHUB_OUTPUT;
else
echo "workflow_call";
echo "draft=${{ inputs.draft }}" >> $GITHUB_OUTPUT;
echo "force=${{ inputs.force }}" >> $GITHUB_OUTPUT;
fi;
echo "linux=true" >> $GITHUB_OUTPUT;
echo "macos=true" >> $GITHUB_OUTPUT;
echo "windows=true" >> $GITHUB_OUTPUT;
######################################################################################
# Use sentry-action to determine if this release has already been built
# based on the latest commit to the repo
sentry:
needs: inputs
runs-on: ubuntu-latest
outputs:
release_not_built: ${{ steps.check.outputs.release_not_built }}
steps:
# Checkout the actions for this repo owner
- name: Checkout Actions
uses: actions/checkout@v4
with:
repository: ${{ github.repository_owner }}/.github
path: ./Actions_${{ github.sha }}
- run: mv ./Actions_${{ github.sha }}/actions ../actions && rm -rf ./Actions_${{ github.sha }}
# Check if build already run for this commit
- name: Build already completed?
id: check
continue-on-error: true
uses: ./../actions/check-sentry-action
with:
tag: "release_docker"
######################################################################################
# Emscripten: build and push Maiko compiled for Emscripten (to run Maiko in browser)
emscripten:
needs: [inputs, sentry]
if: |
needs.inputs.outputs.linux == 'true'
&& (
needs.sentry.outputs.release_not_built == 'true'
|| needs.inputs.outputs.force == 'true'
)
runs-on: ubuntu-latest
steps:
# Checkout the actions for this repo owner
- name: Checkout Actions
uses: actions/checkout@v4
with:
repository: ${{ github.repository_owner }}/.github
path: ./Actions_${{ github.sha }}
- run: mv ./Actions_${{ github.sha }}/actions ../actions && rm -rf ./Actions_${{ github.sha }}
# Install SDL2
- name: Install SDL2
run: |
export DEBIAN_FRONTEND=noninteractive
sudo -E apt-get install -y libsdl2-dev libsdl2-2.0-0
# Install Emscripten SDK
- name: Install Empscripten
working-directory: ../
run: |
git clone https://github.com/emscripten-core/emsdk.git
cd emsdk
./emsdk install latest
./emsdk activate latest
CWD="$(pwd)"
echo "${CWD}" >> ${GITHUB_PATH}
echo "${CWD}/upstream/emscripten" >> ${GITHUB_PATH}
echo "${CWD}/upstream/emscripten/tools" >> ${GITHUB_PATH}
echo "${CWD}/node/$(ls -d node/*64bit | tail -1)/bin" >> ${GITHUB_PATH}
# Checkout the maiko branch
- name: Checkout
uses: actions/checkout@v4
# Setup release tag
- name: Setup Release Tag
id: tag
uses: ./../actions/release-tag-action
# Compile maiko using Emscripten (no load build)
- name: Compile Maiko using Emscripten
working-directory: ./bin
run: |
./makeright wasm_nl
cd ../emscripten.wasm_nl
tar -c -z -f ../${{ steps.tag.outputs.release_tag }}-emscripten.tgz *
# Push Release to github
- name: Push the release
uses: ncipollo/release-action@v1
with:
allowUpdates: true
artifacts: ${{ steps.tag.outputs.release_tag }}-emscripten.tgz
tag: ${{ steps.tag.outputs.release_tag }}
draft: ${{ needs.inputs.outputs.draft }}
token: ${{ secrets.GITHUB_TOKEN }}
######################################################################################
# Use set-sentry-action to determine set the sentry that says this release has
# been successfully built
complete:
runs-on: ubuntu-latest
outputs:
build_successful: ${{ steps.output.outputs.build_successful }}
needs: [inputs, sentry, emscripten]
steps:
# Checkout the actions for this repo owner
- name: Checkout Actions
uses: actions/checkout@v4
with:
repository: ${{ github.repository_owner }}/.github
path: ./Actions_${{ github.sha }}
- run: mv ./Actions_${{ github.sha }}/actions ../actions && rm -rf ./Actions_${{ github.sha }}
# Set sentry
- name: Is build for this commit already completed?
id: set
uses: ./../actions/set-sentry-action
with:
tag: "release_docker"
- name: Output
id: output
run: |
echo "build_successful=true" >> $GITHUB_OUTPUT
######################################################################################