Skip to content
Merged
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
4 changes: 3 additions & 1 deletion .github/workflows/c-cpp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ on:
env:
SPECS_BRANCH: ${{ github.event.pull_request.base.ref || github.ref_name }}
SPECS_BUILD_SOURCE: github
SPECS_BUILD_RUNID: ${{ github.run_id }}
SPECS_BUILD_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}

jobs:
build-linux:
Expand Down Expand Up @@ -40,7 +42,7 @@ jobs:
run: make all

- name: Test specs executable
run: specs/exe/specs "Version:" 1 "@version" WRITE "Platform:" 1 "@platform" WRITE "Build info:" 1 "@build-info"
run: specs/exe/specs "Version:" 1 "@version" WRITE "Platform:" 1 "@platform" WRITE "Build info:" 1 "@build-info" WRITE "Build URL:" 1 "@build-url"

- name: make check
working-directory: specs/src
Expand Down
12 changes: 7 additions & 5 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ env:
SPECS_BRANCH: ${{ github.event.release.target_commitish }}
SPECS_BUILD_SOURCE: github
SPECS_BUILD_NUMBER: ${{ github.run_number }}
SPECS_BUILD_RUNID: ${{ github.run_id }}
SPECS_BUILD_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}

jobs:
build-linux:
Expand Down Expand Up @@ -56,7 +58,7 @@ jobs:
run: make some

- name: Verify binary
run: specs/exe/specs "Version:" 1 "@version" WRITE "Platform:" 1 "@platform" WRITE "Build info:" 1 "@build-info"
run: specs/exe/specs "Version:" 1 "@version" WRITE "Platform:" 1 "@platform" WRITE "Build info:" 1 "@build-info" WRITE "Build URL:" 1 "@build-url"

- name: Prepare manpage
run: |
Expand Down Expand Up @@ -132,7 +134,7 @@ jobs:
run: make some

- name: Verify binary
run: specs/exe/specs "Version:" 1 "@version" WRITE "Platform:" 1 "@platform" WRITE "Build info:" 1 "@build-info"
run: specs/exe/specs "Version:" 1 "@version" WRITE "Platform:" 1 "@platform" WRITE "Build info:" 1 "@build-info" WRITE "Build URL:" 1 "@build-url"

- name: Prepare manpage
run: |
Expand Down Expand Up @@ -216,7 +218,7 @@ jobs:
run: msbuild specs/specs.sln /p:Configuration=Release /p:Platform=x64 /p:GitTag=${{ steps.version.outputs.display }}

- name: Verify binary
run: specs\bin\Release\specs.exe "Version:" 1 "@version" WRITE "Platform:" 1 "@platform" WRITE "Build info:" 1 "@build-info"
run: specs\bin\Release\specs.exe "Version:" 1 "@version" WRITE "Platform:" 1 "@platform" WRITE "Build info:" 1 "@build-info" WRITE "Build URL:" 1 "@build-url"

- name: Prepare standalone executable
shell: bash
Expand Down Expand Up @@ -302,7 +304,7 @@ jobs:
run: msbuild specs/specs.sln /p:Configuration=Release /p:Platform=x64 /p:GitTag=${{ steps.version.outputs.display }} /p:EnablePython=true

- name: Verify binary
run: specs\bin\Release\specs.exe "Version:" 1 "@version" WRITE "Platform:" 1 "@platform" WRITE "Build info:" 1 "@build-info"
run: specs\bin\Release\specs.exe "Version:" 1 "@version" WRITE "Platform:" 1 "@platform" WRITE "Build info:" 1 "@build-info" WRITE "Build URL:" 1 "@build-url"

- name: Prepare standalone executable
shell: bash
Expand Down Expand Up @@ -390,7 +392,7 @@ jobs:
run: make some

