ºÝºÝߣ

ºÝºÝߣShare a Scribd company logo
Using a Private Git Server
for Packaging Software
Git for fun and profit at iThemes
Collaboration Problems
¡ñ Everyone had to coordinate in order to
make code changes
¡ñ Only one of us could modify a specific
file at any time
¡ñ If we ever made a mistake, we could lose
code and possibly lose hours or days of
effort
Collaboration Solution: Git
¡ñ Developers can work on the same projects
without having to coordinate each change
¡ñ Work cannot be accidentally lost or
overwritten
¡ñ A full history of all the changes, including
who made the last change to individual file
lines in case there are any questions or
concerns, is built into every repository
Git Workflow Example
$ git init
Initialized empty Git repository in git-
test/.git/
$ echo "Testing" > new-file
$ git add new-file
$ git commit -m 'Added new-file'
[master (root-commit) c6ecaa7] Added new-
file
1 file changed, 1 insertion(+)
create mode 100644 new-file
Hosting Problems
Git may be decentralized, but we still needed a
central authority to send code to. This meant
that we needed a server solution.
¡ñ Needed to scale to an unknown number of
collaborators
¡ñ Needed to scale to an unknown number of
repositories
¡ñ Needed control in order to add advanced
¡°hooks¡± (discussed later)
¡ñ Needed to do so in a cost-effective manner
Hosting Solution: Gitosis
¡ñ Self-managed centralized server that all
code changes are sent to
¡ñ Unlimited repositories and unlimited users
¡ñ Large number of hooks that can be used to
run code when changes are made to
repositories
¡ñ Per-user permissions for repository access
Since Gitosis is no longer actively maintained, I
would use Gitolite if I were starting over today.
Remote and Local Repositories
When using a Git server such as Gitosis, a
repository lives on the server. This is the
remote repository.
Our developers clone (make a copy) of the
remote repository. This is the local repository. A
developer makes modifications to their local
repository and sends the changes back to the
remote repository.
Remote and Local Repositories
Workflow
$ git clone git@example.com:example-repo
...
$ cd example-repo/
$ echo "Testing" > new-file
$ git add new-file
$ git commit -m 'Added new-file'
...
$ git push
Counting objects: 4, done.
Delta compression using up to 8 threads.
...
As developers of WordPress plugins and
themes, our products are given to customers as
zip files.
We used to create these manually.
There had to be a better way.
Packaging Problems
Packaging Solution: Git Hooks
Git provides a large number of hooks that can
execute code when a repository changes.
The post-receive hook runs after changes
have been pushed to a remote repository (the
repository hosted by the Git server, Gitosis). By
modifying this hook, we can perform actions
after changes are received by the server.
post-receive Hook Example
#!/bin/sh
# Run packager
/usr/local/bin/git-post-receive-hook
"" "$1" "$2" "$3"
git-post-receive-hook Script
Packaging Example
#!/bin/bash
repo=$(basename `pwd`|sed 's/.git$//')
temp_dir=`mktemp -d`
cd $temp_dir
git clone git@git.example.com:$repo
cd $repo
git submodule update --init --recursive
find . -name ".git*" -exec rm -rf {} ;
cd ..
zip -r $repo.zip $repo
mv $repo.zip /home/site/html/releases
Deployment Problems
Just as we used to generate zip files manually,
we used to upload files for our customers
manually as well.
Since we now had an automated system to
generate zip files, it only made sense to also
automate the distribution of these files.
Deployment Solution: Git Hooks
With some modifications to our git-post-
receive-hook script, we could easily send
the files anywhere we needed them.
git-post-receive-hook Script
Deployment Example
# Code from packaging example
zip=/home/site/html/releases/$repo.zip
# Send to membership server
scp $zip user@server:html/member/downloads
# Send to S3 storage
s3cmd -c /root/.s3cfg --no-progress put $zip
s3://downloads.example.com/products
Other Features: Easily Share Code
Across Projects
Git supports nesting a repository inside a
directory of another repository. These nested
repositories are called submodules.
We broke out repeated code libraries into their
own submodules. This prevents fixing a bug or
adding a feature in only some of the projects
that use the library. We¡¯ve even automated
updates to all projects that use the library each
time the library is updated.
Other Features: Simplified
WordPress Localization Domains
WordPress has a series of localization
functions, for example:
__( ¡®Translate string¡¯, ¡®domain¡¯ );
The domain keeps the translations for each
plugin and theme separate from all the other
plugins and themes. This means that it needs
to be unique for each.
Other Features: Simplified
WordPress Localization Domains
We¡¯ve simplified this with our packager. All of
our projects use the domain of ¡®LION¡¯:
__( ¡®Translate string¡¯, ¡®LION¡¯ );
The packager then takes care of changing each
instance of this domain to a generated, unique
domain that is specific to the project.
Future Feature: Unit Testing
The next feature to be integrated into our
packing system is an automated unit testing
platform. This will feature global unit tests that
apply to all projects and project-specific unit
tests.
In order for a commit to be accepted by the
remote repository, it must pass all the unit
tests.
Hosted Git Server Solutions
If you prefer to have someone else host the Git
server, you have options. Both GitHub and
Bitbucket offer great hosted solutions and
provide access to hooks for adding automated
features to your remote repositories.
Thanks
Find this presentation at chrisjean.com/200ok
Chris Jean
chrisjean.com
@chrisjean

