Skip to content

[Bug]: make goreleaser fails to build a .deb file #1404

@hax0rbana-adam

Description

@hax0rbana-adam

Steps to Reproduce

  1. git clone https://github.com/smallstep/cli
  2. cd cli
  3. sudo apt install -y golang
  4. apply the patch to the Makefile from [Bug]: Compilation error during vulncheck #1403
  5. make bootstrap
  6. Install the goreleaser package
  7. Install Google Cloud CLI (gcloud)
  8. make goreleaser

Your Environment

Expected Behavior

A .deb package would be build locally without needing to register an account with Google.

Actual Behavior

$ make goreleaser
  • by using this software you agree with its EULA, available at https://goreleaser.com/eula
  • running goreleaser v2.8.2
  • skipping validate...
  • cleaning distribution directory
  • loading environment variables
  • getting and validating git state
    • git state                                      commit=bfab7772bbd208a682936e93c16f43b3098769cb branch=master current_tag=v0.28.6 previous_tag=v0.28.5 dirty=true
    • pipe skipped or partially skipped              reason=validation is disabled
  • parsing tag
  • setting defaults
    • DEPRECATED:  archives.format_overrides.format  should not be used anymore, check https://goreleaser.com/deprecations#archivesformat_overridesformat for more info
    • DEPRECATED:  archives.builds  should not be used anymore, check https://goreleaser.com/deprecations#archivesbuilds for more info
    • DEPRECATED:  nfpms.builds  should not be used anymore, check https://goreleaser.com/deprecations#nfpmsbuilds for more info
  • partial
    • adjusting environment                          by=target target=linux_amd64 dist=dist/linux_amd64
  • snapshotting
    • building snapshot...                           version=v0.28.6-next
  • running before hooks
    • running hook                                   hook=go mod download
  • ensuring distribution directory
  • setting up metadata
  • writing release metadata
  • loading go mod information
  • build prerequisites
  • building binaries
    • partial build                                  filter=target=linux_amd64_v1 matches=linux_amd64_v1
    • building                                       binary=dist/linux_amd64/default_linux_amd64_v1/bin/step
  • setting up metadata
  • storing artifacts metadata
  • running after hooks
    • running hook                                   hook=bash scripts/package-repo-import.sh step-cli v0.28.6-next
Package: step-cli
Version: v0.28.6-next
ERROR: (gcloud.artifacts.yum.import) You do not currently have an active account selected.
Please run:

  $ gcloud auth login

to obtain new credentials.

If you have already logged in with a different account, run:

  $ gcloud config set account ACCOUNT

to select an already authenticated account to use.
  ⨯ build failed after 3s                   
    error=
    │ after hook failed: hook failed: shell: 'bash scripts/package-repo-import.sh step-cli v0.28.6-next': exit status 1: Package: step-cli
    │ Version: v0.28.6-next
    │ ERROR: (gcloud.artifacts.yum.import) You do not currently have an active account selected.
    │ Please run:
    │   $ gcloud auth login
    │ to obtain new credentials.
    │ If you have already logged in with a different account, run:
    │   $ gcloud config set account ACCOUNT
    │ to select an already authenticated account to use.
make: *** [Makefile:127: goreleaser] Error 1
user@disp7125:~/cli$ find . -name '*.deb'

Additional Context

I installed gcloud to illustrate that the .deb file can not be built even with this installed. If gcloud is not installed, the error message is as follows:

