Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/actions/checkout-head/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ name: Checkout Head
description: >
Attempt to checkout a repository using the head ref. If it doesn't exist attempt to fallback to the
base ref. If it doesn't exist then use the default branch.
# TODO: Fall back to version configured by project instead of main

inputs:
fetch-depth:
Expand Down
28 changes: 28 additions & 0 deletions .github/actions/utils/extract-version/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Extract version from a file
description: Extracts the specified version from a file

inputs:
working-directory:
description: Directory in which the action will run
default: .
version-name:
description: Name of the version to extract e.g. 'crt-kotlin-version'
file-path:
description: Path to the file to search for the version in (relative to `working-directory`).
output-path:
description: Directory where the version will be saved. The action writes the found version to 'version.txt' inside this directory
default: .

runs:
using: composite
steps:
- name: Extract version
working-directory: ${{inputs.working-directory}}
shell: bash
run: |
echo "Looking for version '${{inputs.version-name}}' in '${{inputs.file-path}}'"
version=$(awk -F'=' -v k="${{inputs.version-name}}" '$1 ~ "^"k"[[:space:]]*" { gsub(/[[:space:]]*/, "", $2); gsub(/"/,"",$2); print $2 }' ${{inputs.file-path}})
echo "Found version '$version'"

echo "Saving version to '${{inputs.output-path}}/version.txt'"
echo "$version" > ${{inputs.output-path}}/version.txt
Comment on lines +22 to +28
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correctness: We already have a kat action to handle this:

cd ${{inputs.working-directory}}
kat get-property "${{inputs.version-name}}" > ${{inputs.output-path}}/version.txt

Loading