More Related Content

What's hot (19)

Basic Git commands
Basic Git commandsBasic Git commands
Basic Git commands
Jitendra Zaa
?
Docker Best Practices Workshop
Docker Best Practices WorkshopDocker Best Practices Workshop
Docker Best Practices Workshop
Ahmed AbouZaid
?
Matt Gauger - Git & Github web414 December 2010
Matt Gauger - Git & Github web414 December 2010Matt Gauger - Git & Github web414 December 2010
Matt Gauger - Git & Github web414 December 2010
Matt Gauger
?
Bsadd training-git
Bsadd training-gitBsadd training-git
Bsadd training-git
Maksud Chowdhury
?
BSADD-Git-TRAINING
BSADD-Git-TRAININGBSADD-Git-TRAINING
BSADD-Git-TRAINING
bsadd
?
Continuous Delivery with Jenkins and Wildfly (2014)
Continuous Delivery with Jenkins and Wildfly (2014)Continuous Delivery with Jenkins and Wildfly (2014)
Continuous Delivery with Jenkins and Wildfly (2014)
Tracy Kennedy
?
Git 101 - Crash Course in Version Control using Git
Git 101 - Crash Course in Version Control using GitGit 101 - Crash Course in Version Control using Git
Git 101 - Crash Course in Version Control using Git
Geoff Hoffman
?
Git 101: Git and GitHub for Beginners
Git 101: Git and GitHub for Beginners Git 101: Git and GitHub for Beginners
Git 101: Git and GitHub for Beginners
HubSpot
?
How to create your own WordPress plugin
How to create your own WordPress pluginHow to create your own WordPress plugin
How to create your own WordPress plugin
John Tighe
?
Using Docker for Testing
Using Docker for TestingUsing Docker for Testing
Using Docker for Testing
Carlos Sanchez
?
Make It Cooler: Using Decentralized Version Control
Make It Cooler: Using Decentralized Version ControlMake It Cooler: Using Decentralized Version Control
Make It Cooler: Using Decentralized Version Control
indiver
?
Real time web
Real time webReal time web
Real time web
Medhat Dawoud
?
Continuous Updating with VersionEye at code.talks 2014
Continuous Updating with VersionEye at code.talks 2014Continuous Updating with VersionEye at code.talks 2014
Continuous Updating with VersionEye at code.talks 2014
Robert Reiz
?
Using the GitHub App to Connect to Bitbucket
Using the GitHub App to Connect to BitbucketUsing the GitHub App to Connect to Bitbucket
Using the GitHub App to Connect to Bitbucket
Liam Dempsey
?
Using CI for continuous delivery Part 3
Using CI for continuous delivery Part 3Using CI for continuous delivery Part 3
Using CI for continuous delivery Part 3
Vishal Biyani
?
Using CI for continuous delivery Part 4
Using CI for continuous delivery Part 4Using CI for continuous delivery Part 4
Using CI for continuous delivery Part 4
Vishal Biyani
?
Intro to Github Actions @likecoin
Intro to Github Actions @likecoinIntro to Github Actions @likecoin
Intro to Github Actions @likecoin
William Chong
?
Performance Testing using Real Browsers with JMeter & Webdriver
Performance Testing using Real Browsers with JMeter & WebdriverPerformance Testing using Real Browsers with JMeter & Webdriver
Performance Testing using Real Browsers with JMeter & Webdriver
BlazeMeter
?
Mongo db bangalore 2012
Mongo db bangalore 2012Mongo db bangalore 2012
Mongo db bangalore 2012
MongoDB
?
Docker Best Practices Workshop
Docker Best Practices WorkshopDocker Best Practices Workshop
Docker Best Practices Workshop
Ahmed AbouZaid
?
Matt Gauger - Git & Github web414 December 2010
Matt Gauger - Git & Github web414 December 2010Matt Gauger - Git & Github web414 December 2010
Matt Gauger - Git & Github web414 December 2010
Matt Gauger
?
BSADD-Git-TRAINING
BSADD-Git-TRAININGBSADD-Git-TRAINING
BSADD-Git-TRAINING
bsadd
?
Continuous Delivery with Jenkins and Wildfly (2014)
Continuous Delivery with Jenkins and Wildfly (2014)Continuous Delivery with Jenkins and Wildfly (2014)
Continuous Delivery with Jenkins and Wildfly (2014)
Tracy Kennedy
?
Git 101 - Crash Course in Version Control using Git
Git 101 - Crash Course in Version Control using GitGit 101 - Crash Course in Version Control using Git
Git 101 - Crash Course in Version Control using Git
Geoff Hoffman
?
Git 101: Git and GitHub for Beginners
Git 101: Git and GitHub for Beginners Git 101: Git and GitHub for Beginners
Git 101: Git and GitHub for Beginners
HubSpot
?
How to create your own WordPress plugin
How to create your own WordPress pluginHow to create your own WordPress plugin
How to create your own WordPress plugin
John Tighe
?
Make It Cooler: Using Decentralized Version Control
Make It Cooler: Using Decentralized Version ControlMake It Cooler: Using Decentralized Version Control
Make It Cooler: Using Decentralized Version Control
indiver
?
Continuous Updating with VersionEye at code.talks 2014
Continuous Updating with VersionEye at code.talks 2014Continuous Updating with VersionEye at code.talks 2014
Continuous Updating with VersionEye at code.talks 2014
Robert Reiz
?
Using the GitHub App to Connect to Bitbucket
Using the GitHub App to Connect to BitbucketUsing the GitHub App to Connect to Bitbucket
Using the GitHub App to Connect to Bitbucket
Liam Dempsey
?
Using CI for continuous delivery Part 3
Using CI for continuous delivery Part 3Using CI for continuous delivery Part 3
Using CI for continuous delivery Part 3
Vishal Biyani
?
Using CI for continuous delivery Part 4
Using CI for continuous delivery Part 4Using CI for continuous delivery Part 4
Using CI for continuous delivery Part 4
Vishal Biyani
?
Intro to Github Actions @likecoin
Intro to Github Actions @likecoinIntro to Github Actions @likecoin
Intro to Github Actions @likecoin
William Chong
?
Performance Testing using Real Browsers with JMeter & Webdriver
Performance Testing using Real Browsers with JMeter & WebdriverPerformance Testing using Real Browsers with JMeter & Webdriver
Performance Testing using Real Browsers with JMeter & Webdriver
BlazeMeter
?
Mongo db bangalore 2012
Mongo db bangalore 2012Mongo db bangalore 2012
Mongo db bangalore 2012
MongoDB
?

