Full details and best practices for samples can be found in the Sample Exchange Contribution Guide.

Go to Sample Exchange https://code.vmware.com/samples

Sign in using your MyVMware credentials

If you do not have a MyVMware account, you can create one at https://my.vmware.com. When you do this, please be sure to select the option to "also create a VMware Communities account".

Click on the "Sign In" button in the upper right corner. You can browse any of the sample content without being signed in, but in order to contribute you must sign in with your "MyVMware" credentials. Note also that you must have a VMware Communities account associated with your MyVMware account (anyone that has ever signed in to communities.vmware.com already has this).

Select the type of Sample you will contribute

There are 4 different locations for samples that Sample Exchange supports. Which one you choose depends on how the sample will be maintained in the future. You can see descriptions and tradeoffs below.

choose method

For the first two types, Paste Sample and Upload Sample, Sample Exchange creates a git repository on your behalf in a Github organization that VMware controls. If you have your code.vmware.com account linked to your Github account, you will be made a "collaborator" on the repository that is created so it is possible to edit your sample using standard Github mechanisms (note that the account linking must be done BEFORE you contribute the sample). You can also edit the sample using the Sample Exchange Web UI at any time as well in the case that you do not have a Github account.

Paste Sample:
This type of sample is useful for a small snippet of code that you would simply type in or paste from the clipboard.

Upload Sample:
If your sample is a single file or a zip of multiple files in your local file system you can use this method to add the sample.

Import from Github - Gist:
A "Gist" is Github's name for a Snippet of code. If you have one of these in your Github account you can easily add a sample for it. This has the advantage of being automatically synchronized between Github and Sample Exchange, so any changes you make to the sample are automatically picked up.

Import from Github - Repository:
This is the preferred method to maintain a sample. In this you can select an entire repository as a sample or a subset of files in a given repository. The repository can be in your personal Github account or in a Github organization you belong to. Any changes you make to your sample on Github will be automatically picked up by Sample Exchange.

NOTE: If you have not previously associated your MyVMware account with your Github account you can do so via the "Link your account with Github" link. This step uses Github OAUTH services to get a "token" that Sample Exchange can use to gain read access to your Github repositories and Gists.

choose method

Contributing the entire repository as a sample

SX can support an entire repository being a sample. To do this, simply select the root of the repository in the contribution UI. All files in the repo are treated as a part of the sample and any future modifications will be picked up automatically.

NOTE: Please consider whether or not the repository does in fact contain different samples that expose different features. In this case, creating multiple samples and selecting different subsets of the repository might be better since it will then enable more granular discovery of your samples. (SX does create pages and infrastructure to help Google index samples better, so more samples will help this)

Selecting a subset of repository files as a sample

SX allows selecting child folders as well as individual files within a repository. In the case of a sample that has multiple files, it is typically best to select folders when adding the sample. If you do this, then all content under that folder will be included in the sample. That means if you add new files in the future (or delete existing files) on Github, SX will be able to pick up the changes accordingly.

In the case of samples with shared utility code, you can select the sample as well as any other code in the project that you wish to be included in the sample.

NOTE: currently when you click to "Download" a sample in SX, Github services are used to create a zip of the sample. Github does not support being able to specify a subset of repo files when creating a zip. As a result, a download of a given sample will include all content in the repo. (the flip side is that this may in fact be best depending on the structure of your samples and their dependencies)

Sample Exchange requires a few pieces of additional metadata for the sample. SX does attempt to analyze the selected files themselves to automatically provide defaults for things like sample name, description, tags, and such. There are some supported conventions for comments and such that can greatly improve this heuristically determined metadata. See the "Github Repository best-practices" section in the Sample Exchange Contribution Guide for more detail.

Perhaps the most important thing to note is that it is also possible to use a README.md file in your Github repository as the description for your sample. This allows Sample Exchange to automatically pick up any changes you make to the sample body as well as the description of the sample, keeping Github as the canonical place for all sample content.

choose method