diff --git a/.github/workflows/c-cpp.yml b/.github/workflows/c-cpp.yml index 005db0c..489d906 100644 --- a/.github/workflows/c-cpp.yml +++ b/.github/workflows/c-cpp.yml @@ -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: @@ -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 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 58c2e0f..08b2a64 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -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: @@ -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: | @@ -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: | @@ -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 @@ -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 @@ -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: | diff --git a/manpage b/manpage index 9dd9849..21c6694 100644 --- a/manpage +++ b/manpage @@ -2315,6 +2315,10 @@ 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 @@ -2322,7 +2326,7 @@ contains a composite string with all build information. For example: .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 diff --git a/specs/docs/alu.md b/specs/docs/alu.md index 373a9fa..2e1b7d5 100644 --- a/specs/docs/alu.md +++ b/specs/docs/alu.md @@ -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: diff --git a/specs/docs/onepage.md b/specs/docs/onepage.md index 1a4c903..22387ac 100644 --- a/specs/docs/onepage.md +++ b/specs/docs/onepage.md @@ -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 diff --git a/specs/src/build_info.targets b/specs/src/build_info.targets index 7e1e622..c002637 100644 --- a/specs/src/build_info.targets +++ b/specs/src/build_info.targets @@ -8,6 +8,8 @@ local $(SPECS_BUILD_SOURCE) $(SPECS_BUILD_NUMBER) + $(SPECS_BUILD_RUNID) + $(SPECS_BUILD_URL) @@ -38,6 +40,8 @@ + + diff --git a/specs/src/generate_build_info.py b/specs/src/generate_build_info.py index 32a2ade..4d574bb 100644 --- a/specs/src/generate_build_info.py +++ b/specs/src/generate_build_info.py @@ -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": @@ -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") diff --git a/specs/src/processing/Config.cc b/specs/src/processing/Config.cc index ca62593..741e71a 100644 --- a/specs/src/processing/Config.cc +++ b/specs/src/processing/Config.cc @@ -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"; } diff --git a/specs/src/test/specs-autocomplete.cc b/specs/src/test/specs-autocomplete.cc index 3d695e3..b9a9b11 100644 --- a/specs/src/test/specs-autocomplete.cc +++ b/specs/src/test/specs-autocomplete.cc @@ -19,6 +19,8 @@ StringVector SystemDefinedLabels = { "@build-time", "@build-source", "@build-number", + "@build-runid", + "@build-url", "@build-info" };