Similar to Using a Private Git Server for Packaging Software (20)

Mini-training: Let¡¯s Git It!
Mini-training: Let¡¯s Git It!Mini-training: Let¡¯s Git It!
Mini-training: Let¡¯s Git It!
Betclic Everest Group Tech Team
?
Git training (basic)
Git training (basic)Git training (basic)
Git training (basic)
Arashdeepkaur16
?
tech winter break workshop on git &git hub.pptx
tech winter break workshop on git &git hub.pptxtech winter break workshop on git &git hub.pptx
tech winter break workshop on git &git hub.pptx
ashishraulin
?
Introduction to git & GitHub
Introduction to git & GitHubIntroduction to git & GitHub
Introduction to git & GitHub
Poornachandrakashi
?
Version Control Systems Software Engineering
Version Control Systems Software EngineeringVersion Control Systems Software Engineering
Version Control Systems Software Engineering
ssuser1c86e3
?
Git & GitLab
Git & GitLabGit & GitLab
Git & GitLab
Gaurav Wable
?
Introduction to Git and Github
Introduction to Git and Github Introduction to Git and Github
Introduction to Git and Github
Max Claus Nunes
?
Git introduction
Git introductionGit introduction
Git introduction
satyendrajaladi
?
Git and github
Git and githubGit and github
Git and github
Teodora Ahkozidou
?
Git and Github
Git and GithubGit and Github
Git and Github
Teodora Ahkozidou
?
Introduction to git and githhub with practicals.pptx
Introduction to git and githhub with practicals.pptxIntroduction to git and githhub with practicals.pptx
Introduction to git and githhub with practicals.pptx
Abdul Salam
?
Git workshop
Git workshopGit workshop
Git workshop
Reslan Al Tinawi
?
git github PPT_GDSCIIITK.pptx
git github PPT_GDSCIIITK.pptxgit github PPT_GDSCIIITK.pptx
git github PPT_GDSCIIITK.pptx
AbelPhilipJoseph
?
Git for developers
Git for developersGit for developers
Git for developers
Hacen Dadda
?
GIT By Sivakrishna
GIT By SivakrishnaGIT By Sivakrishna
GIT By Sivakrishna
Nyros Technologies
?
CSE 390 Lecture 9 - Version Control with GIT
CSE 390 Lecture 9 - Version Control with GITCSE 390 Lecture 9 - Version Control with GIT
CSE 390 Lecture 9 - Version Control with GIT
PouriaQashqai1
?
Git and Github.pptx
Git and Github.pptxGit and Github.pptx
Git and Github.pptx
Hitesh670643
?
Git Basics
Git BasicsGit Basics
Git Basics
Ryan Condron
?
Git & Github
Git & GithubGit & Github
Git & Github
Aman Lalpuria
?
Git hub
Git hubGit hub
Git hub
Nitin Goel
?

