generated from amazon-archives/__template_Apache-2.0
-
Notifications
You must be signed in to change notification settings - Fork 2
feat: extract version action #167
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
+29
−0
Closed
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
20789c1
feat: extract version action
0marperez 1b7555a
misc: add todo to fix checkout head
0marperez 02d066a
feat: add file path and make search more flexible
0marperez b86e978
misc: move to utils file
0marperez 3562eb7
fix: actaully run in working dir
0marperez 096d1bb
fix: file path input variable
0marperez 0506620
fix: double parentheses
0marperez 5a4abaf
misc: combine into a single step
0marperez 24c3908
misc: log GitHub output
0marperez bd77cff
fix: add double quotes around GitHub output env var
0marperez 017a9e1
fix: quote result since it has dashes
0marperez fca4520
misc: try hardcoding result
0marperez cdd7db1
feat: use file as output :/
0marperez 78a42c7
misc: documentation updates
0marperez 05bf7c8
fix: update outdated documentation
0marperez File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
This file contains hidden or 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
| 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 | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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: