Skip to content

Added release-bins flow to release binaries in *.tar.gz archive on release tag - #288

Open
pasquale95 wants to merge 2 commits into
mainfrom
feat/release_bins
Open

Added release-bins flow to release binaries in *.tar.gz archive on release tag#288
pasquale95 wants to merge 2 commits into
mainfrom
feat/release_bins

Conversation

@pasquale95

Copy link
Copy Markdown
Contributor

Type of change

  • New feature
  • Documentation update

Description

Ship prebuilt fabric-x-tools CLI binaries (configtxgen, configtxlator, cryptogen, fxconfig) as GitHub Release assets whenever a v* tag is pushed, mirroring the existing fabric-x-tools image release but for users who don't want to run a container.

None of the four tools depend on cgo, so all platforms cross-compile from a single ubuntu-latest runner (no QEMU, no macOS runner needed):

  • linux/amd64, linux/arm64, linux/s390x — same as the fabric-x-tools image
  • darwin/amd64, darwin/arm64 — for macOS users, since the image only ever runs on Linux

Changes:

  • Makefile: new release-bins target that cross-compiles the tools via go build (the existing bin/% rule uses go install, which can't cross-compile) and stamps Version/CommitSHA via METADATA_VAR — previously unused, so released binaries now report their real version instead of latest.
  • scripts/create-binary-package.sh: builds one <os>-<arch> target and packages it into fabric-x-tools-<target>-<version>.tar.gz (bin/ + LICENSE).
  • .github/workflows/release-binaries.yml: new workflow, independent of build-image.yml. Validates the tag, builds the 5-platform matrix, generates checksums.txt, and publishes everything to the tag's GitHub Release via softprops/action-gh-release@v2 (same action used by the fabric-x-ansible-collection release workflow). Also supports manual re-runs via workflow_dispatch.

…GitHub

Signed-off-by: pco <pasquale.convertini@ibm.com>
Signed-off-by: pco <pasquale.convertini@ibm.com>

@mbrandenburger mbrandenburger left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @pasquale95 for this PR! Great stuff! Please see my comments below.

env:
TARGET: ${{ matrix.os }}-${{ matrix.arch }}
RELEASE: ${{ needs.prepare.outputs.tag }}
REVISION: ${{ github.sha }}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am wondering if github.sha is correct here as it might not match the tag version we are trying to build here. If you just drop it here, your script will default to git rev-parse HEAD, which is in any case the correct checkout out version. Can we double check this somehow?

Comment thread Makefile
Comment on lines +74 to +75
$(RELEASE_DIR)/%: GO_LDFLAGS = $(METADATA_VAR:%=-X $(PKGNAME)/common/metadata.%)
$(RELEASE_DIR)/%:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to add a FORCE prerequisite to ensure that we correctly rebuilding?!

Comment thread Makefile
$(RELEASE_DIR)/%:
@echo "Building $@"
@mkdir -p $(@D)
CGO_ENABLED=0 GOOS=$(GOOS) GOARCH=$(GOARCH) $(go_cmd) build -trimpath \

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you check that these go flags are consistent with the docker-based builds, in particular the use of cgo?

Comment thread Makefile
RELEASE_BIN_DIR = $(RELEASE_DIR)/$(GOOS)-$(GOARCH)/bin

.PHONY: release-bins
release-bins: $(TOOLS_EXES:%=$(RELEASE_BIN_DIR)/%) ## Cross-compiles all tools for $(GOOS)/$(GOARCH) into $(RELEASE_DIR)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am wondering what we should do with idemixgen as this is part of the docker-based build. It's kind of inconsistent.

Comment on lines +106 to +109
- name: Publish release assets
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ needs.prepare.outputs.tag }}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

depending on the tag, we may want to set prerelease: true, for instance, on a tag like v1.2.0-rc1. Something like prerelease: ${{ contains(needs.prepare.outputs.tag, '-') }} could help.

runs-on: ubuntu-latest
outputs:
tag: ${{ steps.extract.outputs.tag }}
version: ${{ steps.extract.outputs.version }}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we use the version output?

Comment on lines +43 to +46
RELEASE_DIR="release/${TARGET}"
echo "Building ${TARGET} binaries for ${RELEASE} (${REVISION})..."
make release-bins GOOS="${GOOS}" GOARCH="${GOARCH}" RELEASE_DIR=release \
METADATA_VAR="Version=${VERSION} CommitSHA=${REVISION}"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it seems that the script assumes we run it from the root folder. If invoked from the script folder it won't be happy. Probably ok - maybe some more bash magic needed to make this more robust?

Comment thread Makefile
Comment on lines +67 to +68
GOOS ?= $(shell go env GOOS)
GOARCH ?= $(shell go env GOARCH)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
GOOS ?= $(shell go env GOOS)
GOARCH ?= $(shell go env GOARCH)
# Resolved on first use and then cached, so `go env` is never invoked for
# targets that don't need it (help, lint, test) nor when GOOS/GOARCH are preset.
GOOS ?= $(eval GOOS := $(shell $(go_cmd) env GOOS))$(GOOS)
GOARCH ?= $(eval GOARCH := $(shell $(go_cmd) env GOARCH))$(GOARCH)

Comment thread Makefile
Comment on lines +71 to +72
.PHONY: release-bins
release-bins: $(TOOLS_EXES:%=$(RELEASE_BIN_DIR)/%) ## Cross-compiles all tools for $(GOOS)/$(GOARCH) into $(RELEASE_DIR)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
.PHONY: release-bins
release-bins: $(TOOLS_EXES:%=$(RELEASE_BIN_DIR)/%) ## Cross-compiles all tools for $(GOOS)/$(GOARCH) into $(RELEASE_DIR)
# The per-binary targets are named in the recipe rather than in the prerequisite
# list: prerequisites are expanded when the makefile is parsed, which would
# resolve GOOS/GOARCH on every make invocation.
.PHONY: release-bins
release-bins: ## Cross-compiles all tools for $(GOOS)/$(GOARCH) into $(RELEASE_DIR)
@$(MAKE) --no-print-directory GOOS=$(GOOS) GOARCH=$(GOARCH) \
$(TOOLS_EXES:%=$(RELEASE_BIN_DIR)/%)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants