Skip to content

CI - CD: Publishing #178

CI - CD: Publishing

CI - CD: Publishing #178

name: 'CI - CD: Publishing'
on:
push:
branches:
- main
tags:
- '*-alpha-*.*.*'
- '*-beta-*.*.*'
- '*-prod-*.*.*'
workflow_dispatch:
inputs:
publish:
description: Trigger with publish
required: false
type: boolean
schedule:
- cron: 0 19 * * *
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
jobs:
check_changed_and_publish:
name: Check which workspace member changed and / or needs publishing
runs-on:
- ci-scale-set
outputs:
workspace: ${{ steps.check_workspace.outputs.workspace }}
steps:
- name: Install FSLABScli
uses: ForesightMiningSoftwareCorporation/fslabscli-action@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
- name: Checkout repo
uses: actions/checkout@v4
with:
ref: ${{ github.head_ref }}
- id: check_workspace
name: Check workspace
shell: bash
run: |-
if [ -z "${HEAD_REF}" ]; then
CHECK_CHANGED=()
else
CHECK_CHANGED=('--check-changed' '--changed-base-ref' "origin/${BASE_REF}" '--changed-head-ref' "${HEAD_REF}")
git fetch origin ${BASE_REF} --depth 1
fi
workspace=$(fslabscli check-workspace --json --check-publish "${CHECK_CHANGED[@]}" --binary-store-storage-account ${{ secrets.BINARY_STORE_STORAGE_ACCOUNT }} --binary-store-container-name ${{ secrets.BINARY_STORE_CONTAINER_NAME }} --binary-store-access-key ${{ secrets.BINARY_STORE_ACCESS_KEY }} --cargo-default-publish --cargo-registry foresight-mining-software-corporation --cargo-registry-url https://shipyard.rs/api/v1/shipyard/krates/by-name/ --cargo-registry-user-agent "shipyard ${{ secrets.CARGO_PRIVATE_REGISTRY_TOKEN }}")
if [ $? -ne 0 ]; then
echo "Could not check workspace"
exit 1
fi
echo workspace=${workspace} >> $GITHUB_OUTPUT
working-directory: .
env:
BASE_REF: ${{ github.base_ref }}
HEAD_REF: ${{ github.head_ref }}
publish_cargo-fslabscli:
name: 'Publish fslabscli: cargo-fslabscli'
uses: ForesightMiningSoftwareCorporation/github/.github/workflows/rust-build.yml@v2
needs:
- check_changed_and_publish
if: ${{ !cancelled() && !contains(needs.*.result, 'failure') && !contains(needs.*.result, 'cancelled') && (github.event_name == 'push' || (github.event_name == 'workflow_dispatch' && inputs.publish)) && (fromJSON(needs.check_changed_and_publish.outputs.workspace).cargo-fslabscli.publish) }}
with:
publish: 'true'
publish_private_registry: ${{ fromJson(needs.check_changed_and_publish.outputs.workspace).cargo-fslabscli.publish_detail.cargo.publish }}
publish_public_registry: 'false'
publish_docker: 'false'
publish_binary: ${{ fromJson(needs.check_changed_and_publish.outputs.workspace).cargo-fslabscli.publish_detail.binary.publish }}
publish_npm_napi: 'false'
working_directory: .
binary_sign_build: 'false'
binary_application_name: FSLABS Cli tool
binary_targets: '["x86_64-unknown-linux-gnu"]'
secrets: inherit