diff --git a/README.md b/README.md index e81ea14..2895c3a 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,8 @@ # install-github-release-binary -[![Build Status]](https://github.com/EricCrosson/install-github-release-binary/actions/workflows/release.yml) +[![Build Status]](https://github.com/BitGo/install-github-release-binary/actions/workflows/release.yml) -[build status]: https://github.com/EricCrosson/install-github-release-binary/actions/workflows/release.yml/badge.svg?event=push +[build status]: https://github.com/BitGo/install-github-release-binary/actions/workflows/release.yml/badge.svg?event=push **install-github-release-binary** is an opinionated GitHub Action for adding a binary from a GitHub Release to your CI `$PATH`. @@ -18,7 +18,6 @@ This action only supports installing from releases where the release: - is tagged with the full `{major}.{minor}.{patch}` semantic version - contains raw binary assets (archives not supported) -- assets are labeled with the binary name and [target triple] in the format `-` You can create compatible releases with [semantic-release], using a workflow like [semantic-release-action/rust]. @@ -32,35 +31,45 @@ Use this action in a step: ```yaml - name: Install flux-capacitor - uses: EricCrosson/install-github-release-binary@v2 + uses: BitGo/install-github-release-binary@v2 with: - targets: EricCrosson/flux-capacitor@v1 + targets: BitGo/flux-capacitor@v1 ``` > [!NOTE] > I recommend adding an explicit step name, otherwise the step will only reference -> `EricCrosson/install-github-release-binary@v2`, not your targets. +> `BitGo/install-github-release-binary@v2`, not your targets. Install multiple binaries: ```yaml - name: Install future tools - uses: EricCrosson/install-github-release-binary@v2 + uses: BitGo/install-github-release-binary@v2 with: targets: | - EricCrosson/flux-capacitor@v1 - EricCrosson/steam-locomotive@v7.5.3 - EricCrosson/hoverboard@11.7.3:sha256-8a4600be96d2ec013209042458ce97a9652fcc46c1c855d0217aa42e330fc06e + BitGo/flux-capacitor@v1 + BitGo/steam-locomotive@v7.5.3 + BitGo/hoverboard@11.7.3:sha256-8a4600be96d2ec013209042458ce97a9652fcc46c1c855d0217aa42e330fc06e ``` Install a binary from a release with multiple binaries available: ```yaml - name: Install flux-capacitor - uses: EricCrosson/install-github-release-binary@v2 + uses: BitGo/install-github-release-binary@v2 with: targets: | - EricCrosson/future-tools/flux-capacitor@v1 + BitGo/future-tools/flux-capacitor@v1 +``` + +Install a specific binary with checksum validation: + +```yaml +- name: Install argocd CLI + uses: BitGo/install-github-release-binary@v2 + with: + targets: | + argoproj/argo-cd/argocd-linux-amd64@v3.1.4:sha256-7def0aa3cc9ebcd6acdddc27244e7ea4de448d872a9ab0cf6cab4b1e653841a6 ``` ## Inputs @@ -82,11 +91,11 @@ Optionally, include: Examples: -- `EricCrosson/flux-capacitor@v1` -- `EricCrosson/flux-capacitor@v1.2` -- `EricCrosson/flux-capacitor@v1.2.3` -- `EricCrosson/flux-capacitor@v1.2.3:sha256-ad91159c656d427ad8fe5ded2946f29f3a612c6b7a4af6129e9aa85256b7299e` -- `EricCrosson/future-tools/flux-capacitor@v1` +- `BitGo/flux-capacitor@v1` +- `BitGo/flux-capacitor@v1.2` +- `BitGo/flux-capacitor@v1.2.3` +- `BitGo/flux-capacitor@v1.2.3:sha256-ad91159c656d427ad8fe5ded2946f29f3a612c6b7a4af6129e9aa85256b7299e` +- `BitGo/future-tools/flux-capacitor@v1` [semantic version number]: https://semver.org/ diff --git a/dist/index.js b/dist/index.js index c001c1b..e24125f 100644 --- a/dist/index.js +++ b/dist/index.js @@ -10119,12 +10119,17 @@ async function fetchReleaseAssetMetadataFromTag(octokit, slug, binaryName, tag, }); if (isSome(binaryName)) { const targetLabel = `${binaryName.value}-${targetTriple}`; - const asset2 = releaseMetadata.data.assets.find( + let asset2 = releaseMetadata.data.assets.find( (asset3) => asset3.label === targetLabel ); + if (asset2 === void 0) { + asset2 = releaseMetadata.data.assets.find( + (asset3) => asset3.name === binaryName.value + ); + } if (asset2 === void 0) { throw new Error( - `Expected to find asset in release ${slug.owner}/${slug.repository}@${tag} with label ${targetLabel}` + `Expected to find asset in release ${slug.owner}/${slug.repository}@${tag} with label ${targetLabel} or name ${binaryName.value}` ); } return { diff --git a/src/fetch.ts b/src/fetch.ts index 7c6ef12..f26a229 100644 --- a/src/fetch.ts +++ b/src/fetch.ts @@ -144,12 +144,22 @@ export async function fetchReleaseAssetMetadataFromTag( // When the binary name is provided, look for matching binary and target triple. if (isSome(binaryName)) { const targetLabel = `${binaryName.value}-${targetTriple}`; - const asset = releaseMetadata.data.assets.find( + + // First try to find asset by label (original behavior) + let asset = releaseMetadata.data.assets.find( (asset) => asset.label === targetLabel, ); + + // If not found by label, try to find asset by exact name match + if (asset === undefined) { + asset = releaseMetadata.data.assets.find( + (asset) => asset.name === binaryName.value, + ); + } + if (asset === undefined) { throw new Error( - `Expected to find asset in release ${slug.owner}/${slug.repository}@${tag} with label ${targetLabel}`, + `Expected to find asset in release ${slug.owner}/${slug.repository}@${tag} with label ${targetLabel} or name ${binaryName.value}`, ); } return { @@ -160,7 +170,7 @@ export async function fetchReleaseAssetMetadataFromTag( // When the binary name is not provided, support two use cases: // 1. There is only one binary uploaded to this release, a named binary. - // 2. There is an asset label matching the target triple (with no binary name). + // 2. There is an asset label or name matching the target triple (with no binary name). // In both cases, we assume that's the binary the user meant. // If there is ambiguity, exit with an error. const matchingTargetTriples = releaseMetadata.data.assets.filter(