Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
ffranr opened this issue Jul 23, 2024 · 5 comments · Fixed by #1051
Closed
Labels
enhancement New feature or request version Issues which relate to data structure versioning

Comments

@ffranr
Copy link
Contributor

ffranr commented Jul 23, 2024

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:

  • The makefile already includes GO_VERSION = 1.22.3.
  • Pass the GO_VERSION to ./scripts/release.sh build-release in make release.
  • Modify ./scripts/release.sh to ensure that the correct version of Golang is used.
  • If the required Golang version isn't passed into ./scripts/release.sh, the script should skip the version check.
  • The linter should ensure that the golang version passed into ./scripts/release.sh build-release in make release is consistent with the version used in .github/workflows/release.yaml (this check is already in place and does not require modifications as part of this issue).

Acceptance Criteria:

  • Running make release should use Golang version 1.22.3 (current go version stipulated in the Makefile).
  • If the Golang version is not 1.22.3, the script should exit with an error message.
  • If the required Golang version isn't passed, the script should skip the version check.
  • The release manifest file can be reproduced with identical digest hashes by using the correct Golang version.
@ffranr ffranr added enhancement New feature or request version Issues which relate to data structure versioning labels Jul 23, 2024
@ffranr
Copy link
Contributor Author

ffranr commented Jul 23, 2024

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
Copy link
Contributor

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
Copy link
Member

Roasbeef commented Jul 23, 2024

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
Copy link
Member

Re coveralls:

cc @jharveyb

@ffranr
Copy link
Contributor Author

ffranr commented Jul 26, 2024

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.

@dstadulis dstadulis moved this from 🆕 New to 🏗 In progress in Taproot-Assets Project Board Jul 29, 2024
@github-project-automation github-project-automation bot moved this from 🏗 In progress to ✅ Done in Taproot-Assets Project Board Jul 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request version Issues which relate to data structure versioning
Projects
Status: ✅ Done
Development

Successfully merging a pull request may close this issue.

3 participants