Skip to content

build(windows-builds): include installer sha in checksum file

Description

The current build process does not include the shasum for the windows installer since goreleaser does not build the actual installer file. Because of that previous step in CI (windows_installer) we need to include that file in the checksum file.

  • build(windows-builds): include installer sha in checksum file

Related Issues

Resolves #1133 (closed)

How has this been tested?

  1. Download the installer to avoid building it manually - curl -LO https://gitlab.com/gitlab-org/cli/-/releases/v1.54.0/downloads/glab_1.54.0_Windows_x86_64_installer.exe
  2. Move it to the bin directory since that's where the windows_installer CI job puts it - mv glab_1.54.0_Windows_x86_64_installer.exe bin/
  3. Build the project - GO_VERSION=1.24 goreleaser release --snapshot --clean
  4. Observe the checksum file - cat dist/checksums.txt

Example:

To avoid unnecessary steps apply the following changes to .goreleaser for testing purposes:

.goreleaser diff
diff --git a/.goreleaser.yml b/.goreleaser.yml
index 4dd686a4..7b4da7b9 100644
--- a/.goreleaser.yml
+++ b/.goreleaser.yml
@@ -6,10 +6,10 @@ release:
   extra_files:
     - glob: "./bin/*.exe"
 
-before:
-  hooks:
-    - go mod tidy
-    - make manpage
+# before:
+#   hooks:
+#     - go mod tidy
+#     - make manpage
 
 builds:
   - <<: &build_defaults
@@ -23,70 +23,70 @@ builds:
     goos: [darwin]
     goarch: [amd64, arm64]
 
-  - <<: *build_defaults
-    id: linux
-    goos: [linux]
-    goarch: ["386", arm, amd64, arm64, ppc64le]
+  # - <<: *build_defaults
+  #   id: linux
+  #   goos: [linux]
+  #   goarch: ["386", arm, amd64, arm64, ppc64le]
 
   - <<: *build_defaults
     id: windows
     goos: [windows]
     goarch: ["386", amd64]
 
-  - <<: *build_defaults
-    id: freebsd
-    goos: [freebsd]
-    goarch: ["386", amd64, arm]
+  # - <<: *build_defaults
+  #   id: freebsd
+  #   goos: [freebsd]
+  #   goarch: ["386", amd64, arm]
 
-gitlab_urls:
-  use_job_token: true
-  use_package_registry: true
+# gitlab_urls:
+#   use_job_token: true
+#   use_package_registry: true
 
