Raised This Month: $85 Target: $400
 21% 

Updater Integration Using Bitbucket


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Dr. McKay
Sir Dr. SourceMod Plugin Approver Esq. Ltd. M.D. PhD
Join Date: Aug 2011
Location: Atlantis
Old 12-22-2012 , 22:30   Updater Integration Using Bitbucket
Reply With Quote #1

Updater Integration Using Bitbucket

Bitbucket has removed the ability to use custom domain names. You can instead use the instructions at the bottom of this post to create a repository named [yourname].bitbucket.org.

Problem: You want to allow your plugin to automatically update using Updater, but you don't have a website where you can host your plugin.

Solution: Use Bitbucket! Here's how. It looks overwhelming, but you only need to do this once.

If you already know how to use Bitbucket and Mercurial, then skip to step 5.
  1. Setup
    1. First, you'll need to create an account at bitbucket.org. Bitbucket supports Git and Mercurial (hg). This tutorial will cover Mercurial.
    2. If you don't already have it, download TortoiseHg and install it. This is the Mercurial client that we'll be using.
  2. Create your repository
    1. Next, we'll create the repository that will hold our plugins. You can create a new repository for each plugin (Bitbucket offers unlimited free repositories), but since plugins generally consist of one file, I prefer to use one repository for all public plugins. Click the Repositories dropdown on Bitbucket and select Create repository.
    2. Name your repository something that you like and type a description if you want. Make sure This is a private repository is unchecked, that Mercurial is selected instead of Git, and that SourcePawn is selected as the repository's language. You may enable the Wiki and Issue Tracking if you wish.
  3. Configure your repository locally
    1. Create a folder on your local computer where you want to store the files for this repository.
    2. Right-click on the new folder you just created and select TortoiseHg > Clone....
    3. In the Source box, type https://bitbucket.org/Your_Username/your-repository-name (Your_Username should be replaced with your Bitbucket username, and your-repository-name should be replaced with your repository's name, in all lowercase, with spaces replaced with dashes). Click Clone.
    4. Right-click on your folder again and choose TortoiseHg > Repository Settings.
    5. On the Workbench tab, choose update on the After pull operation dropdown.
    6. On the Commit tab, type your Bitbucket username into the Username box. Choose default in the Push After Commit box.
    7. Click OK
  4. Configure your repository on Bitbucket
    1. On your repository's overview page, which should still be open, click the gear icon
    2. On the Username aliases tab, type your Bitbucket username into both boxes and click Add.
  5. Configure your domain
    1. Bitbucket forces all pages and code to be served over HTTPS. While this is perfectly fine with the cURL and SteamTools extensions, the Socket extension does not support HTTPS. We'll need to configure a custom domain.
    2. Go to freedns.afraid.org and register an account.
    3. After you're registered and signed in, click here to access the shared domain registry. Click a domain you like.
    4. For Type, select CNAME. For Subdomain, specify whatever you want. Your URL will take the form of subdomain-you-chose.domain-you-chose.com. For example, I might choose mckay.crabdance.com.
    5. For Destination, type bitbucket.org. This will point your subdomain at Bitbucket. Click Save.
    6. Back on Bitbucket, click your avatar in the top-right corner and choose Manage Account. Select the Custom domain tab and specify the subdomain you just registered, then click Save.
    7. Bitbucket should show you a green box telling you that your subdomain points to bitbucket.org. If it doesn't, you did something wrong.
  6. Push your code
    1. In your local repository folder, create two folders named "plugins" and "scripting". The scripting folder is where your plugins' source code will go, and plugins is for the compiled smx files.
    2. Put the plugins that you have written into the scripting folder and their smx files into the plugins folder.
    3. Integrate Updater into your plugins using the code in the Updater thread. Your update URL should look like this: http://my-url/my-repository/raw/default/my-plugin.txt
    4. Replace my-url with the URL you registered in step 5. Replace my-repository with your repository's name in lowercase, replacing spaces with dashes. Replace my-plugin.txt with the name of your plugin's update file.
    5. Place your plugin's update file, in the format specified in the Updater thread, into your repository's folder. It should be in the folder that contains the scripting and plugins folders.
    6. Right-click on your repository's folder and choose TortoiseHg > Synchronize. At the top, choose https in the dropdown menu, put bitbucket.org into the first box, and put Bitbucket_Username/repository-name in the third box, replacing Bitbucket_Username with your Bitbucket username and repository-name with your repository's name in lowercase, replacing spaces with dashes.
    7. Click the gold padlock and type your Bitbucket username and password into the username and password fields, then click Save.
    8. Click the save button on the far left, make sure the Alias field reads default, and click Save. Close the Sync window.
    9. Right-click on your repository's folder and choose Hg Commit...
    10. Type a description for this commit and click Commit. Make sure that all the files you want to commit are checked in the left pane. If a dialog asks you to add untracked files, choose Add.
