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.
You want to allow your plugin to automatically update using Updater
, but you don't have a website where you can host your plugin.
! 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.
- First, you'll need to create an account at bitbucket.org. Bitbucket supports Git and Mercurial (hg). This tutorial will cover Mercurial.
- If you don't already have it, download TortoiseHg and install it. This is the Mercurial client that we'll be using.
- Create your repository
- 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.
- 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.
- Configure your repository locally
- Create a folder on your local computer where you want to store the files for this repository.
- Right-click on the new folder you just created and select TortoiseHg > Clone....
- 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.
- Right-click on your folder again and choose TortoiseHg > Repository Settings.
- On the Workbench tab, choose update on the After pull operation dropdown.
- On the Commit tab, type your Bitbucket username into the Username box. Choose default in the Push After Commit box.
- Click OK
- Configure your repository on Bitbucket
- On your repository's overview page, which should still be open, click the gear icon
- On the Username aliases tab, type your Bitbucket username into both boxes and click Add.
- Configure your domain
- 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.
- Go to freedns.afraid.org and register an account.
- After you're registered and signed in, click here to access the shared domain registry. Click a domain you like.
- 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.
- For Destination, type bitbucket.org. This will point your subdomain at Bitbucket. Click Save.
- 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.
- Bitbucket should show you a green box telling you that your subdomain points to bitbucket.org. If it doesn't, you did something wrong.
- Push your code
- 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.
- Put the plugins that you have written into the scripting folder and their smx files into the plugins folder.
- 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
- 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.
- 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.
- 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.
- Click the gold padlock and type your Bitbucket username and password into the username and password fields, then click Save.
- Click the save button on the far left, make sure the Alias field reads default, and click Save. Close the Sync window.
- Right-click on your repository's folder and choose Hg Commit...
- 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
. 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.
- 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.
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.