cicd #274
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
# Copyright (c) Perpetual Intelligence L.L.C. All Rights Reserved. | |
# | |
# For license, terms, and data policies, go to: | |
# https://terms.perpetualintelligence.com | |
name: build-test-push | |
concurrency: github-release | |
# Manual trigger for deployment | |
on: | |
push: | |
branches: [ main ] | |
pull_request: | |
branches: [ main ] | |
workflow_dispatch: | |
inputs: | |
suffix: | |
type: choice | |
description: 'The package deployment suffix' | |
required: true | |
options: | |
- preview | |
- rc | |
- release | |
default: preview | |
registry: | |
type: choice | |
description: 'The package registry' | |
required: true | |
options: | |
- github | |
- nuget | |
default: github | |
jobs: | |
setup: | |
runs-on: ubuntu-latest | |
environment: github-release | |
timeout-minutes: 10 | |
# Define environment variables to authenticate the package feeds | |
env: | |
PI_GITHUB_USERNAME_ENV: ${{ secrets.PI_GITHUB_USERNAME }} | |
PI_GITHUB_PAT_ENV: ${{ secrets.PI_GITHUB_PAT }} | |
PI_NUGET_PAT_ENV: ${{ secrets.PI_NUGET_API_KEY }} | |
PI_PUBLISH_REGISTRY: github | |
PI_CI_REFERENCE: package | |
PI_CLI_TEST_ONLINE_LIC: ${{ secrets.PI_CLI_TEST_ONLINE_LIC }} | |
PI_CLI_TEST_OFFLINE_LIC: ${{ secrets.PI_CLI_TEST_OFFLINE_LIC }} | |
PI_CLI_TEST_PKEY_DEMO_LIC: ${{ secrets.PI_CLI_TEST_PKEY_DEMO_LIC }} | |
PI_CLI_TEST_SKEY_DEMO_LIC: ${{ secrets.PI_CLI_TEST_SKEY_DEMO_LIC }} | |
steps: | |
# Checktout | |
- name: Checkout | |
uses: actions/checkout@v3 | |
# Print directory | |
- name: Print | |
if: ${{ false }} # Debug | |
run: ls -R | |
shell: bash | |
# Read env | |
- name: Read Env | |
run: cat .github/package_version.env >> $GITHUB_ENV | |
continue-on-error: false | |
# Build Number | |
# Establish a unique build number for the current run DMYY{RUN_NUMBER}{RUN_ATTEMPT} e.g. 11223234 | |
# Ignore leading 0 in day and month. | |
# https://stackoverflow.com/questions/54066437/date-month-in-bash-without-leading-0-or-space | |
- name: Build Number | |
run: echo "PI_BUILD_NUMBER=$(date +'%-d%-m%y')${{ github.run_number }}${{ github.run_attempt }}" >> $GITHUB_ENV | |
continue-on-error: false | |
# Setup preview package versions based on trigger | |
# Format: <package>.2.3.6-preview.2201032602 | |
- name: Default metadata (rc) | |
if: ${{ github.event.inputs.suffix == '' }} | |
run: echo "PI_CI_PACKAGE_VERSION=${{ env.PI_MAJOR_VERSION }}.${{ env.PI_MINOR_VERSION }}.${{ env.PI_PATCH_VERSION }}-rc.${{ env.PI_BUILD_NUMBER }}" >> $GITHUB_ENV | |
continue-on-error: false | |
# Setup preview package versions | |
# Format: <package>.2.3.6-preview.2201032602 | |
- name: Preview metadata | |
if: ${{ github.event.inputs.suffix == 'preview' }} | |
run: echo "PI_CI_PACKAGE_VERSION=${{ env.PI_MAJOR_VERSION }}.${{ env.PI_MINOR_VERSION }}.${{ env.PI_PATCH_VERSION }}-preview.${{ env.PI_BUILD_NUMBER }}" >> $GITHUB_ENV | |
continue-on-error: false | |
# Setup rc package versions | |
# Format: <package>.2.3.6-rc.2201032602 | |
- name: RC metadata | |
if: ${{ github.event.inputs.suffix == 'rc' }} | |
run: echo "PI_CI_PACKAGE_VERSION=${{ env.PI_MAJOR_VERSION }}.${{ env.PI_MINOR_VERSION }}.${{ env.PI_PATCH_VERSION }}-rc.${{ env.PI_BUILD_NUMBER }}" >> $GITHUB_ENV | |
continue-on-error: false | |
# Setup release package versions | |
# Format: <package>.2.3.6 | |
- name: Release metadata | |
if: ${{ github.event.inputs.suffix == 'release' }} | |
run: echo "PI_CI_PACKAGE_VERSION=${{ env.PI_MAJOR_VERSION }}.${{ env.PI_MINOR_VERSION }}.${{ env.PI_PATCH_VERSION }}" >> $GITHUB_ENV | |
continue-on-error: false | |
# Setup publish registry (github or Nuget) | |
# PI_PUBLISH_REGISTRY defaults to github | |
- name: Registry metadata | |
if: ${{ github.event.inputs.registry != '' }} | |
run: echo "PI_PUBLISH_REGISTRY=${{ github.event.inputs.registry }}" >> $GITHUB_ENV | |
continue-on-error: false | |
# Print all env and directory | |
- name: Print | |
if: ${{ false }} | |
run: | | |
env | |
ls -R | |
shell: bash | |
# Setup .Net with global.json | |
- name: Setup .NET | |
uses: actions/setup-dotnet@v3 | |
# Build Terminal.DependentAssembly.csproj so it can be loaded during unit tests. | |
- name: Build Dependency Project | |
run: dotnet build ./test/OneImlx.Terminal.DependentAssembly/OneImlx.Terminal.DependentAssembly.csproj -c Release --verbosity minimal | |
# Publish OneImlx.Terminal | |
- name: OneImlx.Terminal | |
uses: ./.github/actions/push-package | |
with: | |
project: OneImlx.Terminal | |
config: Release | |
version: ${{ env.PI_CI_PACKAGE_VERSION }} | |
ghapikey: ${{ env.PI_GITHUB_PAT_ENV }} | |
nugetapikey: ${{ env.PI_NUGET_PAT_ENV }} | |
registry: ${{ env.PI_PUBLISH_REGISTRY }} | |
# Publish OneImlx.Terminal.Authentication | |
- name: OneImlx.Terminal.Authentication | |
uses: ./.github/actions/push-package | |
with: | |
project: OneImlx.Terminal.Authentication | |
config: Release | |
version: ${{ env.PI_CI_PACKAGE_VERSION }} | |
ghapikey: ${{ env.PI_GITHUB_PAT_ENV }} | |
nugetapikey: ${{ env.PI_NUGET_PAT_ENV }} | |
registry: ${{ env.PI_PUBLISH_REGISTRY }} |