-dockers:
-  - image_templates:
-      - "registry.gitlab.com/gitlab-org/cli:{{ .Tag }}-amd64"
-      - "gitlab/glab:{{ .Tag }}-amd64"
-    dockerfile: Dockerfile
-    use: buildx
-    build_flag_templates:
-      - "--pull"
-      - "--label=org.opencontainers.image.created={{.Date}}"
-      - "--label=org.opencontainers.image.name={{.ProjectName}}"
-      - "--label=org.opencontainers.image.revision={{.FullCommit}}"
-      - "--label=org.opencontainers.image.version={{.Version}}"
-      - "--label=org.opencontainers.image.source={{.GitURL}}"
-      - "--platform=linux/amd64"
-  - image_templates:
-      - "registry.gitlab.com/gitlab-org/cli:{{ .Tag }}-arm64"
-      - "gitlab/glab:{{ .Tag }}-arm64"
-    dockerfile: Dockerfile
-    use: buildx
-    build_flag_templates:
-      - "--pull"
-      - "--label=org.opencontainers.image.created={{.Date}}"
-      - "--label=org.opencontainers.image.name={{.ProjectName}}"
-      - "--label=org.opencontainers.image.revision={{.FullCommit}}"
-      - "--label=org.opencontainers.image.version={{.Version}}"
-      - "--label=org.opencontainers.image.source={{.GitURL}}"
-      - "--platform=linux/arm64"
-    goarch: arm64
-docker_manifests:
-  - name_template: "registry.gitlab.com/gitlab-org/cli:{{ .Tag }}"
-    image_templates:
-      - "registry.gitlab.com/gitlab-org/cli:{{ .Tag }}-amd64"
-      - "registry.gitlab.com/gitlab-org/cli:{{ .Tag }}-arm64"
-  - name_template: "registry.gitlab.com/gitlab-org/cli:latest"
-    image_templates:
-      - "registry.gitlab.com/gitlab-org/cli:{{ .Tag }}-amd64"
-      - "registry.gitlab.com/gitlab-org/cli:{{ .Tag }}-arm64"
-  - name_template: "gitlab/glab:{{ .Tag }}"
-    image_templates:
-      - "gitlab/glab:{{ .Tag }}-amd64"
-      - "gitlab/glab:{{ .Tag }}-arm64"
-  - name_template: "gitlab/glab:latest"
-    image_templates:
-      - "gitlab/glab:{{ .Tag }}-amd64"
-      - "gitlab/glab:{{ .Tag }}-arm64"
+# dockers:
+#   - image_templates:
+#       - "registry.gitlab.com/gitlab-org/cli:{{ .Tag }}-amd64"
+#       - "gitlab/glab:{{ .Tag }}-amd64"
+#     dockerfile: Dockerfile
+#     use: buildx
+#     build_flag_templates:
+#       - "--pull"
+#       - "--label=org.opencontainers.image.created={{.Date}}"
+#       - "--label=org.opencontainers.image.name={{.ProjectName}}"
+#       - "--label=org.opencontainers.image.revision={{.FullCommit}}"
+#       - "--label=org.opencontainers.image.version={{.Version}}"
+#       - "--label=org.opencontainers.image.source={{.GitURL}}"
+#       - "--platform=linux/amd64"
+#   - image_templates:
+#       - "registry.gitlab.com/gitlab-org/cli:{{ .Tag }}-arm64"
+#       - "gitlab/glab:{{ .Tag }}-arm64"
+#     dockerfile: Dockerfile
+#     use: buildx
+#     build_flag_templates:
+#       - "--pull"
+#       - "--label=org.opencontainers.image.created={{.Date}}"
+#       - "--label=org.opencontainers.image.name={{.ProjectName}}"
+#       - "--label=org.opencontainers.image.revision={{.FullCommit}}"
+#       - "--label=org.opencontainers.image.version={{.Version}}"
+#       - "--label=org.opencontainers.image.source={{.GitURL}}"
+#       - "--platform=linux/arm64"
+#     goarch: arm64
+# docker_manifests:
+#   - name_template: "registry.gitlab.com/gitlab-org/cli:{{ .Tag }}"
+#     image_templates:
+#       - "registry.gitlab.com/gitlab-org/cli:{{ .Tag }}-amd64"
+#       - "registry.gitlab.com/gitlab-org/cli:{{ .Tag }}-arm64"
+#   - name_template: "registry.gitlab.com/gitlab-org/cli:latest"
+#     image_templates:
+#       - "registry.gitlab.com/gitlab-org/cli:{{ .Tag }}-amd64"
+#       - "registry.gitlab.com/gitlab-org/cli:{{ .Tag }}-arm64"
+#   - name_template: "gitlab/glab:{{ .Tag }}"
+#     image_templates:
+#       - "gitlab/glab:{{ .Tag }}-amd64"
+#       - "gitlab/glab:{{ .Tag }}-arm64"
+#   - name_template: "gitlab/glab:latest"
+#     image_templates:
+#       - "gitlab/glab:{{ .Tag }}-amd64"
+#       - "gitlab/glab:{{ .Tag }}-arm64"
 
 archives:
   - id: nix
@@ -97,47 +97,47 @@ archives:
     ids: [windows]
     formats: zip
 
-nfpms:
-  - id: foo
-    package_name: glab
+# nfpms:
+#   - id: foo
+#     package_name: glab
 
