-
-
Notifications
You must be signed in to change notification settings - Fork 3
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
Conversation
@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 |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
@jluque0101 You can see a test here https://github.com/Qbandev/github-tools/actions/runs/15560468684/job/43811216486 |
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" |
There was a problem hiding this comment.
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" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ls -lh "$YARN_FILENAME" | |
ls -lh "${YARN_FILENAME}" |
|
||
- name: Display SHA256 checksum | ||
run: | | ||
sha256sum "$YARN_FILENAME" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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." |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
echo "download_url=$url" >> "$GITHUB_OUTPUT" | |
echo "download_url=${url}" >> "${GITHUB_OUTPUT}" |
There was a problem hiding this 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 viaworkflow_dispatch
with ayarn_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 |
There was a problem hiding this comment.
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.
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:yarn.js
binary.Are there any issues or other links reviewers should consult to understand this pull request better?