Skip to content

feat: add workflow to upload Yarn binary to GitHub Release #74

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

Merged
merged 5 commits into from
Jun 10, 2025

Conversation

Qbandev
Copy link
Contributor

@Qbandev Qbandev commented Jun 10, 2025

What is the current state of things and why does it need to change?

Currently, there is no automated way to upload Yarn binaries to GitHub Releases in this repository. This is needed to provide a reliable, rate-limit-free, and cost-effective way for CI pipelines and other consumers to fetch specific Yarn versions.

What is the solution your changes offer and how does it work?

This PR introduces a new GitHub Actions workflow (.github/workflows/upload-yarn-binary.yml) that allows maintainers to manually upload a specific Yarn version (e.g., 4.9.1) as a release asset. The workflow:

  • Accepts a Yarn version as input.
  • Downloads the corresponding yarn.js binary.
  • Creates or updates a GitHub Release for that version.
  • Uploads the binary as a release asset.
  • Outputs the download URL for use in CI or documentation.

Are there any issues or other links reviewers should consult to understand this pull request better?

@Qbandev Qbandev requested a review from Copilot June 10, 2025 09:50
Copilot

This comment was marked as outdated.

@Qbandev Qbandev added enhancement New feature or request team-dev-ops labels Jun 10, 2025
@Qbandev Qbandev requested a review from Copilot June 10, 2025 09:55
Copilot

This comment was marked as outdated.

@Qbandev Qbandev requested a review from Copilot June 10, 2025 10:04
Copilot

This comment was marked as outdated.

alucardzom
alucardzom previously approved these changes Jun 10, 2025
jluque0101
jluque0101 previously approved these changes Jun 10, 2025
@jluque0101
Copy link

@Qbandev is there a test where we can see this workflow in action?

curl -L -o "$YARN_FILENAME" "https://repo.yarnpkg.com/${YARN_VERSION}/packages/yarnpkg-cli/bin/yarn.js"
ls -lh "$YARN_FILENAME"

- name: Display SHA256 checksum

Choose a reason for hiding this comment

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

what is the purpose of the showing the checksum, would be worth comparing it with the expected one if happens that you can fetch it once the download is completed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

My idea was to check if we can use that checksum in the URL

@Qbandev Qbandev dismissed stale reviews from jluque0101 and alucardzom via df7148d June 10, 2025 13:11
Copilot

This comment was marked as outdated.

@Qbandev
Copy link
Contributor Author

Qbandev commented Jun 10, 2025

@Qbandev is there a test where we can see this workflow in action?

@jluque0101 You can see a test here https://github.com/Qbandev/github-tools/actions/runs/15560468684/job/43811216486
And here the custom yarn-url MetaMask/metamask-extension#33562 being used

jluque0101
jluque0101 previously approved these changes Jun 10, 2025
alucardzom
alucardzom previously approved these changes Jun 10, 2025
echo "YARN_VERSION=${{ github.event.inputs.yarn_version }}"
echo "YARN_FILENAME=yarn-${{ github.event.inputs.yarn_version }}.js"
echo "RELEASE_TAG=v${{ github.event.inputs.yarn_version }}"
} >> "$GITHUB_ENV"
Copy link
Contributor

Choose a reason for hiding this comment

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

This does not need to be a separate step. You can add in to the env key of the job.


- name: Download yarn.js binary
run: |
curl -L -o "$YARN_FILENAME" "https://repo.yarnpkg.com/${YARN_VERSION}/packages/yarnpkg-cli/bin/yarn.js"
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
curl -L -o "$YARN_FILENAME" "https://repo.yarnpkg.com/${YARN_VERSION}/packages/yarnpkg-cli/bin/yarn.js"
curl -L -o "${YARN_FILENAME}" "https://repo.yarnpkg.com/${YARN_VERSION}/packages/yarnpkg-cli/bin/yarn.js"

- name: Download yarn.js binary
run: |
curl -L -o "$YARN_FILENAME" "https://repo.yarnpkg.com/${YARN_VERSION}/packages/yarnpkg-cli/bin/yarn.js"
ls -lh "$YARN_FILENAME"
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
ls -lh "$YARN_FILENAME"
ls -lh "${YARN_FILENAME}"