Recently uploaded (20)

Transform Your Future with Front-End Development Training
Transform Your Future with Front-End Development TrainingTransform Your Future with Front-End Development Training
Transform Your Future with Front-End Development Training
Vtechlabs
?
Computational Photography: How Technology is Changing Way We Capture the World
Computational Photography: How Technology is Changing Way We Capture the WorldComputational Photography: How Technology is Changing Way We Capture the World
Computational Photography: How Technology is Changing Way We Capture the World
HusseinMalikMammadli
?
Inside Freshworks' Migration from Cassandra to ScyllaDB by Premkumar Patturaj
Inside Freshworks' Migration from Cassandra to ScyllaDB by Premkumar PatturajInside Freshworks' Migration from Cassandra to ScyllaDB by Premkumar Patturaj
Inside Freshworks' Migration from Cassandra to ScyllaDB by Premkumar Patturaj
ScyllaDB
?
Q4 2024 Earnings and Investor Presentation
Q4 2024 Earnings and Investor PresentationQ4 2024 Earnings and Investor Presentation
Q4 2024 Earnings and Investor Presentation
Dropbox
?
30B Images and Counting: Scaling Canva's Content-Understanding Pipelines by K...
30B Images and Counting: Scaling Canva's Content-Understanding Pipelines by K...30B Images and Counting: Scaling Canva's Content-Understanding Pipelines by K...
30B Images and Counting: Scaling Canva's Content-Understanding Pipelines by K...
ScyllaDB
?
Build with AI on Google Cloud Session #4
Build with AI on Google Cloud Session #4Build with AI on Google Cloud Session #4
Build with AI on Google Cloud Session #4
Margaret Maynard-Reid
?
AIXMOOC 2.3 - Modelli di reti neurali con esperimenti di addestramento
AIXMOOC 2.3 - Modelli di reti neurali con esperimenti di addestramentoAIXMOOC 2.3 - Modelli di reti neurali con esperimenti di addestramento
AIXMOOC 2.3 - Modelli di reti neurali con esperimenti di addestramento
Alessandro Bogliolo
?
Technology use over time and its impact on consumers and businesses.pptx
Technology use over time and its impact on consumers and businesses.pptxTechnology use over time and its impact on consumers and businesses.pptx
Technology use over time and its impact on consumers and businesses.pptx
kaylagaze
?
BoxLang JVM Language : The Future is Dynamic
BoxLang JVM Language : The Future is DynamicBoxLang JVM Language : The Future is Dynamic
BoxLang JVM Language : The Future is Dynamic
Ortus Solutions, Corp
?
DAO UTokyo 2025 DLT mass adoption case studies IBM Tsuyoshi Hirayama (ƽɽÒã)
DAO UTokyo 2025 DLT mass adoption case studies IBM Tsuyoshi Hirayama (ƽɽÒã)DAO UTokyo 2025 DLT mass adoption case studies IBM Tsuyoshi Hirayama (ƽɽÒã)
DAO UTokyo 2025 DLT mass adoption case studies IBM Tsuyoshi Hirayama (ƽɽÒã)
Tsuyoshi Hirayama
?
FinTech - US Annual Funding Report - 2024.pptx
FinTech - US Annual Funding Report - 2024.pptxFinTech - US Annual Funding Report - 2024.pptx
FinTech - US Annual Funding Report - 2024.pptx
Tracxn
?
Brave Browser Crack 1.45.133 Activated 2025
Brave Browser Crack 1.45.133 Activated 2025Brave Browser Crack 1.45.133 Activated 2025
Brave Browser Crack 1.45.133 Activated 2025
kherorpacca00126
?
UiPath Automation Developer Associate Training Series 2025 - Session 2
UiPath Automation Developer Associate Training Series 2025 - Session 2UiPath Automation Developer Associate Training Series 2025 - Session 2
UiPath Automation Developer Associate Training Series 2025 - Session 2
DianaGray10
?
UiPath Agentic Automation Capabilities and Opportunities
UiPath Agentic Automation Capabilities and OpportunitiesUiPath Agentic Automation Capabilities and Opportunities
UiPath Agentic Automation Capabilities and Opportunities
DianaGray10
?
Understanding Traditional AI with Custom Vision & MuleSoft.pptx
Understanding Traditional AI with Custom Vision & MuleSoft.pptxUnderstanding Traditional AI with Custom Vision & MuleSoft.pptx
Understanding Traditional AI with Custom Vision & MuleSoft.pptx
shyamraj55
?
DealBook of Ukraine: 2025 edition | AVentures Capital
DealBook of Ukraine: 2025 edition | AVentures CapitalDealBook of Ukraine: 2025 edition | AVentures Capital
DealBook of Ukraine: 2025 edition | AVentures Capital
Yevgen Sysoyev
?
Stronger Together: Combining Data Quality and Governance for Confident AI & A...
Stronger Together: Combining Data Quality and Governance for Confident AI & A...Stronger Together: Combining Data Quality and Governance for Confident AI & A...
Stronger Together: Combining Data Quality and Governance for Confident AI & A...
Precisely
?
Unlocking DevOps Secuirty :Vault & Keylock
Unlocking DevOps Secuirty :Vault & KeylockUnlocking DevOps Secuirty :Vault & Keylock
Unlocking DevOps Secuirty :Vault & Keylock
HusseinMalikMammadli
?
UiPath Automation Developer Associate Training Series 2025 - Session 1
UiPath Automation Developer Associate Training Series 2025 - Session 1UiPath Automation Developer Associate Training Series 2025 - Session 1
UiPath Automation Developer Associate Training Series 2025 - Session 1
DianaGray10
?
Revolutionizing-Government-Communication-The-OSWAN-Success-Story
Revolutionizing-Government-Communication-The-OSWAN-Success-StoryRevolutionizing-Government-Communication-The-OSWAN-Success-Story
Revolutionizing-Government-Communication-The-OSWAN-Success-Story
ssuser52ad5e
?
Transform Your Future with Front-End Development Training
Transform Your Future with Front-End Development TrainingTransform Your Future with Front-End Development Training
Transform Your Future with Front-End Development Training
Vtechlabs
?
Computational Photography: How Technology is Changing Way We Capture the World
Computational Photography: How Technology is Changing Way We Capture the WorldComputational Photography: How Technology is Changing Way We Capture the World
Computational Photography: How Technology is Changing Way We Capture the World
HusseinMalikMammadli
?
Inside Freshworks' Migration from Cassandra to ScyllaDB by Premkumar Patturaj
Inside Freshworks' Migration from Cassandra to ScyllaDB by Premkumar PatturajInside Freshworks' Migration from Cassandra to ScyllaDB by Premkumar Patturaj
Inside Freshworks' Migration from Cassandra to ScyllaDB by Premkumar Patturaj
ScyllaDB
?
Q4 2024 Earnings and Investor Presentation
Q4 2024 Earnings and Investor PresentationQ4 2024 Earnings and Investor Presentation
Q4 2024 Earnings and Investor Presentation
Dropbox
?
30B Images and Counting: Scaling Canva's Content-Understanding Pipelines by K...
30B Images and Counting: Scaling Canva's Content-Understanding Pipelines by K...30B Images and Counting: Scaling Canva's Content-Understanding Pipelines by K...
30B Images and Counting: Scaling Canva's Content-Understanding Pipelines by K...
ScyllaDB
?
Build with AI on Google Cloud Session #4
Build with AI on Google Cloud Session #4Build with AI on Google Cloud Session #4
Build with AI on Google Cloud Session #4
Margaret Maynard-Reid
?
AIXMOOC 2.3 - Modelli di reti neurali con esperimenti di addestramento
AIXMOOC 2.3 - Modelli di reti neurali con esperimenti di addestramentoAIXMOOC 2.3 - Modelli di reti neurali con esperimenti di addestramento
AIXMOOC 2.3 - Modelli di reti neurali con esperimenti di addestramento
Alessandro Bogliolo
?
Technology use over time and its impact on consumers and businesses.pptx
Technology use over time and its impact on consumers and businesses.pptxTechnology use over time and its impact on consumers and businesses.pptx
Technology use over time and its impact on consumers and businesses.pptx
kaylagaze
?
BoxLang JVM Language : The Future is Dynamic
BoxLang JVM Language : The Future is DynamicBoxLang JVM Language : The Future is Dynamic
BoxLang JVM Language : The Future is Dynamic
Ortus Solutions, Corp
?
DAO UTokyo 2025 DLT mass adoption case studies IBM Tsuyoshi Hirayama (ƽɽÒã)
DAO UTokyo 2025 DLT mass adoption case studies IBM Tsuyoshi Hirayama (ƽɽÒã)DAO UTokyo 2025 DLT mass adoption case studies IBM Tsuyoshi Hirayama (ƽɽÒã)
DAO UTokyo 2025 DLT mass adoption case studies IBM Tsuyoshi Hirayama (ƽɽÒã)
Tsuyoshi Hirayama
?
FinTech - US Annual Funding Report - 2024.pptx
FinTech - US Annual Funding Report - 2024.pptxFinTech - US Annual Funding Report - 2024.pptx
FinTech - US Annual Funding Report - 2024.pptx
Tracxn
?
Brave Browser Crack 1.45.133 Activated 2025
Brave Browser Crack 1.45.133 Activated 2025Brave Browser Crack 1.45.133 Activated 2025
Brave Browser Crack 1.45.133 Activated 2025
kherorpacca00126
?
UiPath Automation Developer Associate Training Series 2025 - Session 2
UiPath Automation Developer Associate Training Series 2025 - Session 2UiPath Automation Developer Associate Training Series 2025 - Session 2
UiPath Automation Developer Associate Training Series 2025 - Session 2
DianaGray10
?
UiPath Agentic Automation Capabilities and Opportunities
UiPath Agentic Automation Capabilities and OpportunitiesUiPath Agentic Automation Capabilities and Opportunities
UiPath Agentic Automation Capabilities and Opportunities
DianaGray10
?
Understanding Traditional AI with Custom Vision & MuleSoft.pptx
Understanding Traditional AI with Custom Vision & MuleSoft.pptxUnderstanding Traditional AI with Custom Vision & MuleSoft.pptx
Understanding Traditional AI with Custom Vision & MuleSoft.pptx
shyamraj55
?
DealBook of Ukraine: 2025 edition | AVentures Capital
DealBook of Ukraine: 2025 edition | AVentures CapitalDealBook of Ukraine: 2025 edition | AVentures Capital
DealBook of Ukraine: 2025 edition | AVentures Capital
Yevgen Sysoyev
?
Stronger Together: Combining Data Quality and Governance for Confident AI & A...
Stronger Together: Combining Data Quality and Governance for Confident AI & A...Stronger Together: Combining Data Quality and Governance for Confident AI & A...
Stronger Together: Combining Data Quality and Governance for Confident AI & A...
Precisely
?
Unlocking DevOps Secuirty :Vault & Keylock
Unlocking DevOps Secuirty :Vault & KeylockUnlocking DevOps Secuirty :Vault & Keylock
Unlocking DevOps Secuirty :Vault & Keylock
HusseinMalikMammadli
?
UiPath Automation Developer Associate Training Series 2025 - Session 1
UiPath Automation Developer Associate Training Series 2025 - Session 1UiPath Automation Developer Associate Training Series 2025 - Session 1
UiPath Automation Developer Associate Training Series 2025 - Session 1
DianaGray10
?
Revolutionizing-Government-Communication-The-OSWAN-Success-Story
Revolutionizing-Government-Communication-The-OSWAN-Success-StoryRevolutionizing-Government-Communication-The-OSWAN-Success-Story
Revolutionizing-Government-Communication-The-OSWAN-Success-Story
ssuser52ad5e
?

