Skip to content

Download Archived Installers #29

Download Archived Installers

Download Archived Installers #29

name: 'Download Archived Installers'
on:
workflow_dispatch:
inputs:
ballerina-version:
description: 'Ballerina Version'
required: true
options:
- 'nightly'
- 'nightly-2201.9.x'
- 'nightly-2201.8.x'
- 'nightly-2201.7.x'
default: 'nightly-2201.9.x'
jobs:
install-archived-installer:
name: Install Archived Installers
runs-on: windows-latest
# runs-on: ${{ matrix.os }}
# strategy:
# matrix:
# os: [ubuntu-latest, windows-latest, macos-latest]
steps:
- name: Get Installer Download URL
id: get-installer-url
run: |
BALLERINA_VERSION=${{ github.event.inputs.ballerina-version }}
DAILY_BUILD_VERSION=${BALLERINA_VERSION//nightly/daily-build}
if [[ $OSTYPE == 'msys'* ]]; then
echo "windows runner detected"
ARTIFACT_NAME="Windows Installer msi"
GITHUB_RUN_ID=$(curl -H "Authorization: token $GITHUB_TOKEN" -H "Accept: application/vnd.github.v3+json" \
"https://api.github.com/repos/ballerina-platform/ballerina-distribution/actions/workflows/$DAILY_BUILD_VERSION.yml/runs?status=success&per_page=1" | jq '.workflow_runs[0].id')
DOWNLOAD_URL=$(curl -H "Authorization: token $GITHUB_TOKEN" \
-H "Accept: application/vnd.github.v3+json" \
"https://api.github.com/repos/ballerina-platform/ballerina-distribution/actions/runs/$GITHUB_RUN_ID/artifacts" | jq -r --arg name "$ARTIFACT_NAME" '.artifacts[] | select(.name == $name) | .archive_download_url')
curl -H "Authorization: token $GITHUB_TOKEN" \
-L -o artifact.zip $DOWNLOAD_URL
unzip -q artifact.zip
elif [[ $OSTYPE == 'darwin'* ]]; then
echo "macos runner detected"
ARTIFACT_NAME="MacOS Installer pkg"
GITHUB_RUN_ID=$(curl -H "Authorization: token $GITHUB_TOKEN" -H "Accept: application/vnd.github.v3+json" \
"https://api.github.com/repos/ballerina-platform/ballerina-distribution/actions/workflows/$DAILY_BUILD_VERSION.yml/runs?status=success&per_page=1" | jq '.workflow_runs[0].id')
DOWNLOAD_URL=$(curl -H "Authorization: token $GITHUB_TOKEN" \
-H "Accept: application/vnd.github.v3+json" \
"https://api.github.com/repos/ballerina-platform/ballerina-distribution/actions/runs/$GITHUB_RUN_ID/artifacts" | jq -r --arg name "$ARTIFACT_NAME" '.artifacts[] | select(.name == $name) | .archive_download_url')
curl -H "Authorization: token $GITHUB_TOKEN" \
-L -o artifact.zip $DOWNLOAD_URL
unzip -q artifact.zip
else
echo "ubuntu runner detected"
ARTIFACT_NAME="Linux Installer deb"
GITHUB_RUN_ID=$(curl -H "Authorization: token $GITHUB_TOKEN" -H "Accept: application/vnd.github.v3+json" \
"https://api.github.com/repos/ballerina-platform/ballerina-distribution/actions/workflows/$DAILY_BUILD_VERSION.yml/runs?status=success&per_page=1" | jq '.workflow_runs[0].id')
DOWNLOAD_URL=$(curl -H "Authorization: token $GITHUB_TOKEN" \
-H "Accept: application/vnd.github.v3+json" \
"https://api.github.com/repos/ballerina-platform/ballerina-distribution/actions/runs/$GITHUB_RUN_ID/artifacts" | jq -r --arg name "$ARTIFACT_NAME" '.artifacts[] | select(.name == $name) | .archive_download_url')
curl -H "Authorization: token $GITHUB_TOKEN" \
-L -o artifact.zip $DOWNLOAD_URL
unzip -q artifact.zip
fi
shell: bash
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Install Ballerina
run: |
set -x
if [[ $OSTYPE == 'msys'* ]]; then
echo "windows runner detected"
INSTALLER_PATH=$(dir ballerina-*-windows-x64.msi)
msiexec //i $INSTALLER_PATH //qn
echo "BALLERINA_HOME=C:\\Program Files\\Ballerina\\" >> $GITHUB_ENV
cmd $env:Path += ";C:\Program Files\Ballerina\bin"
elif [[ $OSTYPE == 'darwin'* ]]; then
echo "macos runner detected"
INSTALLER_PATH=$(ls ./ballerina-*-macos-x64.pkg)
sudo installer -pkg $INSTALLER_PATH -target /Library
echo "BALLERINA_HOME=/Library/Ballerina" >> $GITHUB_ENV
echo "/Library/Ballerina/bin" >> $GITHUB_PATH
else
echo "ubuntu runner detected"
INSTALLER_PATH=$(ls ./ballerina-*-linux-x64.deb)
if [ "$(id --user)" -eq "0" ]; then
sudocmd=""
else
sudocmd="sudo"
fi
$sudocmd dpkg -i $INSTALLER_PATH
echo "BALLERINA_HOME=/usr/lib/ballerina" >> $GITHUB_ENV
echo "/usr/lib/ballerina/bin" >> $GITHUB_PATH
fi
shell: bash
- name: Verify Installation
run: |
bal -v