$ make goreleaser
  • by using this software you agree with its EULA, available at https://goreleaser.com/eula
  • running goreleaser v2.8.2
  • skipping validate...
  • cleaning distribution directory
  • loading environment variables
  • getting and validating git state
    • git state                                      commit=bfab7772bbd208a682936e93c16f43b3098769cb branch=master current_tag=v0.28.6 previous_tag=v0.28.5 dirty=true
    • pipe skipped or partially skipped              reason=validation is disabled
  • parsing tag
  • setting defaults
    • DEPRECATED:  archives.format_overrides.format  should not be used anymore, check https://goreleaser.com/deprecations#archivesformat_overridesformat for more info
    • DEPRECATED:  archives.builds  should not be used anymore, check https://goreleaser.com/deprecations#archivesbuilds for more info
    • DEPRECATED:  nfpms.builds  should not be used anymore, check https://goreleaser.com/deprecations#nfpmsbuilds for more info
  • partial
    • adjusting environment                          by=target target=linux_amd64 dist=dist/linux_amd64
  • snapshotting
    • building snapshot...                           version=v0.28.6-next
  • running before hooks
    • running hook                                   hook=go mod download
  • ensuring distribution directory
  • setting up metadata
  • writing release metadata
  • loading go mod information
  • build prerequisites
  • building binaries
    • partial build                                  filter=target=linux_amd64_v1 matches=linux_amd64_v1
    • building                                       binary=dist/linux_amd64/default_linux_amd64_v1/bin/step
  • setting up metadata
  • storing artifacts metadata
  • running after hooks
    • running hook                                   hook=bash scripts/package-repo-import.sh step-cli v0.28.6-next
Package: step-cli
Version: v0.28.6-next
scripts/package-repo-import.sh: line 49: gcloud: command not found
  ⨯ build failed after 1s                   
    error=
    │ after hook failed: hook failed: shell: 'bash scripts/package-repo-import.sh step-cli v0.28.6-next': exit status 127: Package: step-cli
    │ Version: v0.28.6-next
    │ scripts/package-repo-import.sh: line 49: gcloud: command not found
make: *** [Makefile:127: goreleaser] Error 1
$ find . -name '*.deb'
$

To fix this, "variables" and "check_boxes" need to be removed from .goreleaser.yml (patch below) then goreleaser release --snapshot --clean --skip sign will get further.

diff --git a/.goreleaser.yml b/.goreleaser.yml
index 5a9930ce..d536c9d4 100644
--- a/.goreleaser.yml
+++ b/.goreleaser.yml
@@ -3,19 +3,19 @@
 version: 2
 project_name: step
 
-variables:
-  packageName: step-cli
-  packageRelease: 1 # Manually update release: in the nfpm section to match this value if you change this
+#variables:
+#  packageName: step-cli
+#  packageRelease: 1 # Manually update release: in the nfpm section to match this value if you change this
 
 before:
   hooks:
     - go mod download
 
-after:
-  hooks:
-    # This script depends on IS_PRERELEASE env being set. This is set by CI in the Is Pre-release step.
-    - cmd: bash scripts/package-repo-import.sh {{ .Var.packageName }} {{ .Version }}
-      output: true
+#after:
+#  hooks:
+#    # This script depends on IS_PRERELEASE env being set. This is set by CI in the Is Pre-release step.
+#    - cmd: bash scripts/package-repo-import.sh {{ .Var.packageName }} {{ .Version }}
+#      output: true
 
 builds:
   - &BUILD
@@ -96,7 +96,7 @@ nfpms:
     id: packages
     builds:
       - nfpm
-    package_name: "{{ .Var.packageName }}"
+    package_name: "step-cli"
     release: "1"
     file_name_template: >-
       {{- trimsuffix .ConventionalFileName .ConventionalExtension -}}
@@ -160,7 +160,7 @@ publishers:
 - name: Google Cloud Artifact Registry
   ids:
   - packages
-  cmd: ./scripts/package-upload.sh {{ abs .ArtifactPath }} {{ .Var.packageName }} {{ .Version }} {{ .Var.packageRelease }}
+  cmd: ./scripts/package-upload.sh {{ abs .ArtifactPath }} step-cli {{ .Version }} 1
 
 snapshot:
   version_template: "{{ .Tag }}-next"
