Closed hoffa closed 12 months ago
Noticed that we easily parse the latest release tag using curl -s https://api.github.com/repos/aws/aws-sam-cli/releases | jq -r '.[0].tag_name'
We've now support caching with use-installer
even when version
is not specified. Going to mark this issue as completed. Feel free to open a new issue or re-open this one if there's additional questions.
Context
With https://github.com/aws-actions/setup-sam/pull/73 merged, SAM CLI is cached when
use-installer
is enabled andversion
is specified.For example:
This is beneficial for self-hosted runners that don't get a fresh machine at every workflow run.
Issue
When
version
is not specified (i.e. it uses the latest available version), it currently does not cache:https://github.com/aws-actions/setup-sam/blob/b42eb7a54dac4039080975e32860b1b30935c9af/lib/setup.js#L137-L144
https://github.com/aws-actions/setup-sam/blob/b42eb7a54dac4039080975e32860b1b30935c9af/lib/setup.js#L154-L159
Proposal
Ideally, it would do something like this when
version
is not specified:Challenges
version
field in PyPI (e.g.curl https://pypi.org/pypi/aws-sam-cli/json | jq -r .info.version
), there's no guarantee the GitHub release for that version will always exist at the same time (they're separate assets, so there can be a brief delay during releases). If we use the GitHub release directly, there's no robust way of getting the version (but could parse the title or tag).Alternatives
check-latest
fromactions/setup-go
andactions/setup-python
? GitHub-hosted runners already include SAM CLI (see e.g. https://github.com/actions/runner-images/blob/main/images/linux/Ubuntu2204-Readme.md), so perhaps by default if it finds SAM CLI is installed, it could immediately return? Might require a new major version, as it no longer installs latest version by default. Might not be a reliable way to ensure pre-installed version is functioning well. The waycheck-latest
works seems to be a little different; it's because the version can be a range, and so instead of picking whatever fits in the range from the cache, it ensures the latest version is used.