- name: Verify binary
run: specs/exe/specs "Version:" 1 "@version" WRITE "Platform:" 1 "@platform" WRITE "Build info:" 1 "@build-info"
run: specs/exe/specs "Version:" 1 "@version" WRITE "Platform:" 1 "@platform" WRITE "Build info:" 1 "@build-info" WRITE "Build URL:" 1 "@build-url"

- name: Prepare manpage
run: |
Expand Down
6 changes: 5 additions & 1 deletion manpage
Original file line number Diff line number Diff line change
Expand Up @@ -2315,14 +2315,18 @@ or
depending on where the build was created.
.IP "build-number" 3
contains the build number from GitHub Actions (github.run_number). Empty for local builds.
.IP "build-runid" 3
contains the 11-digit build id from GitHub Actions (github.run_id). Empty for local builds.
.IP "build-url" 3
contains the build URL for the GitHub build. Empty for local builds.
.IP "build-info" 3
contains a composite string with all build information. For example:
.p
Built locally from commit 8bd11da on branch dev-1.0.0 at 2026-06-08T13:01:18 local
.p
or
.p
Built on github (build 217) from commit 8bd11da of version 1.0.0 at 2026-06-08T10:01:18 UTC
Built on github (id 27334782912; build 217) from commit 8bd11da of version 1.0.0 at 2026-06-08T10:01:18 UTC
.p