You're done! Whenever you update your plugin, make sure that you put a new smx file into plugins and that you update your updater file. Then commit it in the same manner that you just did in 6i-6j.

If you commit changes from another computer, you will need to update. To do this, right-click on your repository's folder and choose TortoiseHg > Synchronize. Then click the pull button (it's the second button from the left at the top). Once the console says that the command was completed, you can close the window.

Some Tips:
  • Mercurial is a version control system. It displays all the previous edits to your files on the Commits tab.
  • Instead of updating the attachments in your plugin's thread, you can just simply link to the latest download. The smx link looks like http://my-url/my-repository/raw/default/plugins/my-plugin.smx and the source link looks like http://my-url/my-repository/raw/default/scripting/my-plugin.sp.

Update: Instead of registering a custom domain, you can create a repository named [yourbitbucketusername].bitbucket.org, and all of its contents will be available on the Web at [yourusername].bitbucket.org.

For instance, I could create a repository called Doctor_McKay.bitbucket.org with scripting and plugins folders and put all of my plugins there. Then my Updater URL would look like http://doctor_mckay.bitbucket.org/awesomeplugin.txt, with the plugin source and binaries being located at http://doctor_mckay.bitbucket.org/plugins/awesomeplugin.smx and http://doctor_mckay.bitbucket.org/scripting/awesomeplugin.sp.
__________________

Last edited by Dr. McKay; 09-04-2015 at 01:53.
Dr. McKay is offline
Sheepdude
SourceMod Donor
Join Date: Aug 2012
Location: Chicago
Old 12-23-2012 , 03:25   Re: Updater Integration Using Bitbucket
Reply With Quote #2

Nice tutorial! Having a reliable website was the one thing keeping me from supporting Updater (that and the fact that Updater overwrites custom edits, but a convar can manage that.) Tutorial was easy to follow.
__________________
Sheepdude is offline
GoD-Tony
Veteran Member
Join Date: Jul 2005
Old 12-23-2012 , 07:41   Re: Updater Integration Using Bitbucket
Reply With Quote #3

Nice writeup!

Quote:
Originally Posted by Sheepdude View Post
Having a reliable website was the one thing keeping me from supporting Updater (that and the fact that Updater overwrites custom edits, but a convar can manage that.)
You just have to be careful not to include files such as configs in your updates, and any new configuration aside from the initial install of your plugin should be managed with suitable defaults.
__________________
GoD-Tony is offline
RedSword
SourceMod Plugin Approver
Join Date: Mar 2006
Location: Quebec, Canada
Old 12-24-2012 , 02:39   Re: Updater Integration Using Bitbucket
Reply With Quote #4

Thanks for the tutorial; that might come handy.
__________________
My plugins :
Red Maze
Afk Bomb
RAWR (per player/rounds Awp Restrict.)
Kill Assist
Be Medic

You can also Donate if you appreciate my work
RedSword is offline
Impact123
Veteran Member
Join Date: Oct 2011
Location: Germany
Old 01-04-2013 , 07:12   Re: Updater Integration Using Bitbucket
Reply With Quote #5

Just an thing which came to my mind while readind this and looking at your repo.
If you use this technique your masterbranch should always be deployable/stable.
In other words, the version you have in your updaterfile should always be equal to the one in master/default.
An workflow similar to this is important in this case.
  • New branch featurex
  • Working on feature x
  • Finish up feature x
  • Update versionfile and tag the changeset
  • Merge branch featurex to master/default
If you don't, bughunting can be horrible because some might have commit "x" and others commit "z" while using the same version.
Other than that this is a nice post, i would recommend dropbox for the "usual" developer though.

Yours sincerely
Impact
__________________

Last edited by Impact123; 01-04-2013 at 07:26.
Impact123 is offline
berni
SourceMod Plugin Approver
Join Date: May 2007
Location: Austria
Old 01-04-2013 , 12:49   Re: Updater Integration Using Bitbucket
Reply With Quote #6

Nice tutorial, but I like GIT & Github more.
__________________
Why reinvent the wheel ? Download smlib with over 350 useful functions.

When people ask me "Plz" just because it's shorter than "Please" I feel perfectly justified to answer "No" because it's shorter than "Yes"
powered by Core i7 3770k | 32GB DDR3 1886Mhz | 2x Vertex4 SSD Raid0
berni is offline
asherkin
SourceMod Developer
Join Date: Aug 2009
Location: OnGameFrame()
Old 01-04-2013 , 15:18   Re: Updater Integration Using Bitbucket
Reply With Quote #7

Quote:
Originally Posted by berni View Post
Nice tutorial, but I like GIT & Github more.
We're a Mercurial-based community. It's better for everyone if we're all using that.
__________________
asherkin is offline
berni
SourceMod Plugin Approver
Join Date: May 2007
Location: Austria
Old 01-04-2013 , 15:48   Re: Updater Integration Using Bitbucket
Reply With Quote #8

Quote:
Originally Posted by asherkin View Post
We're a Mercurial-based community. It's better for everyone if we're all using that.
I personally don't think Mercurial is bad, it's similar to Git in some aspects.
But I'm really a Git-addict, using it in my company and for every private project, so don't even try to convince me to switch to something else Git just feels lightweight and fast for me (I also already used Mercurial a lot of times).

But I really don't want to start a discussion about that, I'm really sure every versioning system has its benefits and everyone should just use what they like.
I don't mind using Mercurial when I have to, but I prefer Git for my own projects.
Please don't try to force people to use something.
__________________
Why reinvent the wheel ? Download smlib with over 350 useful functions.

When people ask me "Plz" just because it's shorter than "Please" I feel perfectly justified to answer "No" because it's shorter than "Yes"
powered by Core i7 3770k | 32GB DDR3 1886Mhz | 2x Vertex4 SSD Raid0
berni is offline
GoD-Tony
Veteran Member
Join Date: Jul 2005
Old 01-15-2013 , 08:43   Re: Updater Integration Using Bitbucket
Reply With Quote #9

I thought I'd ask here because I'm considering doing the same: Is it better to have a separate repository just for Updater releases, or to have named branches on the main one?

For example, code is always pushed to default, but Updater releases could be pushed to a "stable-release" branch, then maybe have a "dev-release" as well.

Is it down to personal preference or would one be more recommended than the other?
__________________
GoD-Tony is offline
psychonic

BAFFLED
Join Date: May 2008
Old 01-15-2013 , 08:53   Re: Updater Integration Using Bitbucket
Reply With Quote #10

Quote:
Originally Posted by GoD-Tony View Post
I thought I'd ask here because I'm considering doing the same: Is it better to have a separate repository just for Updater releases, or to have named branches on the main one?

For example, code is always pushed to default, but Updater releases could be pushed to a "stable-release" branch, then maybe have a "dev-release" as well.

Is it down to personal preference or would one be more recommended than the other?
Since it's transparent to the end user, use whatever is easiest for you.
psychonic is offline
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 11:08.


Powered by vBulletin®
Copyright ©2000 - 2018, vBulletin Solutions, Inc.
Theme made by Freecode