Giter VIP home page Giter VIP logo

Comments (27)

gr2m avatar gr2m commented on May 24, 2024

Could the build files live in a separate branch? Then you could use https://www.npmjs.com/package/gh-pages-deploy for it. We use it do push docs after a deploy, e.g. for https://github.com/hoodiehq/pouchdb-hoodie-api, see https://github.com/hoodiehq/pouchdb-hoodie-api/blob/master/.travis.yml#L24

from semantic-release.

kentcdodds avatar kentcdodds commented on May 24, 2024

Hi @gr2m. I want the built files to live in the tagged version because that's how bower works. It doesn't make a difference what branch it's in.

from semantic-release.

gr2m avatar gr2m commented on May 24, 2024

Then you can achieve that with

  1. On traves in after_success, run the build task which builds into /dist or similar
  2. Copy / create bower.json file in dist/ folder
  3. Use gh-pages-deploy to push contents of /dist folder to a dist branch on GitHub
  4. Point bower to the dist branch

That should work, right?

from semantic-release.

kentcdodds avatar kentcdodds commented on May 24, 2024

Seems like it should. How do I authorize travis to commit to my repo?

from semantic-release.

gr2m avatar gr2m commented on May 24, 2024

Travis already has the github token, so we use a smal script for that:
https://github.com/hoodiehq/pouchdb-hoodie-api/blob/master/bin/authorize-push.js

and run it in predeploydocs

from semantic-release.

kentcdodds avatar kentcdodds commented on May 24, 2024

That looks awesome! Mind open sourcing that so I (and others) can just npm install?

from semantic-release.

gr2m avatar gr2m commented on May 24, 2024

Not at all! I'll leave it to @boennemann, just to make sure there is no simpler solution for the root problem you have. Also it's his work, so honor to whom honor is due. Okay for you to copy & paste this for the time being?

from semantic-release.

kentcdodds avatar kentcdodds commented on May 24, 2024

no problem. I'll let you know how it goes :-)

from semantic-release.

kentcdodds avatar kentcdodds commented on May 24, 2024

Alright, so I've gotten something that works really well. Here's my semantic-release process: https://github.com/formly-js/angular-formly/blob/master/package.json#L32

semantic-release pre && npm run build && npm publish && semantic-release post && npm run publish:latest

Note: I need to run the build after pre because my build depends on the package.json version because I publish the version as part of my library (similar to what angular or react do).

Then the publish:latest is this script which essentially:

  1. checks out the latest branch
  2. merges master
  3. adds the dist directory (the generated files needed for bower)
  4. commits it with the version as the message
  5. Moves the tag that semantic-release just created
  6. Force pushes (so the tag gets moved to the commit with the dist directory).

However, I think this is causing some odd behavior. If you look at my releases you'll see that the changelog is getting stacked. Each release has the changes from the previous releases as well as its own. If you look at the output from the travis build you'll see that semantic-release is: "Generating changelog from v6.24.21 to HEAD..." every single release.

Any tips on how I could accomplish what I'm trying to do, but fix the changelog issue are appreciated!

from semantic-release.

kentcdodds avatar kentcdodds commented on May 24, 2024

So I've changed a few things and now we no longer need to move the release tag (which is great). Here's how things look now:

semantic-release pre && npm run build && npm publish && npm run publish:latest && semantic-release post

So publish:latest has moved in front of semantic-release post and here's what it's doing now:

  1. checks out the latest branch
  2. merges master
  3. adds the dist directory (the generated files needed for bower)
  4. commits it with the version as the message
  5. Force pushes latest (in case there is some kind of divergence for some reason).

All that's changed is I'm no longer moving the tag because it doesn't exist yet. This seems to work great. The only problem is that it's still generating the changelog from 6.24.21 so every release the changelog gets bigger and bigger filled with stuff that's been released before.

from semantic-release.

kentcdodds avatar kentcdodds commented on May 24, 2024

I think I've found the problem. When I run git describe --tags --abbrev=0 in my repo, I get back v6.24.21. I'm not sure why it's not showing me the actual latest. Any tips appreciated!

from semantic-release.

kentcdodds avatar kentcdodds commented on May 24, 2024

I figured out that because I'm actually committing my tags on the latest branch, I need to change the branch to latest before conventional-changelog runs git describe --tags --abbrev=0. Still working out a few kinks. Hopefully I'll be able to create a plugin to suit this use case better in the future when I'm done :-)

from semantic-release.

kentcdodds avatar kentcdodds commented on May 24, 2024

Alrighty! I've got it. It's kinda crazy, but it totally works. I'm all set!

from semantic-release.

apowers313 avatar apowers313 commented on May 24, 2024

hi @kentcdodds -- I was just trying to figure out how to get semantic-release to push to Bower when I came across this post. Do you have some code you can share?

from semantic-release.

