GitHub Action
Get info Cargo.toml file
v1
Latest version
A GitHub Action to get info in a Cargo.toml file. This is useful for getting project versions when working on docker images. The returned value is available in the github action step.
In the following example, you can learn how to use it, especially you can put the desired key value in the package value, and you can also enter it in an array. Here is an example of it in use:
name: Get info Cargo.toml file
on: [ push ]
jobs:
get-cargo-package-info:
runs-on: ubuntu-latest
steps:
- name: Get package info
id: info
uses: rabbitson87/get-cargo-package-info@v1
with:
file_name: Cargo.toml
directory: <directory_name>
package: |
name
version
edition
In the example above, there are several key/value pairs that will be added to output object's values.
Name | Description |
---|---|
package |
These key values are used to obtain values that match the key value of the environment variable corresponding to [package] from the 'Cargo.toml' file |
directory (Optional) |
This key will set the directory in which you want to get info in Cargo.toml file. Important: cannot start with / . Action will fail if the specified directory doesn't exist. |
file_name (Optional) |
Set the name of the 'Cargo.toml' file. Defaults to Cargo.toml |
The output value is output in json form according to the value set in the package. The following example shows the expected json form:
{
"name": "test_toml",
"version": "0.1.0",
"edition": "2021"
}
[package]
name = "test_toml"
version = "0.1.0"
edition = "2021"
name: Get info Cargo.toml file
on: [ push ]
jobs:
get-cargo-package-info:
runs-on: ubuntu-latest
steps:
- name: Get package info
id: info
uses: rabbitson87/get-cargo-package-info@v1
with:
package: |
version
- name: Use output
shell: bash
run: echo "version is ${{ fromJson(steps.info.outputs.object).package.version }}"