This article demonstrates how to contribute a module to Drupal.org. Before contributing to Drupal.org, make sure you tick the following boxes:
- You have an account at Drupal.org. If you don’t have one, then you can easily create one now.
- Your module is ready to deploy and conforms to the Drupal coding standards.
- Your module includes a README file and is written using the proper template.
- Know that once you contribute a project to Drupal.org, it can't be deleted. However, its status can be changed.
- Know that you can still contribute a module to Drupal.org, even if your account status is "Not Valid User."Please follow the below steps to contribute your module to Drupal.org:
Step 1: Go to https://www.drupal.org/dashboard
Click on the "Add a new project" link.
Step 2: Select “Module Project” from the project category list.
Although you can select multiple categories from the list, however, we will only be opting for the "Module project" item, as shown below.
Step 3: Fill the Create Module Project form.
Name: This field is required, and you can change it later if you want.
Project Type: This field is required and provides you with two options to choose from.
- Full project: Go for this option if you're confident enough that your module is working. Other users will then be able to download this module and use it in their projects.
- Sandbox project: In case you opt for this option, then your module will be available at the following URL: /sandbox/username/node-id, replace username and node-id with their respective values. Also, this option does not allow you to generate releases for your module, to put it in simple words, your module will not be available for other users to download. However, you can later promote the sandbox project to a full project.
Short name: Fill this field with great caution as you will not change its value later on. The short name will appear in the URL, such as drupal.org/project/[short_name]. Pick a unique name (in lower case) that is relevant to your module.
Project Classifications: This field allows you to assign a status to your module, such as Maintenance status, Development status, and so forth.
Images: As easily evident from the name, this field allows you to attach Images to your module. It is placed in parallel to the description field. You can upload images in png, gif, jpg, and jpeg formats.
Description: This field consist of headings that will be in a h3 HTML tag(e.g.<H3>Requirements</H3>). Following are some important headings of this field.
- Synopsis (Brief): This should start with telling users what the project does, what problem it solves.
- Requirements: Link to required contributed modules, themes, etc.
- Recommended modules: List any module that is not required but if enabled, will enhance your module’s functionality.
- Roadmap: Your plans for further developments.
- Credits: The list of maintainers who are working on this project.
- Known problems: Be upfront about known problems and limitations.
- Help wanted: If a co-maintainer is needed to assist in maintaining the project. Ref: link
Drupal 9 Porting info: This field provides you with several different statuses. You can select any of them.
File Attachments: Here, we will add your README file.
Supporting Organizations: Enter your organization name and then state how they have helped you. With this, the module will appear on the organization profile as well, along with your user profile. Ignore the rest of the information and save the form. Once it's saved, your description, pics, and README all will be posted on drupal.org/project/[short_name]. So, now you can go and check out your module.
Step 4: Setting up Git for Drupal.org
You can ignore this step if your SSH key is already added. Before creating releases for your module, you will need to set up Git, by following the below steps (don’t worry, you will have to go through this ordeal only the first time). - Start with installing Git from https://git-scm.com/downloads.
- After that, you will have to authenticate with SSH Keys. First, you need to check if the below command generates previous SSH keys in the terminal:
$ cd ~/.ssh
Then you need to check the files in this folder using the following command:
$ ls
You will see a couple of different files with names like "id_dsa" or "id_rsa" and an identical file with a .pub extension. The .pub file is your public key, and the other file is the matching private key. To generate SSH keys, you will have to enter the below command in the terminal
$ ssh-keygen -o
Once you run the above command, you will be asked for some information:
Generating P...
Enter file in which.. :
Created….
Enter… :
Enter… :
Your identification...
Your public...
The key fingerprint is:
dE:FS:2D...
If you face any issues in following the above steps, you can then go to their official site and follow the given steps to generate the SSH key. Once you have completed the above steps, you will then need to open the id_rsa.pub file and copy content from "ssh-RSA…. till the end," and then paste it into your profile dashboard by following the below steps.
- Click on profile,
- Then click on SSH keys.
- Afterward, click on the "Add a public key" link, and paste the SSH key you have copied from the id_rsa.pub file.
Step 5: Add New Release.
To add a new release to your module. Scroll down and click on the "Add new release" link.
Since, at the moment, there are no valid branches or tags, so you’ll have to click on "Git instruction," it will then redirect you to the essential Git commands, using which you can upload your module code.
Step 6: Setting up Branches (dev releases) and Tags (stable versions).
You will have to set up a repository in your local environment. To do so, you’ll have to clone your module using the below commands. These commands will be provided to you and will be unique for each module.
$ git clone --branch 8.x-3.x git@git.drupal.org:project/galleryslider.git
$ cd galleryslider
Then you will create a branch using the naming convention
$ git branch -a
$ git checkout [branchname]
Once you have created the branch, you can then go ahead and make any changes you want to the module. When you are done making changes, you will have to commit your changes, and you can do so using the below command.
$ Git add .
$ git commit -m "Issue # [issue no.] by [usernames]: [Changes short summary]."
Afterward, push your code
$ git push -u origin [branchname]
After that, you need to repeat step 5. That’s it. Thank you for reading. If you face any difficulties implementing any of the steps above, then leave a comment below.
riaz
Sr. Drupal Developer/ Module Developer