.SH EXAMPLES
Expand Down
4 changes: 3 additions & 1 deletion specs/docs/alu.md
Original file line number Diff line number Diff line change
Expand Up @@ -123,10 +123,12 @@ Build information is also available via the following labels:
- `@build-time` — the timestamp when the build was created (format: `yyyy-MM-ddTHH:mm:ss`). It's local time for local builds, or UTC for GitHub builds.
- `@build-source` — either `local` or `github`
- `@build-number` — the GitHub Actions build number (empty for local builds)
- `@build-runid` — the 11-digit GitHub Actions run id (empty for local builds)
- `@build-url` — the build URL for the GitHub build (Empty for local builds), e.g: [https://github.com/yoavnir/specs2016/actions/runs/27334782912](https://github.com/yoavnir/specs2016/actions/runs/27334782912).
- `@build-info` — a composite string with all build information, e.g.:
```
Built locally from commit 8bd11da on branch dev-1.0.0 at 2026-06-08T13:01:18 local
Built on github (build 217) from commit 8bd11da of version 1.0.0 at 2026-06-08T10:01:18 UTC
Built on github (id 27334782912; build 217) from commit 8bd11da of version 1.0.0 at 2026-06-08T10:01:18 UTC
```

Additionally, the `@@` string stands for the entire input record. When rolling context is in effect (see [Streams and Records](streams.md#rolling-context)), `@@` always refers to the original input record. The `@!` string refers to the current record as affected by `CONTEXT`, which is the same as `@@` when no `CONTEXT` is active. The `@-n` and `@+n` syntax is an alternative to using that is effective within expressions. Note that reading beyond the input with `@+n` or `@-n` does not cause processing to stop, even if a `READSTOP` token is present in the specification. The following three specifications are equivalent:
Expand Down
2 changes: 2 additions & 0 deletions specs/docs/onepage.md
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,8 @@ There are some pre-configured labels that do not need to be explicitly defined:
* build-time - contains the timestamp when the build was created (format: `yyyy-MM-ddTHH:mm:ss`). It's local time for local builds, or UTC for GitHub builds.
* build-source - contains either `local` or `github`
* build-number - contains the GitHub Actions build number (empty for local builds)
* build-runid - contains the 11-digit GitHub Actions run id (empty for local builds)
* build-url - contains the build URL for the GitHub build (Empty for local builds)
* build-info - contains a composite string with all build information

Examples
Expand Down
4 changes: 4 additions & 0 deletions specs/src/build_info.targets
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
<BuildSource Condition="'$(SPECS_BUILD_SOURCE)' == ''">local</BuildSource>
<BuildSource Condition="'$(SPECS_BUILD_SOURCE)' != ''">$(SPECS_BUILD_SOURCE)</BuildSource>
<BuildNumber>$(SPECS_BUILD_NUMBER)</BuildNumber>
<BuildRunId>$(SPECS_BUILD_RUNID)</BuildRunId>
<BuildUrl>$(SPECS_BUILD_URL)</BuildUrl>
</PropertyGroup>

<!-- Get git commit hash -->
Expand Down Expand Up @@ -38,6 +40,8 @@
<BuildInfoLines Include="#define SPECS_BUILD_TIME &quot;$(BuildTime)&quot;" />
<BuildInfoLines Include="#define SPECS_BUILD_SOURCE &quot;$(BuildSource)&quot;" />
<BuildInfoLines Include="#define SPECS_BUILD_NUMBER &quot;$(BuildNumber)&quot;" />
<BuildInfoLines Include="#define SPECS_BUILD_RUNID &quot;$(BuildRunId)&quot;" />
<BuildInfoLines Include="#define SPECS_BUILD_URL &quot;$(BuildUrl)&quot;" />
</ItemGroup>

<WriteLinesToFile File="utils\build_info.h" Lines="@(BuildInfoLines)" Overwrite="true" />
Expand Down
6 changes: 6 additions & 0 deletions specs/src/generate_build_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,10 @@ def run_git(name, args):
report_success("SPECS_BUILD_SOURCE", build_source)
build_number = os.environ.get("SPECS_BUILD_NUMBER", "")
report_success("SPECS_BUILD_NUMBER", build_number)
build_runid = os.environ.get("SPECS_BUILD_RUNID", "")
report_success("SPECS_BUILD_RUNID", build_runid)
build_url = os.environ.get("SPECS_BUILD_URL", "")
report_success("SPECS_BUILD_URL", build_url)

# Get UTC build time
if build_source == "local":
Expand All @@ -75,5 +79,7 @@ def run_git(name, args):
f.write('#define SPECS_BUILD_TIME "{}"\n'.format(build_time))
f.write('#define SPECS_BUILD_SOURCE "{}"\n'.format(build_source))
f.write('#define SPECS_BUILD_NUMBER "{}"\n'.format(build_number))
f.write('#define SPECS_BUILD_RUNID "{}"\n'.format(build_runid))
f.write('#define SPECS_BUILD_URL "{}"\n'.format(build_url))

print("Generated utils/build_info.h")
7 changes: 5 additions & 2 deletions specs/src/processing/Config.cc
Original file line number Diff line number Diff line change
Expand Up @@ -224,14 +224,17 @@ void readConfigurationFile(useKeyValueCB cb)
ExternalLiterals["build-time"] = dequote(STRINGIFY(SPECS_BUILD_TIME));
ExternalLiterals["build-source"] = dequote(STRINGIFY(SPECS_BUILD_SOURCE));
ExternalLiterals["build-number"] = dequote(STRINGIFY(SPECS_BUILD_NUMBER));
ExternalLiterals["build-runid"] = dequote(STRINGIFY(SPECS_BUILD_RUNID));
ExternalLiterals["build-url"] = dequote(STRINGIFY(SPECS_BUILD_URL));

// Compose build-info
std::string build_info = "Built ";
if (ExternalLiterals["build-source"] == "github") {
build_info += "on github";
build_info += "on github (id " + ExternalLiterals["build-runid"];
if (!ExternalLiterals["build-number"].empty()) {
build_info += " (build " + ExternalLiterals["build-number"] + ")";
build_info += "; build " + ExternalLiterals["build-number"];
}
build_info += ")";
} else {
build_info += "locally";
}
Expand Down
2 changes: 2 additions & 0 deletions specs/src/test/specs-autocomplete.cc
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ StringVector SystemDefinedLabels = {
"@build-time",
"@build-source",
"@build-number",
"@build-runid",
"@build-url",
"@build-info"
};

Expand Down
Loading