kentcdodds avatar kentcdodds commented on May 24, 2024

Sure, if you look at my comments, I describe exactly what my code does and where it is. You need to alter the semantic-release script slightly and you'll need to have a script which commits built files and pushes them to a branch (I use latest). In addition, you'll need to either re-use your GH_TOKEN on this line or do what I did and have a BOT_GH_TOKEN which is a token for a bot account.

I'm hoping to make this a plugin eventually. Good luck!

from semantic-release.

tlvince avatar tlvince commented on May 24, 2024

I've been using a similar script for sometime now and whilst it's a little hacky, it works. I've written up my workflow in tlvince/tlvince-semantic-release-push-dist, but I'd also love to see a plugin that implements this more robustly.

from semantic-release.

kentcdodds avatar kentcdodds commented on May 24, 2024

That is quite similar. I'm working on something right now. Hopefully I'll
have it before too long.

-Kent C. Dodds

On Tue, Sep 15, 2015 at 12:56 PM, Tom Vincent [email protected]
wrote:

I've been using a similar script for sometime now and whilst it's a little
hacky, it works. I've written up my workflow in
tlvince/tlvince-semantic-release-push-dist
https://github.com/tlvince/tlvince-semantic-release-push-dist, but I'd
also love to see a plugin that implements this more robustly.


Reply to this email directly or view it on GitHub
#75 (comment)
.

from semantic-release.

kentcdodds avatar kentcdodds commented on May 24, 2024

Alrighty, I've open sourced my script. It seems to work great :-) http://npm.im/publish-latest

from semantic-release.

juristr avatar juristr commented on May 24, 2024

I have the exact same problem with semantic release & bower. Used to have the dist folder in master and to compile it just before creating a new release (really tedious work..).

@kentcdodds Ok, so if I got you correctly, Travis is listening for changes on master, builds etc, uses semantic-release and your script to publish the dist files to latest which you then tag. You cannot push the dist to master 'cause that would end in an infinite loop 😄. Did I get that correctly?

from semantic-release.

juristr avatar juristr commented on May 24, 2024

@kentcdodds Hmm..ok. Set it up. Publishing to npm etc works. Tried to hook in your publish-latest plugin, but it failed. Any idea why: https://travis-ci.org/Swimlane/angular-model-factory/builds/82403298

...
> [email protected] postpublish .
> publish-latest
stderr: fatal: 'travis/temp' does not appear to be a git repository
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
fatal: Cannot update paths and switch to branch 'dist' at the same time.
Did you intend to checkout 'package.json' which can not be resolved as commit?
stdout: > PL >> setting global git config: latest,
> PL >> running git config --global user.email
> PL >> running git config --global user.name "latest"
> PL >> setting remote
> PL >> running git remote set-url origin travis/temp
> PL >> checking for dist package.json branch
> PL >> dist package.json does not exist on remote... creating it...
> PL >> running git checkout -b dist package.json
...

I don't get why it says this: Please make sure you have the correct access rights. 'Cause the push of the semantic-release created tag and GitHub release works just fine.

And it also seems to do a weird thing:

image

Any idea?

Thx!

from semantic-release.

kentcdodds avatar kentcdodds commented on May 24, 2024

@juristr, you'd be fine to have a dist in master. Travis just runs the build as normal and it simply commits your built files and pushes them to latest. It explicitly adds dist and package.json (with -f so it works even if they're .gitignored) (the files it adds is configurable). Glad you got it working!

Oh, also, I recommend you do this also, to prevent building the latest branch.

from semantic-release.

juristr avatar juristr commented on May 24, 2024

Oh, also, I recommend you do this also, to prevent building the latest branch.

@kentcdodds 👍 thx for the hint.

from semantic-release.

tlvince avatar tlvince commented on May 24, 2024

For reference, I recently packaged up two other approaches:

  • publish-repo: pushes dist to a separate repository
  • publish-dist: commits and pushes dist to master if the last commit was not made by itself

from semantic-release.

boennemann avatar boennemann commented on May 24, 2024

Wow these tools are all very nice 👍 Would someone mind adding them to the readme via a PR?

from semantic-release.

kentcdodds avatar kentcdodds commented on May 24, 2024

Huh... @tlvince is there a reason you didn't just use publish-latest? You know you can publish to a separate repository, to master, OR to the latest branch with it right?

from semantic-release.

tlvince avatar tlvince commented on May 24, 2024

@kentcdodds NIH? 😅 In all seriousness, I didn't realise publish-latest was that flexible; I thought it only concerned itself with one scenario (publishing to a branch). I guess I didn't look very hard! (I'd also been using the scripts in different projects for quite some time before and wanted to consolidate them).

from semantic-release.

kentcdodds avatar kentcdodds commented on May 24, 2024

That's my bad for not calling that out in the documentation well enough.

from semantic-release.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.