Skip to content

fix: updating modification timestamps with GoReleaser#26

Merged
tmknom merged 1 commit intomainfrom
fix/add-modification-timestamps
Jan 3, 2025
Merged

fix: updating modification timestamps with GoReleaser#26
tmknom merged 1 commit intomainfrom
fix/add-modification-timestamps

Conversation

@tmknom
Copy link
Copy Markdown
Owner

@tmknom tmknom commented Jan 3, 2025

The metadata section in GoReleaser allows you to attach custom metadata to your release artifacts. By adding information such as timestamps or commit hashes, you improve traceability and consistency for your software releases.


Configuration Example

metadata:
  mod_timestamp: "{{ .CommitTimestamp }}"

This configuration updates the modification timestamp for all artifacts, aligning them with the commit that generated them.


Key Benefits

  1. Traceability
    Including commit timestamps in metadata makes it easy to identify when a build was created. This is invaluable for debugging and pinpointing specific versions of your artifacts.

  2. Consistency
    Ensures that the metadata accurately reflects the project’s source code history, making it easier to correlate code changes with released artifacts.


Configuration Option: mod_timestamp

The mod_timestamp option specifies the modification timestamp for your artifacts.

  • Template Variable:
    {{ .CommitTimestamp }}
    This variable dynamically replaces the mod_timestamp with the actual timestamp of the commit, ensuring the artifacts are tightly linked to their source history.

Quoting the GoReleaser documentation:

Metadata

GoReleaser creates some metadata files in the dist directory before it
finishes running.

You can also set some global defaults that can be used by other features.

metadata:
  # Set the modified timestamp on the metadata files.
  #
  # Templates: allowed.
  mod_timestamp: "{{ .CommitTimestamp }}"

  # The maintainers of this software.
  # Most features will only use the first maintainer defined here.
  #
  # <!-- md:inline_pro -->.
  # <!-- md:inline_version v2.1 -->.
  # Templates: allowed.
  maintainers:
    - "Foo Bar <foo at bar dot com>"

  # SPDX identifier of your app's license.
  #
  # <!-- md:inline_pro -->.
  # <!-- md:inline_version v2.1 -->.
  # Templates: allowed.
  license: "MIT"

  # Your homepage.
  #
  # <!-- md:inline_pro -->.
  # <!-- md:inline_version v2.1 -->.
  # Templates: allowed.
  homepage: "https://example.com/"

  # Your app's description.
  # Sometimes also referred as "short description".
  #
  # <!-- md:inline_pro -->.
  # <!-- md:inline_version v2.1 -->.
  # Templates: allowed.
  description: "Software to create fast and easy drum rolls."

  # Your app's full description, sometimes also referred to as "long description".
  #
  # It can be a string directly, or you can use `from_url` or `from_file` to
  # source it from somewhere else.
  #
  # <!-- md:inline_pro -->.
  # <!-- md:inline_version v2.1 -->.
  # Templates: allowed.
  full_description:
    # Loads from an URL.
    from_url:
      # Templates: allowed.
      url: https://foo.bar/README.md
      headers:
        x-api-token: "${MYCOMPANY_TOKEN}"

    # Loads from a local file.
    # Overrides `from_url`.
    from_file:
      # Templates: allowed.
      path: ./README.md

The `metadata` section in GoReleaser allows you to attach **custom metadata** to your release artifacts. By adding information such as timestamps or commit hashes, you improve traceability and consistency for your software releases.

---

## Configuration Example

```yaml
metadata:
  mod_timestamp: "{{ .CommitTimestamp }}"
```

This configuration updates the modification timestamp for all artifacts, aligning them with the commit that generated them.

---

## Key Benefits

1. **Traceability**
   Including commit timestamps in metadata makes it easy to identify when a build was created. This is invaluable for debugging and pinpointing specific versions of your artifacts.

2. **Consistency**
   Ensures that the metadata accurately reflects the project’s source code history, making it easier to correlate code changes with released artifacts.

---

## Configuration Option: `mod_timestamp`

The `mod_timestamp` option specifies the modification timestamp for your artifacts.

- **Template Variable**:
  `{{ .CommitTimestamp }}`
  This variable dynamically replaces the `mod_timestamp` with the actual timestamp of the commit, ensuring the artifacts are tightly linked to their source history.

---

# Quoting the GoReleaser documentation:

- https://goreleaser.com/customization/release/

## Metadata

GoReleaser creates some metadata files in the `dist` directory before it
finishes running.

You can also set some global defaults that can be used by other features.

```yaml title=".goreleaser.yaml"
metadata:
  # Set the modified timestamp on the metadata files.
  #
  # Templates: allowed.
  mod_timestamp: "{{ .CommitTimestamp }}"

  # The maintainers of this software.
  # Most features will only use the first maintainer defined here.
  #
  # <!-- md:inline_pro -->.
  # <!-- md:inline_version v2.1 -->.
  # Templates: allowed.
  maintainers:
    - "Foo Bar <foo at bar dot com>"

  # SPDX identifier of your app's license.
  #
  # <!-- md:inline_pro -->.
  # <!-- md:inline_version v2.1 -->.
  # Templates: allowed.
  license: "MIT"

  # Your homepage.
  #
  # <!-- md:inline_pro -->.
  # <!-- md:inline_version v2.1 -->.
  # Templates: allowed.
  homepage: "https://example.com/"

  # Your app's description.
  # Sometimes also referred as "short description".
  #
  # <!-- md:inline_pro -->.
  # <!-- md:inline_version v2.1 -->.
  # Templates: allowed.
  description: "Software to create fast and easy drum rolls."

  # Your app's full description, sometimes also referred to as "long description".
  #
  # It can be a string directly, or you can use `from_url` or `from_file` to
  # source it from somewhere else.
  #
  # <!-- md:inline_pro -->.
  # <!-- md:inline_version v2.1 -->.
  # Templates: allowed.
  full_description:
    # Loads from an URL.
    from_url:
      # Templates: allowed.
      url: https://foo.bar/README.md
      headers:
        x-api-token: "${MYCOMPANY_TOKEN}"

    # Loads from a local file.
    # Overrides `from_url`.
    from_file:
      # Templates: allowed.
      path: ./README.md
```

<!-- md:templates -->
@tmknom tmknom merged commit 0af2210 into main Jan 3, 2025
@tmknom tmknom deleted the fix/add-modification-timestamps branch January 3, 2025 09:29
@github-actions github-actions bot added the bug Something isn't working label Jan 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant