Files
software-version/action.yaml
2025-04-14 15:38:12 +02:00

59 lines
1.5 KiB
YAML

name: 'software-version'
description: 'Retrieve the software version that will be packaged into the docker image'
author: 'Eric Coissac'
inputs:
git_checkout:
description: 'Shall I checkout the git'
required: false
default: false
type: boolean
version_file:
description: 'Name of the file containing the version number'
required: false
default: 'software_version.txt'
debug:
description: 'Run the action in debug mode'
required: false
default: false
type: boolean
outputs:
version:
description: 'The version of the software packaged in the image'
runs:
using: 'composite'
steps:
- name: Load bash library
uses: https://gargoton.petite-maison-orange.fr/pmo-actions/bash-library@main
- name: Set debug mode
if: inputs.debug == 'true'
shell: bash
run: |
source "${{ github.action_path }}/../bashlib.sh"
export DEBUG="ON"
echo "DEBUG=ON" >> $GITEA_ENV
debug Debug switch on
- name: Checkout code
if: inputs.git_checkout == 'true'
uses: actions/checkout@v4
- name: Retrieve the version
shell: bash
run: |
# Lire le contenu du fichier et supprimer les espaces/retours chariots
SOFTVERSION=$(cat ${{ inputs.version_file }} \
| grep -v '^ *$' \
| head -n 1 \
| tr -d '\n' \
| sed -E 's/^[[:space:]]*//;s/[[:space:]]*$//' \
| tr ' ' '-')
echo "version=${SOFTVERSION}" >> $GITHUB_OUTPUT