Upload Yarn Binary to GitHub Release #1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Upload Yarn Binary to GitHub Release | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| yarn_version: | |
| description: 'Yarn version to upload (e.g., 4.9.1)' | |
| required: true | |
| type: string | |
| jobs: | |
| upload-yarn-binary: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| packages: write | |
| env: | |
| YARN_VERSION: ${{ github.event.inputs.yarn_version }} | |
| YARN_FILENAME: yarn-${{ github.event.inputs.yarn_version }}.js | |
| RELEASE_TAG: v${{ github.event.inputs.yarn_version }} | |
| outputs: | |
| download_url: ${{ steps.output-url.outputs.download_url }} | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - 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}" | |
| - name: Display SHA256 checksum | |
| run: | | |
| sha256sum "${YARN_FILENAME}" | |
| - name: Create or update GitHub Release | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| gh release view "${RELEASE_TAG}" || gh release create "${RELEASE_TAG}" --title "Yarn ${YARN_VERSION}" --notes "Yarn CLI ${YARN_VERSION} binary." | |
| - name: Upload yarn.js to GitHub Release | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| 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}" | |
| echo "Download URL: ${url}" | |
| echo "download_url=${url}" >> "${GITHUB_OUTPUT}" |