Fractures contribute significantly to the overall permeability of naturally or hydraulically fractured reservoirs. In the cap rock, fractures may provide unwanted pathways for reservoir or stimulation fluids. Predicting fluid flow in naturally fractured rocks under production or fluid injection requires that permeability of a single, rough-walled fracture be well understood and accurately described as a function of the effective stress. The lack of information about the properties of fractures at depth calls for a numerical approach that would enable predicting the fracture permeability as a function of the effective normal stress. Such fully computational approach is developed in this study. The fracture deformation is calculated by solving the contact problem using the finite-element method. At each deformation step, the steady-state fluid flow in the fracture is computed in two orthogonal directions using the lubrication theory approximation, in order to evaluate the permeability and the hydraulic aperture of the fracture. The computational approach is tested on two examples: a 'brittle rock' (linear elastic) and a 'ductile rock' (linear elastic perfectly plastic). Both mechanical and hydraulic behaviours of the fracture under cyclic normal loading are found to be in qualitative agreement with the results obtained in a number of published experimental studies. The computational approach provides an insight into the actual mechanics of the fracture deformation under stress, and the effect of the latter on the permeability. In particular, hysteresis in the fracture roughness is obtained with the 'ductile rock', suggesting that (at least some) fractured rocks may retain 'memory' about their loading history imprinted in the fracture landscapes.