You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'd like to bundle my monorepo into a single file whenever I release and upload that as a release asset
I can do that with github actions and the github rest api, but I'd rather have changesets do that in the changesets action. It would be nice to have a hook to run my own custom build process for releases
Reacted by Kevin McGonigle, Ze-Zheng Wu, zanminkian, Guillaume Bonnet, Rasso Hilber, Eyal Lapid - LimitlessCnc, karteekiitg, Yuriy Grunin and Kane Wang
Thank you @Andarist for the reply. Allow me to elaborate:
I am participating in the development of a design system, implemented in an npm monorepo of ~20 web components. Under normal circumstances, users would load whichever components they needed via a module transforming CDN (e.g. unpkg) or with import maps (e.g. jspm), or by npm installing and bundling themselves.
However, many of our users do not want to have to install a node/npm toolchain in order to fetch and bundle our components, and they are prevented by compliance concerns from using third party CDNs like unpkg or jspm
Therefore, we'd like to provide a complete single-file bundle of our design system so that users can download a single javascript file and use it however they like.
Now, from what I gather, I can set up a workflow which bundles the monorepo and uploads it as an asset to an existing release
name: Bundleon:
release:
types:
- publishedjobs:
bundle:
runs-on: ubuntu-lateststeps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2with:
node-version: 16cache: npm
- run: npm i --prefer-offline
- run: npm run build# outputs to /releases/$GITHUB_REF/bundle.min.js
- run: node scripts/bundle-release.js
- uses: actions/github-script@v6with:
script: | // yadda yadda github.rest.repos.uploadReleaseAsset({ owner, repo, release_id, name, data, });
I think the downside to this would be the delay in between creating the release and uploading the asset
Instead, perhaps there could be some assets param to changesets action which looks for assets in a newline-separated string of filenames and attaches them if present
name: Releaseon:
push:
branches:
- main
- masterjobs:
release:
runs-on: ubuntu-lateststeps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2with:
node-version: 16cache: npm
- run: npm i --prefer-offline
- run: npm run build
- name: Create Release Pull Request or Publish to npmuses: changesets/action@v1with:
publish: npx changeset publishcommit: "chore: version packages"# files are uploaded as-is,# directories get tarballed then uploaded# changesets action could also automatically upload the npm package tarballsassets: | /releases/${{ env.GITHUB_REF }}/bundle.min.jsenv:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}NPM_TOKEN: ${{ secrets.NPM_TOKEN }}NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
Reacted by zanminkian, Alec Blance and karteekiitg
An important point I missed in yesterday's comment: the config I proposed there (assets key) would not work as shown, since the build process would need to know about the release's metadata via the env
Since changesets support monorepo and we can have several different packages released, a singular assets config might not work very well.
If changesets/action would also include release ID in the outputs.publishedPackages for every published/released item, that would help, or perhaps something similar but solely focused on outputting only for released packages.
I'm facing this issue with non-npm packages (applications), and as a workaround I'm going to use whatever is available in the outputs.publishedPackages to craft the lookup tag, then retrieve the release, using the upload URL for every release I'd then compile applications and upload to respected assets. Not ideal, but better than nothing.
It'd be greater if changesets/action could do the heavy lifting though.
I also just stumbled upon the need to upload a custom release asset to my gh releases. Turns out, finding the latest release tag and uploading a release asset to it is pretty simple using GitHub CLI, which is available in GitHub actions by default, in combination with a detection if a release was published by changesets/action:
detects if a release was published (steps.cs.outputs.published == 'true')
if so, uses gh to get the latest tag
uses gh to upload my previously generated package-name.zip to my release
I'm always pre-generating the release asset in a step before the changesets/action step, so that is readily available, should changesets decide it's time to publish a release. That way, the time between a published release and the asset being attached should be minimal.
Activity
Andarist commentedon Mar 2, 2022
Could you describe this in more detail? I'd like to understand the context behind the feature request better.
Could you roughly describe how this would work? Additional question - can assets be attached after the release is already published?
bennypowers commentedon Mar 2, 2022
Thank you @Andarist for the reply. Allow me to elaborate:
I am participating in the development of a design system, implemented in an npm monorepo of ~20 web components. Under normal circumstances, users would load whichever components they needed via a module transforming CDN (e.g. unpkg) or with import maps (e.g. jspm), or by npm installing and bundling themselves.
However, many of our users do not want to have to install a node/npm toolchain in order to fetch and bundle our components, and they are prevented by compliance concerns from using third party CDNs like unpkg or jspm
Therefore, we'd like to provide a complete single-file bundle of our design system so that users can download a single javascript file and use it however they like.
Now, from what I gather, I can set up a workflow which bundles the monorepo and uploads it as an asset to an existing release
I think the downside to this would be the delay in between creating the release and uploading the asset
Instead, perhaps there could be some
assetsparam to changesets action which looks for assets in a newline-separated string of filenames and attaches them if presentbennypowers commentedon Mar 3, 2022
An important point I missed in yesterday's comment: the config I proposed there (
assetskey) would not work as shown, since the build process would need to know about the release's metadata via the envbennypowers commentedon Sep 2, 2022
Alternatively, if changesets/action would provide the release ID as an output, users could easily modify the release after publish:
mark-omarov commentedon Dec 12, 2022
Since changesets support monorepo and we can have several different packages released, a singular assets config might not work very well.
If
changesets/actionwould also include release ID in theoutputs.publishedPackagesfor every published/released item, that would help, or perhaps something similar but solely focused on outputting only for released packages.I'm facing this issue with non-npm packages (applications), and as a workaround I'm going to use whatever is available in the
outputs.publishedPackagesto craft the lookup tag, then retrieve the release, using the upload URL for every release I'd then compile applications and upload to respected assets. Not ideal, but better than nothing.It'd be greater if
changesets/actioncould do the heavy lifting though.irshadahmad21 commentedon Jan 18, 2024
If #347 is accepted, then we should be able to upload assets to the releases.
zanminkian commentedon Jun 23, 2024
I'm facing the same problem and I need this feature too. Any progress?
MrSquaare commentedon Oct 15, 2024
@Andarist could you please take a look at the proposed PR?
cumt-robin commentedon Dec 10, 2024
This is a very meaningful feature to look forward to.
hirasso commentedon Jan 18, 2025
I also just stumbled upon the need to upload a custom release asset to my gh releases. Turns out, finding the latest release
tagand uploading a release asset to it is pretty simple using GitHub CLI, which is available in GitHub actions by default, in combination with a detection if a release was published bychangesets/action:The Upload Release Asset step:
steps.cs.outputs.published == 'true')ghto get the latest tagghto upload my previously generatedpackage-name.zipto my releaseI'm always pre-generating the release asset in a step before the changesets/action step, so that is readily available, should changesets decide it's time to publish a release. That way, the time between a published release and the asset being attached should be minimal.
This works nicely for me.