lightninglabs / taproot-assets

A layer 1 daemon, for the Taproot Assets Protocol specification, written in Go (golang)
MIT License
460 stars 110 forks source link

[feature]: Ensure Golang Version 1.22.3 for `make release` Command to Reproduce Release Manifest #1045

Closed ffranr closed 2 months ago

ffranr commented 2 months ago

Description:

The overall goal is to be able to reproduce a release manifest file. In order to reproduce the digest hashes in the manifest file of a given release, the correct Golang version must be used when building the binaries. Therefore, the make release command needs to assert the correct Golang version. If the Golang version is incorrect, the command should exit with an error message.

Considerations and Modifications:

Acceptance Criteria:

ffranr commented 2 months ago

Useful snippets:

Modification to Makefile

release:
    @$(call print, "Releasing tapd and tapcli binaries.")
    $(VERSION_CHECK)
    ./scripts/release.sh build-release "$(VERSION_TAG)" "$(BUILD_SYSTEM)" "$(RELEASE_TAGS)" "$(RELEASE_LDFLAGS)" "$(GO_VERSION)"

Modification to ./scripts/release.sh

#!/bin/bash

REQUIRED_GO_VERSION=$6

if [ -n "$REQUIRED_GO_VERSION" ]; then
  # Check the current Golang version
  CURRENT_GO_VERSION=$(go version | grep -oP 'go\K[0-9]+\.[0-9]+\.[0-9]+')

  if [ "$CURRENT_GO_VERSION" != "$REQUIRED_GO_VERSION" ]; then
    echo "Error: Golang version $CURRENT_GO_VERSION found, but $REQUIRED_GO_VERSION is required."
    exit 1
  fi
fi

# Proceed with the rest of the script
gijswijs commented 2 months ago

While we're at it, maybe also check for unclean working directory?

Something like:

if output=$(git status --porcelain) && [ -z "$output" ]; then
  # Working directory clean
else 
  # Uncommitted changes
fi
Roasbeef commented 2 months ago

You can have Go download and manage certain versions: https://go.dev/doc/manage-install

There's also this: https://go.dev/doc/toolchain, which lets you add an env variable GOTOOLCHAIN.

Roasbeef commented 2 months ago

Re coveralls:

cc @jharveyb

ffranr commented 2 months ago

You can have Go download and manage certain versions: https://go.dev/doc/manage-install

There's also this: https://go.dev/doc/toolchain, which lets you add an env variable GOTOOLCHAIN.

Thanks, that's good to know. I'm keen on adding GOTOOLCHAIN.