- name: Display SHA256 checksum
run: |
sha256sum "$YARN_FILENAME"
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
sha256sum "$YARN_FILENAME"
sha256sum "${YARN_FILENAME}"

GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
# Create the release if it doesn't exist
gh release view "$RELEASE_TAG" || gh release create "$RELEASE_TAG" --title "Yarn $YARN_VERSION" --notes "Yarn CLI $YARN_VERSION binary."
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
gh release view "$RELEASE_TAG" || gh release create "$RELEASE_TAG" --title "Yarn $YARN_VERSION" --notes "Yarn CLI $YARN_VERSION binary."
gh release view "${RELEASE_TAG}" || gh release create "${RELEASE_TAG}" --title "Yarn ${YARN_VERSION}" --notes "Yarn CLI ${YARN_VERSION} binary."

env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh release upload "$RELEASE_TAG" "$YARN_FILENAME" --clobber
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
gh release upload "$RELEASE_TAG" "$YARN_FILENAME" --clobber
gh release upload "${RELEASE_TAG}" "${YARN_FILENAME}" --clobber

- name: Output download URL
id: output-url
run: |
url="https://github.com/${{ github.repository }}/releases/download/${RELEASE_TAG}/${YARN_FILENAME}"
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
url="https://github.com/${{ github.repository }}/releases/download/${RELEASE_TAG}/${YARN_FILENAME}"
url="https://github.com/${GITHUB_REPOSITORY}/releases/download/${RELEASE_TAG}/${YARN_FILENAME}"

id: output-url
run: |
url="https://github.com/${{ github.repository }}/releases/download/${RELEASE_TAG}/${YARN_FILENAME}"
echo "Download URL: $url"
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
echo "Download URL: $url"
echo "Download URL: ${url}"

run: |
url="https://github.com/${{ github.repository }}/releases/download/${RELEASE_TAG}/${YARN_FILENAME}"
echo "Download URL: $url"
echo "download_url=$url" >> "$GITHUB_OUTPUT"
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
echo "download_url=$url" >> "$GITHUB_OUTPUT"
echo "download_url=${url}" >> "${GITHUB_OUTPUT}"

@Qbandev Qbandev dismissed stale reviews from alucardzom and jluque0101 via 2ef7408 June 10, 2025 18:58
@Qbandev Qbandev requested a review from Copilot June 10, 2025 18:58
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

Adds a manual GitHub Actions workflow to download a specified Yarn CLI binary and upload it as a GitHub Release asset, then outputs its download URL.

  • Introduces .github/workflows/upload-yarn-binary.yml triggered via workflow_dispatch with a yarn_version input.
  • Downloads yarn.js, computes its SHA256 checksum, creates or updates the corresponding release tag, uploads the binary, and exposes the download URL.
  • Grants necessary write permissions and exposes the URL as a job output.
Comments suppressed due to low confidence (2)

.github/workflows/upload-yarn-binary.yml:29

  • Use curl's -f flag (e.g., curl -fSL) to ensure the step fails on HTTP errors (like 404), otherwise curl may download an HTML error page and subsequent steps would run against an invalid file.
curl -L -o "${YARN_FILENAME}" "https://repo.yarnpkg.com/${YARN_VERSION}/packages/yarnpkg-cli/bin/yarn.js"

.github/workflows/upload-yarn-binary.yml:24

  • [nitpick] The checkout step isn’t used in any following steps—consider removing it to reduce workflow runtime.
- name: Checkout repository

@@ -0,0 +1,53 @@
name: Upload Yarn Binary to GitHub Release
Copy link
Preview

Copilot AI Jun 10, 2025

Choose a reason for hiding this comment

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

[nitpick] Consider adding a concurrency group to prevent multiple manual dispatches from clobbering the same release simultaneously, for example:

concurrency:
  group: upload-yarn-binary-${{ github.event.inputs.yarn_version }}
  cancel-in-progress: false

Copilot uses AI. Check for mistakes.

@Qbandev Qbandev merged commit 1c38c80 into main Jun 10, 2025
18 checks passed
@Qbandev Qbandev deleted the feat-github-release branch June 10, 2025 19:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request team-dev-ops
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants