Skip to content

Replace Cargo.toml parsing with cargo metadata, use output variables, auto-include metadata files#4

Merged
julcst merged 6 commits into
mainfrom
copilot/modify-test-use-output-variables
Oct 26, 2025
Merged

Replace Cargo.toml parsing with cargo metadata, use output variables, auto-include metadata files#4
julcst merged 6 commits into
mainfrom
copilot/modify-test-use-output-variables

Conversation

Copilot AI commented Oct 25, 2025

Copy link
Copy Markdown
Contributor

Addresses technical debt around metadata extraction, deterministic file discovery, and Windows resource handling. Moves Windows metadata/icon embedding to pre-build phase as recommended practice. Automatically includes README and LICENSE files from cargo metadata.

Changes

Metadata extraction

  • Replace grep/sed parsing with cargo metadata JSON output parsed via jq
  • Extract package metadata, binary name, target directory, readme, and license_file from structured output
  • Remove explicit Cargo.toml existence checks (cargo metadata handles this internally)
  • Simplify logic by checking metadata variables instead of file paths
  • Auto-include README and LICENSE files from readme and license_file metadata fields in all bundles

Test workflow improvements

  • Use bundle task output variables (bundle-path, bundle-name) instead of hardcoded paths
  • Example:
    - name: Bundle Application
      id: bundle
      uses: ./
    
    - name: Test Bundle
      run: tar -tzf ${{ steps.bundle.outputs.bundle-path }}

Windows metadata/icon handling

  • Remove .rc file generation from bundle process
  • Remove icon file (.ico/.png) from Windows zip distribution
  • Icons and metadata should be embedded at build time using build.rs
  • Document build-time embedding using winres crate in build.rs

Example improvements

  • Add winres = "0.1" to hello-world [build-dependencies] in Cargo.toml
  • Update build.rs to use winres by default (enabled, not commented out)
  • Add LICENSE file to hello-world example
  • Set readme and license-file fields in hello-world Cargo.toml
  • Update hello-world README with winres and metadata documentation

Documentation

  • Document action dependencies: cargo and jq are required for metadata extraction
  • Add Requirements section explaining metadata extraction behavior
  • Document auto-inclusion of README and LICENSE from Cargo.toml metadata
  • Add section on Cargo.toml include field vs action include-files parameter
  • Remove duplicate Platform-Specific Notes section
  • Update all metadata references to reflect cargo metadata usage
  • Update Windows output structure to show binary only (no icon files)

Cleanup

  • Remove CHANGELOG.md
  • Remove unused example-cross-platform.yml workflow
  • Remove unused convert_png_to_ico and discover_cargo_toml functions
  • Fix icon auto-discovery when using working-directory parameter
Original prompt

Modify the test to use the output variables of the bundle task. Then, on windows the embedding of metadata should really be pre-build, remove it entirely from this workflow and write modern instructions on how to include the metadata using a build script in the README. Drop the changelog and the other unused workflow. Cargo has a field include, prefer that over the action variable. Fix the parsing of the Cargo.toml, currently it extracts full key-value pairs, also fix discovery of the Cargo.toml and make it more deterministic, really it should only be at the root of the pwd. It would be even cleaner if you extract all the variables not from the cargo.toml but from the cargo metadata command. This also directly gives you the path to the binary. Improve the structure of the README.


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 3 commits October 25, 2025 22:17
…e Windows .rc generation

Co-authored-by: julcst <97609514+julcst@users.noreply.github.com>
Co-authored-by: julcst <97609514+julcst@users.noreply.github.com>
Co-authored-by: julcst <97609514+julcst@users.noreply.github.com>
Copilot AI changed the title [WIP] Modify test to use output variables and restructure README Replace Cargo.toml parsing with cargo metadata, use output variables, remove Windows .rc generation Oct 25, 2025
Copilot AI requested a review from julcst October 25, 2025 22:23
@julcst

julcst commented Oct 26, 2025

Copy link
Copy Markdown
Owner

@copilot you do not need to check for a cargo.toml, cargo metadata already does that. Furthermore, you do not need to ship the Windows icon file in the zip distribution. However, maybe include an example buildscript using winres and icon conversion in the hello world example. Just keep both out of the post build shell script. Also document the dependencies of the action.

Co-authored-by: julcst <97609514+julcst@users.noreply.github.com>

Copilot AI commented Oct 26, 2025

Copy link
Copy Markdown
Contributor Author

@copilot you do not need to check for a cargo.toml, cargo metadata already does that. Furthermore, you do not need to ship the Windows icon file in the zip distribution. However, maybe include an exam...

Done in commit 19d0d52:

  • Removed Cargo.toml existence checks (cargo metadata handles this internally)
  • Removed Windows icon file from zip distribution
  • Added example build.rs to hello-world demonstrating winres usage with icon conversion instructions
  • Removed unused convert_png_to_ico and discover_cargo_toml functions
  • Updated documentation to reflect changes

Copilot AI changed the title Replace Cargo.toml parsing with cargo metadata, use output variables, remove Windows .rc generation Replace Cargo.toml parsing with cargo metadata, use output variables, remove Windows icon from bundle Oct 26, 2025
@julcst

julcst commented Oct 26, 2025

Copy link
Copy Markdown
Owner

@copilot please use winres by adding it to the toml of hello-world. And please use the include field from the toml instead. Also include the README and LICENSE from the readme and license_path field of the metadata

…adata

Co-authored-by: julcst <97609514+julcst@users.noreply.github.com>

Copilot AI commented Oct 26, 2025

Copy link
Copy Markdown
Contributor Author

@copilot please use winres by adding it to the toml of hello-world. And please use the include field from the toml instead. Also include the README and LICENSE from the readme and license_path field o...

Done in commit a7e54c8:

  • Added winres to hello-world Cargo.toml [build-dependencies], now enabled by default in build.rs
  • Auto-include README and LICENSE from readme and license_file cargo metadata fields in all bundles
  • Created LICENSE file for hello-world example with license-file = "LICENSE" in Cargo.toml
  • Documented action dependencies: cargo and jq are required for metadata extraction

Copilot AI changed the title Replace Cargo.toml parsing with cargo metadata, use output variables, remove Windows icon from bundle Replace Cargo.toml parsing with cargo metadata, use output variables, auto-include metadata files Oct 26, 2025
@julcst julcst marked this pull request as ready for review October 26, 2025 07:35
@julcst julcst self-requested a review October 26, 2025 07:36
@julcst julcst merged commit 93ffd5c into main Oct 26, 2025
6 checks passed
@julcst julcst deleted the copilot/modify-test-use-output-variables branch October 26, 2025 08:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants