Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to automate deployment of source & compiled code (excluding git history) to third-party developers?

I'm going to setup some tools/techiques/environments so that when I need to provide the source code for third-party developers, I do it without git history with some sensitive code already compiled and stripped. So I want to automate this process, so that I always provide the latest version of it without the pain of doing all necessary steps by hands everytime. I use bitbucket and git.

How can my goals be accomplished using bitbucket and git? Do I need some other tools?

P.S. Feel free to edit the question if it doesn't state clear the idea. I hope this questions is not too broad and doesn't fall under restrictions

like image 520
rightaway717 Avatar asked Sep 06 '25 03:09

rightaway717


1 Answers

Sounds like you want to write some post-commit hook. But that might be too fine grained for you. Just write the automatic steps to .git/hooks/post-commit and make that executable. You can

git --work-tree PATH_FOR_THIRD_PARTY checkout HEAD -- PUBLIC_FILES

to update the PUBLIC_FILES for your third-party developers in PATH_FOR_THIRD_PARTY, where I assume you publish the data for the third-party developers.

Then to update the compiled results you shoud write some Makefile (or similar) to produce the output in the PATH_FOR_THIRD_PARTY from your hidden files.

If you chose the right layout for your repository can just use a PUBLIC_FILES directory, to checkout all PUBLIC_FILES to PATH_FOR_THIRD_PARTY/PUBLIC_FILES.

Note that with this method the directory layout will be the same in the publishing directory and in your repository.

BTW.: If a third-party developer changes a PUBLIC_FILE in their directory, you can simply

git --work-tree PATH_FOR_THIRD_PARTY add -u

I use this method often to publish files from a git repository. You can simply

git config -g alias.public '!git --work-tree $(git config --get public.root) '
git config public.root 'PATH_FOR_THIRD_PARTY'

so you can say

git public diff --name-only

or

git public status -s -uno

I think this method is known as or similar to a detached work-tree.

If you use this method you need to checkout the files in your local repository after you did a public commit:

git public add -u; git public commit -m "John Doe changed something"
git checkout HEAD -- .

The last line updates you local work tree to align with the commit you did above.

like image 174
ikrabbe Avatar answered Sep 07 '25 20:09

ikrabbe