Skip to content

Commit 1c38c80

Browse files
authored
feat: add workflow to upload Yarn binary to GitHub Release (#74)
* feat: add upload-yarn-binary workflow * fix: add lint and remove gh installation * fix: add yarn url to output * fix: add checkout step * fix: apply changes suggested
1 parent eeb5a4a commit 1c38c80

File tree

1 file changed

+53
-0
lines changed

1 file changed

+53
-0
lines changed
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
name: Upload Yarn Binary to GitHub Release
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
yarn_version:
7+
description: 'Yarn version to upload (e.g., 4.9.1)'
8+
required: true
9+
type: string
10+
11+
jobs:
12+
upload-yarn-binary:
13+
runs-on: ubuntu-latest
14+
permissions:
15+
contents: write
16+
packages: write
17+
env:
18+
YARN_VERSION: ${{ github.event.inputs.yarn_version }}
19+
YARN_FILENAME: yarn-${{ github.event.inputs.yarn_version }}.js
20+
RELEASE_TAG: v${{ github.event.inputs.yarn_version }}
21+
outputs:
22+
download_url: ${{ steps.output-url.outputs.download_url }}
23+
steps:
24+
- name: Checkout repository
25+
uses: actions/checkout@v4
26+
27+
- name: Download yarn.js binary
28+
run: |
29+
curl -L -o "${YARN_FILENAME}" "https://repo.yarnpkg.com/${YARN_VERSION}/packages/yarnpkg-cli/bin/yarn.js"
30+
ls -lh "${YARN_FILENAME}"
31+
32+
- name: Display SHA256 checksum
33+
run: |
34+
sha256sum "${YARN_FILENAME}"
35+
36+
- name: Create or update GitHub Release
37+
env:
38+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
39+
run: |
40+
gh release view "${RELEASE_TAG}" || gh release create "${RELEASE_TAG}" --title "Yarn ${YARN_VERSION}" --notes "Yarn CLI ${YARN_VERSION} binary."
41+
42+
- name: Upload yarn.js to GitHub Release
43+
env:
44+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
45+
run: |
46+
gh release upload "${RELEASE_TAG}" "${YARN_FILENAME}" --clobber
47+
48+
- name: Output download URL
49+
id: output-url
50+
run: |
51+
url="https://github.com/${GITHUB_REPOSITORY}/releases/download/${RELEASE_TAG}/${YARN_FILENAME}"
52+
echo "Download URL: ${url}"
53+
echo "download_url=${url}" >> "${GITHUB_OUTPUT}"

0 commit comments

Comments
 (0)