Skip to content

Commit

Permalink
#52 add support for all versions
Browse files Browse the repository at this point in the history
  • Loading branch information
kernelsam committed Feb 27, 2024
1 parent 9c86d4c commit a9e1503
Show file tree
Hide file tree
Showing 9 changed files with 301 additions and 92 deletions.
4 changes: 0 additions & 4 deletions .project

This file was deleted.

35 changes: 27 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,19 @@ A GitHub Action for installing the Senzing API.
## Overview

The GitHub Action performs a
[system install](https://github.com/Senzing/knowledge-base/blob/main/WHATIS/senzing-system-installation.md)
[system install]
of the Senzing API.
The GitHub Action works where the
[RUNNER_OS](https://docs.github.com/en/actions/learn-github-actions/variables#default-environment-variables)
[RUNNER_OS]
GitHub variable is `Linux`, `macOS`, or `Windows`.

## Usage

1. An example `.github/workflows/install-senzing-example.yaml` file
which installs the latest Senzing API:
which installs the latest released Senzing API:

```yaml
name: install-senzing-example.yaml
name: install senzing example

on: [push]

Expand All @@ -28,14 +28,16 @@ GitHub variable is `Linux`, `macOS`, or `Windows`.
runs-on: ubuntu-latest
steps:
- name: Install Senzing API
uses: Senzing/github-action-install-senzing-api@latest
uses: senzing-factory/github-action-install-senzing-api@v2
with:
senzingapi-version: production-v3
```
1. An example `.github/workflows/install-senzing-example.yaml` file
which installs a specific Senzing API verson:

```yaml
name: install-senzing-example.yaml
name: install senzing example
on: [push]
Expand All @@ -44,9 +46,26 @@ GitHub variable is `Linux`, `macOS`, or `Windows`.
runs-on: ubuntu-latest
steps:
- name: Install Senzing API
uses: Senzing/github-action-install-senzing-api@latest
uses: senzing-factory/github-action-install-senzing-api@v2
with:
senzingapi-version: 3.6.0-23160
```

If `senzingapi-version` is not specified, the default is "latest".
### senzingapi-version

`senzingapi-version` values can include the following:
- `production-v<MAJOR_VERSION>`
- Ex. `production-v3`
- This will install the latest version of the respective major version from *production*.
- `staging-v<MAJOR_VERSION>`
- Ex. `staging-v3`
- This will install the latest version of the respective major version from *staging*.
- `X.Y.Z`
- Ex. `3.8.2`
- This will install the latest build of the respective semantic version from *production*.
- `X.Y.Z-ABCDE`
- Ex. `3.8.3-24043`
- This will install the exact version supplied from *production*.

[RUNNER_OS]: https://docs.github.com/en/actions/learn-github-actions/variables#default-environment-variables
[system install]: https://github.com/senzing-garage/knowledge-base/blob/main/WHATIS/senzing-system-installation.md
9 changes: 4 additions & 5 deletions action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,27 +5,26 @@ author: support@senzing.com
inputs:
senzingapi-version:
description: Version of Senzing API to install
required: false
default: latest
required: true

runs:
using: composite
steps:
- if: runner.os == 'Linux'
name: Run on Linux
uses: Senzing/github-action-install-senzing/linux@latest
uses: senzing-factory/github-action-install-senzing/linux@"#52-skern"
with:
senzingapi-version: ${{ inputs.senzingapi-version }}

- if: runner.os == 'macOS'
name: Run on macOS
uses: Senzing/github-action-install-senzing/darwin@latest
uses: senzing-factory/github-action-install-senzing/darwin@"#52-skern"
with:
senzingapi-version: ${{ inputs.senzingapi-version }}

- if: runner.os == 'Windows'
name: Run on Windows
uses: Senzing/github-action-install-senzing/windows@latest
uses: senzing-factory/github-action-install-senzing/windows@"#52-skern"
with:
senzingapi-version: ${{ inputs.senzingapi-version }}

Expand Down
28 changes: 6 additions & 22 deletions darwin/action.yaml
Original file line number Diff line number Diff line change
@@ -1,39 +1,23 @@
# darwin/action.yaml
name: Install Senzing - darwin
description: Install Senzing API on the darwin/macOS platform.
author: support@senzing.com

inputs:
senzingapi-version:
description: Version of Senzing API to install
required: false
default: latest
required: true

runs:
using: composite
steps:
# Download staging, latest, or versioned image.

- if: inputs.senzingapi-version == 'staging'
env:
SENZINGAPI_STAGING_URL: https://public-read-access.s3.amazonaws.com/staging/senzingapi_staging.dmg
name: Download staging Senzing API
shell: bash
run: curl --output /tmp/senzingapi.dmg $SENZINGAPI_STAGING_URL

- if: inputs.senzingapi-version == 'latest'
env:
SENZINGAPI_LATEST_URL: https://public-read-access.s3.amazonaws.com/staging/senzingapi_latest.dmg
name: Download Senzing API
shell: bash
run: curl --output /tmp/senzingapi.dmg $SENZINGAPI_LATEST_URL
# Download latest staging or production image.

- if: ${{ inputs.senzingapi-version != 'latest' && inputs.senzingapi-version != 'staging' }}
env:
SENZINGAPI_LATEST_URL: https://public-read-access.s3.amazonaws.com/staging/senzingapi_latest.dmg
name: Download versioned Senzing API
- env:
SENZING_INSTALL_VERSION: ${{ inputs.senzingapi-version }}
name: Install Senzing API
shell: bash
run: curl --output /tmp/senzingapi.dmg $SENZINGAPI_LATEST_URL
run: ${{ github.action_path }}/darwin/download-senzing.sh

# Install Senzing API.

Expand Down
71 changes: 71 additions & 0 deletions darwin/download-senzing.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
#!/usr/bin/env bash
set -e

############################################
# configure-vars
# GLOBALS:
# SENZING_INSTALL_VERSION
# one of: production-v<X>, staging-v<X>
############################################
configure-vars() {

if [[ $SENZING_INSTALL_VERSION =~ "production" ]]; then

echo "[INFO] install senzingapi from production"
SENZINGAPI_URI="s3://public-read-access/MacOS_API/"
SENZINGAPI_URL="https://public-read-access.s3.amazonaws.com/MacOS_API"

elif [[ $SENZING_INSTALL_VERSION =~ "staging" ]]; then

echo "[INFO] install senzingapi from staging"
SENZINGAPI_URI="s3://public-read-access/staging/"
SENZINGAPI_URL="https://public-read-access.s3.amazonaws.com/staging"

else
echo "[ERROR] senzingapi install version $SENZING_INSTALL_VERSION is unsupported"
exit 1
fi

}

############################################
# determine-latest-dmg-for-major-version
# GLOBALS:
# SENZING_INSTALL_VERSION
# one of: production-v<X>, staging-v<X>
# SENZINGAPI_URI
############################################
determine-latest-dmg-for-major-version() {

major_version=$(echo "$SENZING_INSTALL_VERSION" | grep -Eo '[0-9]+$')
echo "[INFO] major version is: $major_version"

aws s3 ls $SENZINGAPI_URI --recursive --no-sign-request | grep -o -E '[^ ]+$' > /tmp/staging-versions
latest_staging_version=$(cat /tmp/staging-versions | grep _$major_version | sort -r | head -n 1 | awk -F'/' ' { print $NF } ')
rm /tmp/staging-versions
echo "[INFO] latest staging version is: $latest_staging_version"

SENZINGAPI_DMG_URL="$SENZINGAPI_URL/$latest_staging_version"

}

############################################
# download-dmg
# GLOBALS:
# SENZINGAPI_DMG_URL
############################################
download-dmg() {

echo "[INFO] curl --output /tmp/senzingapi.dmg $SENZINGAPI_DMG_URL"
curl --output /tmp/senzingapi.dmg $SENZINGAPI_DMG_URL

}

############################################
# Main
############################################

echo "[INFO] senzing version to install is: $SENZING_INSTALL_VERSION"
configure-vars
determine-latest-dmg-for-major-version
download-dmg
35 changes: 4 additions & 31 deletions linux/action.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# linux/action.yaml
name: Install Senzing - linux
description: Install Senzing API on the linux platform.
author: support@senzing.com
Expand All @@ -12,41 +11,15 @@ inputs:
runs:
using: composite
steps:
# Download production or staging APT repository.

- if: inputs.senzingapi-version == 'staging'
name: Download Senzing staging repository metadata
shell: bash
run: wget -qO /tmp/senzingrepo.deb https://senzing-staging-apt.s3.amazonaws.com/senzingstagingrepo_1.0.1-1_all.deb

- if: inputs.senzingapi-version != 'staging'
name: Download Senzing repository metadata
shell: bash
run: wget -qO /tmp/senzingrepo.deb https://senzing-production-apt.s3.amazonaws.com/senzingrepo_1.0.1-1_all.deb
# Install staging, production or versioned release.

# Install repository metadata.

- name: Install Senzing APT repository
shell: bash
run: |
sudo apt-get -y install /tmp/senzingrepo.deb
sudo apt-get update
# Install staging, latest or versioned release.

- if: ${{ inputs.senzingapi-version == 'staging' || inputs.senzingapi-version == 'latest' }}
env:
- env:
SENZING_ACCEPT_EULA: I_ACCEPT_THE_SENZING_EULA
SENZING_INSTALL_VERSION: ${{ inputs.senzingapi-version }}
name: Install Senzing API
shell: bash
run: sudo --preserve-env apt-get -y install senzingapi

- if: ${{ inputs.senzingapi-version != 'staging' && inputs.senzingapi-version != 'latest' }}
env:
SENZING_ACCEPT_EULA: I_ACCEPT_THE_SENZING_EULA
name: Install versioned Senzing API
shell: bash
run: sudo --preserve-env apt-get -y install senzingapi=${{ inputs.senzingapi-version }}
run: ${{ github.action_path }}/linux/install-senzing.sh

# Adjust files for "system install".

Expand Down
111 changes: 111 additions & 0 deletions linux/install-senzing.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
#!/usr/bin/env bash
set -e

############################################
# configure-vars
# GLOBALS:
# SENZING_INSTALL_VERSION
# one of: production-v<X>, staging-v<X>
# X.Y.Z, X.Y.Z-ABCDE
############################################
configure-vars() {

# senzing apt repository packages
PROD_REPO=https://senzing-production-apt.s3.amazonaws.com/senzingrepo_1.0.1-1_all.deb
STAGING_REPO=https://senzing-staging-apt.s3.amazonaws.com/senzingstagingrepo_1.0.1-1_all.deb

# semantic versions
REGEX_SEM_VER="^(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)$"
# semantic version with build number
REGEX_SEM_VER_BUILD_NUM="^(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)-([0-9]){5}$"

if [[ $SENZING_INSTALL_VERSION =~ "production" ]]; then

echo "[INFO] install senzingapi from production"
INSTALL_REPO="$PROD_REPO"
SENZING_PACKAGE="senzingapi"
restrict-major-version

elif [[ $SENZING_INSTALL_VERSION =~ "staging" ]]; then

echo "[INFO] install senzingapi from staging"
INSTALL_REPO="$STAGING_REPO"
SENZING_PACKAGE="senzingapi"
restrict-major-version

elif [[ $SENZING_INSTALL_VERSION =~ $REGEX_SEM_VER ]]; then

echo "[INFO] install senzingapi semantic version"
INSTALL_REPO="$PROD_REPO"
SENZING_PACKAGE="senzingapi=$SENZING_INSTALL_VERSION*"

elif [[ $SENZING_INSTALL_VERSION =~ $REGEX_SEM_VER_BUILD_NUM ]]; then

echo "[INFO] install senzingapi semantic version with build number"
INSTALL_REPO="$PROD_REPO"
SENZING_PACKAGE="senzingapi=$SENZING_INSTALL_VERSION"

else
echo "[ERROR] senzingapi install version $SENZING_INSTALL_VERSION is unsupported"
exit 1
fi

}

############################################
# install-senzing-repository
# GLOBALS:
# SENZING_INSTALL_VERSION
# one of: production-v<X>, staging-v<X>
# semver does not apply here
############################################
restrict-major-version() {

MAJOR_VERSION=$(echo "$SENZING_INSTALL_VERSION" | grep -Eo '[0-9]+$')
senzingapi_preferences_file="/etc/apt/preferences.d/senzingapi"
echo "[INFO] restrict senzingapi major version to: $MAJOR_VERSION"

echo "Package: senzingapi" | sudo tee -a $senzingapi_preferences_file
echo "Pin: version $MAJOR_VERSION.*" | sudo tee -a $senzingapi_preferences_file
echo "Pin-Priority: 999" | sudo tee -a $senzingapi_preferences_file

}

############################################
# install-senzing-repository
# GLOBALS:
# INSTALL_REPO
# APT Repository Package URL
############################################
install-senzing-repository() {

echo "[INFO] wget -qO /tmp/senzingrepo.deb $INSTALL_REPO"
wget -qO /tmp/senzingrepo.deb $INSTALL_REPO
echo "[INFO] sudo apt-get -y install /tmp/senzingrepo.deb"
sudo apt-get -y install /tmp/senzingrepo.deb
echo "[INFO] sudo apt-get update"
sudo apt-get update

}

############################################
# install-senzingapi
# GLOBALS:
# SENZING_PACKAGE
# full package name used for install
############################################
install-senzingapi() {

echo "[INFO] sudo --preserve-env apt-get -y install $SENZING_PACKAGE"
sudo --preserve-env apt-get -y install "$SENZING_PACKAGE"

}

############################################
# Main
############################################

echo "[INFO] senzing version to install is: $SENZING_INSTALL_VERSION"
configure-vars
install-senzing-repository
install-senzingapi
Loading

0 comments on commit a9e1503

Please sign in to comment.