@@ -206,10 +206,10 @@ release:
     - 📦 [step_linux_{{ .Version }}_amd64.tar.gz](https://dl.smallstep.com/gh-release/cli/gh-release-header/{{ .Tag }}/step_linux_{{ .Version }}_amd64.tar.gz)
     - 📦 [step_linux_{{ .Version }}_arm64.tar.gz](https://dl.smallstep.com/gh-release/cli/gh-release-header/{{ .Tag }}/step_linux_{{ .Version }}_arm64.tar.gz)
     - 📦 [step_linux_{{ .Version }}_armv7.tar.gz](https://dl.smallstep.com/gh-release/cli/gh-release-header/{{ .Tag }}/step_linux_{{ .Version }}_armv7.tar.gz)
-    - 📦 [step-cli_{{ replace .Version "-" "." }}-{{ .Var.packageRelease }}_amd64.deb](https://dl.smallstep.com/gh-release/cli/gh-release-header/{{ .Tag }}/step-cli_{{ replace .Version "-" "." }}-{{ .Var.packageRelease }}_amd64.deb)
-    - 📦 [step-cli-{{ replace .Version "-" "." }}-{{ .Var.packageRelease }}.x86_64.rpm](https://dl.smallstep.com/gh-release/cli/gh-release-header/{{ .Tag }}/step-cli-{{ replace .Version "-" "." }}-{{ .Var.packageRelease }}.x86_64.rpm)
-    - 📦 [step-cli_{{ replace .Version "-" "." }}-{{ .Var.packageRelease }}_arm64.deb](https://dl.smallstep.com/gh-release/cli/gh-release-header/{{ .Tag }}/step-cli_{{ replace .Version "-" "." }}-{{ .Var.packageRelease }}_arm64.deb)
-    - 📦 [step-cli-{{ replace .Version "-" "." }}-{{ .Var.packageRelease }}.aarch64.rpm](https://dl.smallstep.com/gh-release/cli/gh-release-header/{{ .Tag }}/step-cli-{{ replace .Version "-" "." }}-{{ .Var.packageRelease }}.aarch64.rpm)
+    - 📦 [step-cli_{{ replace .Version "-" "." }}-1_amd64.deb](https://dl.smallstep.com/gh-release/cli/gh-release-header/{{ .Tag }}/step-cli_{{ replace .Version "-" "." }}-1_amd64.deb)
+    - 📦 [step-cli-{{ replace .Version "-" "." }}-1.x86_64.rpm](https://dl.smallstep.com/gh-release/cli/gh-release-header/{{ .Tag }}/step-cli-{{ replace .Version "-" "." }}-1.x86_64.rpm)
+    - 📦 [step-cli_{{ replace .Version "-" "." }}-1_arm64.deb](https://dl.smallstep.com/gh-release/cli/gh-release-header/{{ .Tag }}/step-cli_{{ replace .Version "-" "." }}-{{ .Var.packageRelease }}_arm64.deb)
+    - 📦 [step-cli-{{ replace .Version "-" "." }}-1.aarch64.rpm](https://dl.smallstep.com/gh-release/cli/gh-release-header/{{ .Tag }}/step-cli-{{ replace .Version "-" "." }}-1.aarch64.rpm)
     - see `Assets` below for more builds
 
     #### macOS Darwin
@@ -407,7 +407,7 @@ winget:
       pull_request:
         # Whether to enable it or not.
         enabled: true
-        check_boxes: true
+        #check_boxes: true
         # Whether to open the PR as a draft or not.
         #
         # Default: false

I'm not sure why the .goreleaser.yml file needs the above modifications, but goreleaser release will refuse to run as long as those are there. Mainly I just wanted to provide a workaround that would allow people to build their own .deb package locally until this can be fixed properly.

After the workaround is applied, the .deb files are there:

$ find . -name '*.deb'
./dist/step-cli_0.28.6~next-1_amd64.deb
./dist/step-cli_amd64.deb
./dist/step-cli_0.28.6~next-1_arm64.deb
./dist/step-cli_arm64.deb

Contributing

Vote on this issue by adding a 👍 reaction.
To contribute a fix for this issue, leave a comment (and link to your pull request, if you've opened one already).

Metadata

Metadata

Assignees

Labels

bugneeds triageWaiting for discussion / prioritization by team

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions