View Single Post
Author Message
Dr. McKay
Sir Dr. SourceMod Plugin Approver Esq. Ltd. M.D. PhD
Join Date: Aug 2011
Location: Atlantis
Old 12-22-2012 , 21: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 00:53.
Dr. McKay is offline