-    # Build IDs for the builds you want to create NFPM packages for.
-    # Defaults to all builds.
+#     # Build IDs for the builds you want to create NFPM packages for.
+#     # Defaults to all builds.
 
-    vendor: GitLab
-    homepage: https://gitlab.com/gitlab-org/cli
-    # using service-desk email https://docs.gitlab.com/ee/user/project/service_desk.html
-    maintainer: GitLab<contact-project+gitlab-org-cli-34675721-issue-@incoming.gitlab.com>
-    description: An open source GitLab CLI tool
-    license: MIT
-    formats:
-      - apk
-      - deb
-      - rpm
-    dependencies:
-      - git
-    bindir: /usr
-    contents:
-      - src: "./share/man/man1/glab*.1"
-        dst: "/usr/share/man/man1"
+#     vendor: GitLab
+#     homepage: https://gitlab.com/gitlab-org/cli
+#     # using service-desk email https://docs.gitlab.com/ee/user/project/service_desk.html
+#     maintainer: GitLab<contact-project+gitlab-org-cli-34675721-issue-@incoming.gitlab.com>
+#     description: An open source GitLab CLI tool
+#     license: MIT
+#     formats:
+#       - apk
+#       - deb
+#       - rpm
+#     dependencies:
+#       - git
+#     bindir: /usr
+#     contents:
+#       - src: "./share/man/man1/glab*.1"
+#         dst: "/usr/share/man/man1"
 
 checksum:
   name_template: "checksums.txt"
   extra_files:
     - glob: ./bin/*installer.exe
 
-snapshot:
-  version_template: "{{ .Tag }}"
-changelog:
-  # https://goreleaser.com/customization/changelog/
-  use: gitlab
-  sort: asc
-  filters:
-    exclude:
-      - >
-        ^docs(\(.*\))*:
-      - >
-        ^test(\(.*\))*:
-      - "^Merge branch"
-      - "^chore"
-      - "^Update README.md"
+# snapshot:
+#   version_template: "{{ .Tag }}"
+# changelog:
+#   # https://goreleaser.com/customization/changelog/
+#   use: gitlab
+#   sort: asc
+#   filters:
+#     exclude:
+#       - >
+#         ^docs(\(.*\))*:
+#       - >
+#         ^test(\(.*\))*:
+#       - "^Merge branch"
+#       - "^chore"
+#       - "^Update README.md"

We are only interested in building the binary and not everything for testing purposes. Checking

cat dist/checksums.txt
   1 2935a95788e740806586c2d067a21835f7edb54ea3ed931312e6e6daed12c74c  glab_1.54.0-SNAPSHOT-ed4cda64_darwin_amd64.tar.gz
   2 b0db1ca757708d49cdf14773fcd0f5b2143a49058855c2d3c134a3857101cb5c  glab_1.54.0-SNAPSHOT-ed4cda64_darwin_arm64.tar.gz
   3 9c6a4cea3c19bc91ad88287256973442d283df7be8482845bac97397a0e930b0  glab_1.54.0-SNAPSHOT-ed4cda64_windows_386.zip
   4 c0d7bc6015f722f7009b938687aead9f007cc68791944ea92c5cf0e1b7426f59  glab_1.54.0-SNAPSHOT-ed4cda64_windows_amd64.zip
   5 8792d5ddd75199cc712649d09e34eba2edd1c7a9333d27cdb9b3cb5b0e11a295  glab_1.54.0_Windows_x86_64_installer.exe

We can see that the installer sha is present. Checking manually:

sha256sum bin/glab_1.54.0_Windows_x86_64_installer.exe
8792d5ddd75199cc712649d09e34eba2edd1c7a9333d27cdb9b3cb5b0e11a295  bin/glab_1.54.0_Windows_x86_64_installer.exe

We can confirm we have the correct sha.

Screenshots (if appropriate):

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation
  • Chore (Related to CI or Packaging to platforms)
  • Test gap
Edited by Filip Aleksic

Merge request reports

Loading