This PR consolidates the Agent and ecs-init VERSION files into a single source of truth from which we derive version in go code and RPM spec files. With these changes, we need only update the toplevel VERSION file before running version-gen.go.
Implementation details
Consolidate Agent and ecs-init VERSION files
We only need a single VERSION file because Agent and ecs-init always release together with the same version, so keep VERSION, remove ECSVERSION, and replace any references to ECSVERSION with VERSION.
Consolidate scripts for generating version.go
We have 3 different scripts for generating version.go files in Agent and ecs-init.
The original version-gen.go was in agent/version/gen. It is now in the toplevel scripts directory since it is used by both agent and ecs-init. It should be run from the root of the repo, e.g. go run scripts/version-gen.go.
Makefile targets for building .rpm/.deb package each individually ran ./scripts/update-version.sh to regenerate the ecs-init version file. I have moved this call into scripts/gobuild.sh since the .rpm/.deb package builders all eventually call gobuild.sh. gobuild.sh also uses version-gen.go instead of update-version.sh.
scripts/gobuild.sh set linker flags to override ecs-init version variables. This is how we've been able to release correctly versioned ecs-inits without committing changes to ecs-init's version.go. Setting linker flags isn't necessary anymore because we
regenerate version.go (when the script runs version-gen.go, as mentioned in the previous bullet point)
Built and installed .rpm/.deb packages on the appropriate platforms.
make amazon-linux-rpm-integrated
make generic-rpm-integrated
make generic-deb-integrated
Verified that the ecs-init version info was correct with
sudo /usr/libexec/amazon-ecs-init version
Changed the semver in the toplevel VERSION file and then rebuilt and reinstalled ecs-init.
Verified that the newly installed ecs-init version info had the new semver.
Description for the changelog
Derive version in agent, ecs-init, and .rpm/.deb packages from the toplevel VERSION file.
Licensing
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
Summary
When releasing a new version of Agent, we need to manually update version in several places before running
version-gen.go
:This PR consolidates the Agent and ecs-init VERSION files into a single source of truth from which we derive version in go code and RPM spec files. With these changes, we need only update the toplevel VERSION file before running
version-gen.go
.Implementation details
Consolidate Agent and ecs-init VERSION files
We only need a single VERSION file because Agent and ecs-init always release together with the same version, so keep VERSION, remove ECSVERSION, and replace any references to ECSVERSION with VERSION.
Consolidate scripts for generating
version.go
We have 3 different scripts for generating
version.go
files in Agent and ecs-init.version-gen.go
only generatesagent/version/version.go
. We commit changes to this file.update-version.sh
generatesagent/version/version.go
andecs-init/version/version.go
. We don't commit changes to either file, which is why the info in ecs-init'sversion.go
is so out-of-date.update-version
doesn't appear to be used.Update
version-gen.go
to generateversion.go
files in both theagent/version
andecs-init/version
packages. Replace references toupdate-version.sh
withversion-gen.go
. Finally, updateconfig.DefaultAgentVersion
https://github.com/aws/amazon-ecs-agent/blob/ea4ffcdd5a69b36c5a7216938949fae0b26d2b0f/ecs-init/config/common.go#L48 to useversion.Version
Derive RPM spec file version from VERSION
In our Makefile, update
rpmbuild
commands to define a%version
macro. The%version
macro will evaluate to the value in our VERSION file.In the amazon-linux-ami-integrated spec and the generic-rpm-integrated spec, replace the hard-coded version string with
%{version}
.Other notable changes
version-gen.go
was inagent/version/gen
. It is now in the toplevelscripts
directory since it is used by both agent and ecs-init. It should be run from the root of the repo, e.g.go run scripts/version-gen.go
../scripts/update-version.sh
to regenerate the ecs-init version file. I have moved this call intoscripts/gobuild.sh
since the .rpm/.deb package builders all eventually callgobuild.sh
.gobuild.sh
also usesversion-gen.go
instead ofupdate-version.sh
.scripts/gobuild.sh
set linker flags to override ecs-init version variables. This is how we've been able to release correctly versioned ecs-inits without committing changes to ecs-init'sversion.go
. Setting linker flags isn't necessary anymore because weversion.go
(when the script runsversion-gen.go
, as mentioned in the previous bullet point)version.go
(the releaser will do this when creating the release PR) https://github.com/aws/amazon-ecs-agent/blob/ea4ffcdd5a69b36c5a7216938949fae0b26d2b0f/scripts/gobuild.sh#L28-L38Testing
Built and installed .rpm/.deb packages on the appropriate platforms.
Verified that the ecs-init version info was correct with
Changed the semver in the toplevel VERSION file and then rebuilt and reinstalled ecs-init. Verified that the newly installed ecs-init version info had the new semver.
Description for the changelog
Derive version in agent, ecs-init, and .rpm/.deb packages from the toplevel VERSION file.
Licensing
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.