Build/Push Medley Release #217
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
#******************************************************************************* | |
# buidLoadup.yml | |
# | |
# Interlisp workflow to build Medley release and push it to github. This workflow | |
# is platform independent - but runs on Linux/amd64. | |
# | |
# This workflow contains a sentry that causes it to skip the build (as identified | |
# by its commit SHA) if its already been done. Setting the "force" input to true | |
# will bypass this sentry, | |
# | |
# 2022-01-17 Frank Halasz based on an earlier version of buildLoadup for Medley. | |
# | |
# Copyright 2022-2023 by Interlisp.org | |
# | |
# ****************************************************************************** | |
name: Build/Push Medley 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: | |
outputs: | |
successful: | |
description: "'True' if medley 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' | |
secrets: | |
OIO_SSH_KEY: | |
required: true | |
defaults: | |
run: | |
shell: bash | |
jobs: | |
# JOB: inputs ####################################################################### | |
# 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 }} | |
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 | |
# JOB: sentry ####################################################################### | |
# 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: "loadup" | |
# JOB: loadup ####################################################################### | |
# | |
# Do the loadup and push to release on github | |
# | |
loadup: | |
runs-on: ubuntu-latest | |
outputs: | |
combined_release_tag: ${{ steps.job_outputs.outputs.COMBINED_RELEASE_TAG }} | |
medley_release_tag: ${{ steps.job_outputs.outputs.MEDLEY_RELEASE_TAG }} | |
medley_short_release_tag: ${{ steps.job_outputs.outputs.MEDLEY_SHORT_RELEASE_TAG }} | |
debs_filename_base: ${{ steps.debs.outputs.DEBS_FILENAME_BASE }} | |
maiko_release_tag: ${{ steps.job_outputs.outputs.MAIKO_RELEASE_TAG }} | |
artifacts_filename_template: ${{ steps.job_outputs.outputs.ARTIFACTS_FILENAME_TEMPLATE }} | |
release_url: ${{ steps.push.outputs.html_url }} | |
needs: [inputs, sentry] | |
if: | | |
needs.sentry.outputs.release_not_built == 'true' | |
|| needs.inputs.outputs.force == 'true' | |
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 }} | |
# Checkout latest commit | |
- name: Checkout Medley | |
uses: actions/checkout@v4 | |
# Setup release tag | |
- name: Setup Release Tag | |
id: tag | |
uses: ./../actions/release-tag-action | |
# Get Maiko release information, retrieves the name of the latest (draft) | |
# release. Used to download the correct Maiko release | |
# Find latest release (draft or normal) | |
- name: Get maiko release information | |
id: maiko | |
run: | | |
tag="" | |
if [ "${{ needs.inputs.outputs.draft }}" = "true" ]; | |
then | |
gh release list --repo ${{ github.repository_owner }}/maiko > /tmp/releases-$$ | |
if grep Draft </tmp/releases-$$ >/tmp/draft-releases-$$; | |
then | |
tag=$(head -n 1 /tmp/draft-releases-$$ | awk '{ print $3 }') | |
fi | |
fi | |
if [ -z "${tag}" ]; | |
then | |
tag=$(gh release list --repo ${{ github.repository_owner }}/maiko | grep Latest | head -n 1 | awk '{ print $3 }') | |
fi | |
echo "maiko_tag=${tag}" >> ${GITHUB_OUTPUT} | |
env: | |
GITHUB_TOKEN: ${{ secrets.MAIKO_TOKEN }} | |
# Setup environment variables & establish job outputs | |
- name: Setup Environment Variables | |
run: | | |
echo "build_time=$(date -u +'%Y-%m-%dT%H:%M:%SZ')" >> ${GITHUB_OUTPUT} | |
echo "TARBALL_DIR=/tmp/tarballs" >>${GITHUB_ENV} | |
echo "MEDLEY_RELEASE_TAG=${RELEASE_TAG}" >>${GITHUB_ENV} | |
echo "MAIKO_RELEASE_TAG=${{ steps.maiko.outputs.maiko_tag }}" >>${GITHUB_ENV} | |
echo "ARTIFACTS_FILENAME_TEMPLATE=medley-full-@@PLATFORM@@-@@ARCH@@-@@MEDLEY.RELEASE@@_@@MAIKO.RELEASE@@" >>${GITHUB_ENV} | |
- name: More Environment Variables | |
run: | | |
echo "MEDLEY_SHORT_RELEASE_TAG=${MEDLEY_RELEASE_TAG#medley-}" >>${GITHUB_ENV} | |
echo "MAIKO_SHORT_RELEASE_TAG=${MAIKO_RELEASE_TAG#maiko-}" >>${GITHUB_ENV} | |
- name: Even More Environment Variables | |
run: | | |
echo "COMBINED_RELEASE_TAG=${MEDLEY_SHORT_RELEASE_TAG}_${MAIKO_SHORT_RELEASE_TAG}" >>${GITHUB_ENV} | |
- name: Establish job outputs | |
id: job_outputs | |
run: | | |
echo "COMBINED_RELEASE_TAG=${COMBINED_RELEASE_TAG}" >> ${GITHUB_OUTPUT} | |
echo "MEDLEY_RELEASE_TAG=${MEDLEY_RELEASE_TAG}" >> ${GITHUB_OUTPUT} | |
echo "MEDLEY_SHORT_RELEASE_TAG=${MEDLEY_SHORT_RELEASE_TAG}" >> ${GITHUB_OUTPUT} | |
echo "MAIKO_RELEASE_TAG=${MAIKO_RELEASE_TAG}" >> $GITHUB_OUTPUT; | |
echo "ARTIFACTS_FILENAME_TEMPLATE=${ARTIFACTS_FILENAME_TEMPLATE}" >> ${GITHUB_OUTPUT} | |
# Setup some needed dirs in workspace | |
- name: Create work dirs | |
run: mkdir -p ${TARBALL_DIR} | |
# Download Maiko Release Assets and untar it | |
- name: Download Release Assets | |
run: | | |
gh release download ${MAIKO_RELEASE_TAG} \ | |
-D ${TARBALL_DIR} \ | |
--repo ${{ github.repository_owner }}/maiko \ | |
-p '*.tgz' | |
tar -xzf "${TARBALL_DIR}/${MAIKO_RELEASE_TAG}-linux.x86_64.tgz" | |
env: | |
GITHUB_TOKEN: ${{ secrets.MAIKO_TOKEN }} | |
# Checkout Notecards and tar it in the tarballsdir | |
- name: Checkout Notecards | |
uses: actions/checkout@v4 | |
with: | |
repository: ${{ github.repository_owner }}/notecards | |
path: ./notecards | |
- name: Tar notecards into tarball dir | |
run: | | |
mv ./notecards ../notecards | |
cd ../notecards | |
git archive --format=tgz --output="${TARBALL_DIR}/notecards.tgz" --prefix=notecards/ main | |
# Install vnc | |
- name: Install vnc | |
run: sudo apt-get update && sudo apt-get install -y tightvncserver | |
- name: Build Loadup sysouts and databases | |
run: | | |
Xvnc -geometry 1280x720 :0 & | |
export DISPLAY=":0" | |
scripts/loadup-all.sh -apps | |
# scripts/loadup-db.sh | |
- name: Build release tars | |
run: | | |
scripts/release-make-tars.sh "${MEDLEY_RELEASE_TAG}" | |
mv releases/"${MEDLEY_SHORT_RELEASE_TAG}"/*.tgz "${TARBALL_DIR}" | |
# Push the release up to github releases | |
- name: Delete existing release with same tag (if any) | |
uses: cb80/delrel@latest | |
with: | |
tag: ${{ env.MEDLEY_RELEASE_TAG }} | |
continue-on-error: true | |
- name: Push the release | |
id: push | |
uses: ncipollo/release-action@v1 | |
with: | |
allowUpdates: true | |
artifacts: | |
# ${{ env.TARBALL_DIR }}/notecards.tgz, | |
${{ env.TARBALL_DIR }}/${{ env.MEDLEY_RELEASE_TAG }}-loadups.tgz, | |
${{ env.TARBALL_DIR }}/${{ env.MEDLEY_RELEASE_TAG }}-runtime.tgz | |
tag: ${{ env.MEDLEY_RELEASE_TAG }} | |
draft: ${{ needs.inputs.outputs.draft }} | |
prerelease: false | |
generateReleaseNotes: true | |
token: ${{ secrets.GITHUB_TOKEN }} | |
# Tar the installers directory for later use | |
- name: Save installers directory for later jobs | |
run: | | |
cd .. | |
tar -c -z -f ${TARBALL_DIR}/installers.tgz medley/installers | |
# Save the tarball directory for subsequent jobs | |
- name: Save tarballs | |
uses: actions/upload-artifact@v4 | |
with: | |
name: tarballs | |
path: ${{ env.TARBALL_DIR }} | |
if-no-files-found: error | |
# JOB: emscripten_installer ############################################################## | |
# | |
# Create the a tar file of the emscripten files for deplaoyment | |
# | |
emscripten_installer: | |
runs-on: ubuntu-latest | |
needs: [inputs, sentry, loadup] | |
if: | | |
needs.sentry.outputs.release_not_built == 'true' | |
|| needs.inputs.outputs.force == 'true' | |
steps: | |
# Environment variables | |
- name: Environment variables | |
run: | | |
echo "IL_DIR=/tmp/il" >>${GITHUB_ENV} | |
echo "MEDLEY_RELEASE_TAG=${{ needs.loadup.outputs.medley_release_tag }}" >>${GITHUB_ENV} | |
echo "COMBINED_RELEASE_TAG=${{ needs.loadup.outputs.combined_release_tag }}" >>${GITHUB_ENV} | |
# 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} | |
# Create working directory | |
- name: Create working directory | |
run: mkdir -p ${IL_DIR} | |
# Get the tarballs | |
- name: Get tarballs | |
uses: actions/download-artifact@v4 | |
with: | |
name: tarballs | |
path: ${{ env.IL_DIR }} | |
# Untar the tarballs | |
- name: Untar tarballs | |
run: | | |
cd ${IL_DIR} | |
tar -x -z -f *-loadups.tgz | |
tar -x -z -f *-runtime.tgz | |
tar -x -z -f notecards.tgz | |
tar -x -z -f installers.tgz | |
mkdir -p maiko/emscripten.wasm_nl | |
tar -x -z -C maiko/emscripten.wasm_nl -f maiko*emscripten.tgz | |
# Build the emscripten files | |
- name: Build emscripten files | |
run: | | |
cd ${IL_DIR}/medley/installers/emscripten | |
./em_build.sh | |
cd tar | |
mv medley-full-emscripten.tgz medley-full-emscripten-${COMBINED_RELEASE_TAG}.tgz | |
# Push the emscripten tgz up to github releases | |
- name: Push the release | |
id: push_release | |
uses: ncipollo/release-action@v1 | |
with: | |
allowUpdates: true | |
artifacts: | |
${{ env.IL_DIR }}/medley/installers/emscripten/tar/*.tgz | |
tag: ${{ env.MEDLEY_RELEASE_TAG }} | |
token: ${{ secrets.GITHUB_TOKEN }} | |
omitBodyDuringUpdate: true | |
omitDraftDuringUpdate: true | |
omitNameDuringUpdate: true | |
omitPrereleaseDuringUpdate: true | |
# JOB: complete ##################################################################### | |
# 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, loadup, emscripten_installer] | |
steps: | |
# Delete the tarballs artifact | |
- name: Delete tarballs artifact | |
uses: geekyeggo/delete-artifact@v2 | |
with: | |
name: tarballs | |
failOnError: false | |
# 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: Set flag that build for this commit has been completed | |
id: set | |
uses: ./../actions/set-sentry-action | |
with: | |
tag: "loadup" | |
- name: Output | |
id: output | |
run: | | |
echo "build_successful='true'" >> $GITHUB_OUTPUT | |
###################################################################################### | |
###################################################################################### |