In order to upgrade/level up weapons, both melee and ranged, you need to play the Operations mode.
First, switch to that mode through the terminal found by the Thunderhawk embarkation point.
Next, go to the Armouring Hall to set up your character. Once there, you can customize your character and select your weapon. The Heavy is the only character with access to the Heavy Bolter, Heavy Plasma Incinerator, and Multi-Melta for exp. The Assault & Bulwarks only have access to the Bolt Pistol (both), Heavy Bolt Pistol (Assault) & Plasma Pistol (Bulwark) for Ranged weapons. The Sniper is the only class to have access to the Bolt Sniper Rifle & Las Fusil.
Once you've selected your weapon, you'll see two tabs labeled Version & Perks. Version is what we are concerned with. You'll also see 0 (Standard), 1500 (Master Crafted), 7500 (Artificier), and 17000 (Relic). That is the amount of experience needed to upgrade your weapon to that tier. Once you've got your character set up, go and play Operations till you get enough EXP to upgrade. Be sure and use all your weapons during the mission. If you only use, for example, your Primary weapon, but forget to use your Melee or Secondary, you'll only get exp for the Primary.
Once you've gotten 1500 exp with that weapon, go back to the Armouring Hall and back into the Customization. You'll have gotten a Mastery point that can be used to buy a Perk. Now, you'll be able to buy the next tier of weapon with Requisition Points, gained from completing Operations. You can continue to use your Mastered weapon and gain overall experience for the bar, but weapons in higher tiers are just plain better and you should save Requisition Points to buy a new one. Plus, switching weapons allows you to gain more Mastery points (eventually) and that means more Perks and that means you increase in strength and capabilities.
HOWEVER...you'll also need Armory Data to upgrade to the next tier of weapon. To go to Master Crafted, you'll need a green AD. Green ADs can be obtained from Minimal & Average operations, AND through completing the Trials for each character, so you'll be able to get 18 of them without doing Operations. In order to get the Purple & Orange Armoury Datas, you'll need to play the Substantial and Ruthless Operations. Those can either be found within the mission or given as a reward for completing the Operation. You'll need to either find a Servoskull (floating skulls with red eyes) or defeat a miniboss to get an Armoury Data.
Weapon exp is cumulative through multiple characters, so you only need to level up your weapon once, rather than doing say the Bolt Pistol multiple times (other than doing multiple different pistols within a tier).
The following is how much exp is required to max the bar for each of the Ranged Weapons:
22800
Auto Bolt Rifle
25700
Heavy Plasma Incinerator
Multi Melta
Stalker Bolt Rifle
Melta Rifle
Bolt Pistol
Heavy Bolt Pistol
Instigator Bolt Rifle
Plasma Pistol
Bolt Sniper Rifle
Las Fusil
28600
Heavy Bolter
Bolt Rifle
Heavy Bolt Rifle
Bolt Carbine
Plasma Incinerator
Occulus Bolt Rifle