Using a Private Git Server for Packaging Software

  • 1. Using a Private Git Server for Packaging Software Git for fun and profit at iThemes
  • 2. Collaboration Problems ¡ñ Everyone had to coordinate in order to make code changes ¡ñ Only one of us could modify a specific file at any time ¡ñ If we ever made a mistake, we could lose code and possibly lose hours or days of effort
  • 3. Collaboration Solution: Git ¡ñ Developers can work on the same projects without having to coordinate each change ¡ñ Work cannot be accidentally lost or overwritten ¡ñ A full history of all the changes, including who made the last change to individual file lines in case there are any questions or concerns, is built into every repository
  • 4. Git Workflow Example $ git init Initialized empty Git repository in git- test/.git/ $ echo "Testing" > new-file $ git add new-file $ git commit -m 'Added new-file' [master (root-commit) c6ecaa7] Added new- file 1 file changed, 1 insertion(+) create mode 100644 new-file
  • 5. Hosting Problems Git may be decentralized, but we still needed a central authority to send code to. This meant that we needed a server solution. ¡ñ Needed to scale to an unknown number of collaborators ¡ñ Needed to scale to an unknown number of repositories ¡ñ Needed control in order to add advanced ¡°hooks¡± (discussed later) ¡ñ Needed to do so in a cost-effective manner
  • 6. Hosting Solution: Gitosis ¡ñ Self-managed centralized server that all code changes are sent to ¡ñ Unlimited repositories and unlimited users ¡ñ Large number of hooks that can be used to run code when changes are made to repositories ¡ñ Per-user permissions for repository access Since Gitosis is no longer actively maintained, I would use Gitolite if I were starting over today.
  • 7. Remote and Local Repositories When using a Git server such as Gitosis, a repository lives on the server. This is the remote repository. Our developers clone (make a copy) of the remote repository. This is the local repository. A developer makes modifications to their local repository and sends the changes back to the remote repository.
  • 8. Remote and Local Repositories Workflow $ git clone git@example.com:example-repo ... $ cd example-repo/ $ echo "Testing" > new-file $ git add new-file $ git commit -m 'Added new-file' ... $ git push Counting objects: 4, done. Delta compression using up to 8 threads. ...
  • 9. As developers of WordPress plugins and themes, our products are given to customers as zip files. We used to create these manually. There had to be a better way. Packaging Problems
  • 10. Packaging Solution: Git Hooks Git provides a large number of hooks that can execute code when a repository changes. The post-receive hook runs after changes have been pushed to a remote repository (the repository hosted by the Git server, Gitosis). By modifying this hook, we can perform actions after changes are received by the server.
  • 11. post-receive Hook Example #!/bin/sh # Run packager /usr/local/bin/git-post-receive-hook "" "$1" "$2" "$3"
  • 12. git-post-receive-hook Script Packaging Example #!/bin/bash repo=$(basename `pwd`|sed 's/.git$//') temp_dir=`mktemp -d` cd $temp_dir git clone git@git.example.com:$repo cd $repo git submodule update --init --recursive find . -name ".git*" -exec rm -rf {} ; cd .. zip -r $repo.zip $repo mv $repo.zip /home/site/html/releases
  • 13. Deployment Problems Just as we used to generate zip files manually, we used to upload files for our customers manually as well. Since we now had an automated system to generate zip files, it only made sense to also automate the distribution of these files.
  • 14. Deployment Solution: Git Hooks With some modifications to our git-post- receive-hook script, we could easily send the files anywhere we needed them.
  • 15. git-post-receive-hook Script Deployment Example # Code from packaging example zip=/home/site/html/releases/$repo.zip # Send to membership server scp $zip user@server:html/member/downloads # Send to S3 storage s3cmd -c /root/.s3cfg --no-progress put $zip s3://downloads.example.com/products
  • 16. Other Features: Easily Share Code Across Projects Git supports nesting a repository inside a directory of another repository. These nested repositories are called submodules. We broke out repeated code libraries into their own submodules. This prevents fixing a bug or adding a feature in only some of the projects that use the library. We¡¯ve even automated updates to all projects that use the library each time the library is updated.
  • 17. Other Features: Simplified WordPress Localization Domains WordPress has a series of localization functions, for example: __( ¡®Translate string¡¯, ¡®domain¡¯ ); The domain keeps the translations for each plugin and theme separate from all the other plugins and themes. This means that it needs to be unique for each.
  • 18. Other Features: Simplified WordPress Localization Domains We¡¯ve simplified this with our packager. All of our projects use the domain of ¡®LION¡¯: __( ¡®Translate string¡¯, ¡®LION¡¯ ); The packager then takes care of changing each instance of this domain to a generated, unique domain that is specific to the project.
  • 19. Future Feature: Unit Testing The next feature to be integrated into our packing system is an automated unit testing platform. This will feature global unit tests that apply to all projects and project-specific unit tests. In order for a commit to be accepted by the remote repository, it must pass all the unit tests.
  • 20. Hosted Git Server Solutions If you prefer to have someone else host the Git server, you have options. Both GitHub and Bitbucket offer great hosted solutions and provide access to hooks for adding automated features to your remote repositories.
  • 21. Thanks Find this presentation at chrisjean.com/200ok Chris Jean chrisjean.com @chrisjean